Merge pull request #9680 from h-c-c/CRM-19881
[civicrm-core.git] / CRM / Core / Resources.php
index 67ec542aa7d48b500c933497307379ede38a8493..52815a69f74cb558db1ef6812a511e2480ac2700 100644 (file)
@@ -3,7 +3,7 @@
   +--------------------------------------------------------------------+
   | CiviCRM version 4.7                                                |
   +--------------------------------------------------------------------+
-  | Copyright CiviCRM LLC (c) 2004-2016                                |
+  | Copyright CiviCRM LLC (c) 2004-2017                                |
   +--------------------------------------------------------------------+
   | This file is a part of CiviCRM.                                    |
   |                                                                    |
@@ -37,7 +37,7 @@
  * should incorporte services for aggregation, minimization, etc.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  * $Id$
  *
  */
@@ -712,7 +712,6 @@ class CRM_Core_Resources {
       "bower_components/select2/select2.min.js",
       "bower_components/select2/select2.min.css",
       "bower_components/font-awesome/css/font-awesome.min.css",
-      "packages/jquery/plugins/jquery.tableHeader.js",
       "packages/jquery/plugins/jquery.form.min.js",
       "packages/jquery/plugins/jquery.timeentry.min.js",
       "packages/jquery/plugins/jquery.blockUI.min.js",
@@ -727,15 +726,18 @@ class CRM_Core_Resources {
     // add wysiwyg editor
     $editor = Civi::settings()->get('editor_id');
     if ($editor == "CKEditor") {
-      $items[] = "js/wysiwyg/crm.ckeditor.js";
-      $ckConfig = CRM_Admin_Page_CKEditorConfig::getConfigUrl();
-      if ($ckConfig) {
-        $items[] = array('config' => array('CKEditorCustomConfig' => $ckConfig));
-      }
+      CRM_Admin_Page_CKEditorConfig::setConfigDefault();
+      $items[] = array(
+        'config' => array(
+          'wysisygScriptLocation' => Civi::paths()->getUrl("[civicrm.root]/js/wysiwyg/crm.ckeditor.js"),
+          'CKEditorCustomConfig' => CRM_Admin_Page_CKEditorConfig::getConfigUrl(),
+        ),
+      );
     }
 
     // These scripts are only needed by back-office users
     if (CRM_Core_Permission::check('access CiviCRM')) {
+      $items[] = "packages/jquery/plugins/jquery.tableHeader.js";
       $items[] = "packages/jquery/plugins/jquery.menu.min.js";
       $items[] = "css/civicrmNavigation.css";
       $items[] = "packages/jquery/plugins/jquery.jeditable.min.js";
@@ -779,17 +781,21 @@ class CRM_Core_Resources {
    *   is this page request an ajax snippet?
    */
   public static function isAjaxMode() {
-    return in_array(CRM_Utils_Array::value('snippet', $_REQUEST), array(
+    if (in_array(CRM_Utils_Array::value('snippet', $_REQUEST), array(
         CRM_Core_Smarty::PRINT_SNIPPET,
         CRM_Core_Smarty::PRINT_NOFORM,
         CRM_Core_Smarty::PRINT_JSON,
-      ));
+      ))
+    ) {
+      return TRUE;
+    }
+    return strpos(CRM_Utils_System::getUrlPath(), 'civicrm/ajax') === 0;
   }
 
   /**
    * Provide a list of available entityRef filters.
-   * FIXME: This function doesn't really belong in this class
-   * @TODO: Provide a sane way to extend this list for other entities - a hook or??
+   * @todo: move component filters into their respective components (e.g. CiviEvent)
+   *
    * @return array
    */
   public static function getEntityRefFilters() {
@@ -834,6 +840,7 @@ class CRM_Core_Resources {
       array('key' => 'country', 'value' => ts('Country'), 'entity' => 'address'),
       array('key' => 'gender_id', 'value' => ts('Gender')),
       array('key' => 'is_deceased', 'value' => ts('Deceased')),
+      array('key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'),
     );
 
     if (in_array('CiviCase', $config->enableComponents)) {
@@ -856,6 +863,8 @@ class CRM_Core_Resources {
       }
     }
 
+    CRM_Utils_Hook::entityRefFilters($filters);
+
     return $filters;
   }