X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=f5f57cfd4c6195c2934672ead91cef2b89691366;hb=7e9e8871fab6ef8220dffbe418460ebc9c61ed33;hp=e1663fc7bf0509c3237b7f3f457ec6bd0c3f75ef;hpb=0af9027c8c3fd57397b3f17e71c9c8ca3e57fca9;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index e1663fc7bf..f5f57cfd4c 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -1,7 +1,7 @@ addString($this->strings->get($domain, $this->getPath($ext, $file), 'text/javascript'), $domain); } - // Look for non-minified version if we are in debug mode - if (CRM_Core_Config::singleton()->debug && strpos($file, '.min.js') !== FALSE) { - $nonMiniFile = str_replace('.min.js', '.js', $file); - if ($this->getPath($ext, $nonMiniFile)) { - $file = $nonMiniFile; - } - } + $this->resolveFileName($file, $ext); return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region); } @@ -416,6 +410,7 @@ class CRM_Core_Resources { * @return CRM_Core_Resources */ public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { + $this->resolveFileName($file, $ext); return $this->addStyleUrl($this->getUrl($ext, $file, TRUE), $weight, $region); } @@ -587,14 +582,17 @@ class CRM_Core_Resources { // Add resources from coreResourceList $jsWeight = -9999; - foreach ($this->coreResourceList($region) as $file) { - if (substr($file, -2) == 'js') { + foreach ($this->coreResourceList($region) as $item) { + if (is_array($item)) { + $this->addSetting($item); + } + elseif (substr($item, -2) == 'js') { // Don't bother looking for ts() calls in packages, there aren't any - $translate = (substr($file, 0, 3) == 'js/'); - $this->addScriptFile('civicrm', $file, $jsWeight++, $region, $translate); + $translate = (substr($item, 0, 3) == 'js/'); + $this->addScriptFile('civicrm', $item, $jsWeight++, $region, $translate); } else { - $this->addStyleFile('civicrm', $file, -100, $region); + $this->addStyleFile('civicrm', $item, -100, $region); } } @@ -685,44 +683,53 @@ class CRM_Core_Resources { /** * List of core resources we add to every CiviCRM page. * + * Note: non-compressed versions of .min files will be used in debug mode + * * @param string $region * @return array */ public function coreResourceList($region) { $config = CRM_Core_Config::singleton(); - // Use minified files for production, uncompressed in debug mode - // Note, $this->addScriptFile would automatically search for the non-minified file in debug mode but this is probably faster - $min = $config->debug ? '' : '.min'; // Scripts needed by everyone, everywhere // FIXME: This is too long; list needs finer-grained segmentation $items = array( "bower_components/jquery/dist/jquery.min.js", "bower_components/jquery-ui/jquery-ui.min.js", - "bower_components/jquery-ui/themes/smoothness/jquery-ui$min.css", + "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css", "bower_components/lodash-compat/lodash.min.js", - "packages/jquery/plugins/jquery.mousewheel$min.js", - "bower_components/select2/select2$min.js", - "bower_components/select2/select2$min.css", + "packages/jquery/plugins/jquery.mousewheel.min.js", + "bower_components/select2/select2.min.js", + "bower_components/select2/select2.min.css", "packages/jquery/plugins/jquery.tableHeader.js", - "packages/jquery/plugins/jquery.textarearesizer.js", - "packages/jquery/plugins/jquery.form$min.js", - "packages/jquery/plugins/jquery.timeentry$min.js", - "packages/jquery/plugins/jquery.blockUI$min.js", - "packages/jquery/plugins/DataTables/media/js/jquery.dataTables$min.js", - "packages/jquery/plugins/DataTables/media/css/jquery.dataTables$min.css", - "bower_components/jquery-validation/dist/jquery.validate$min.js", - "packages/jquery/plugins/jquery.ui.datepicker.validation.pack.js", + "packages/jquery/plugins/jquery.form.min.js", + "packages/jquery/plugins/jquery.timeentry.min.js", + "packages/jquery/plugins/jquery.blockUI.min.js", + "bower_components/datatables/media/js/jquery.dataTables.min.js", + "bower_components/datatables/media/css/jquery.dataTables.min.css", + "bower_components/jquery-validation/dist/jquery.validate.min.js", + "packages/jquery/plugins/jquery.ui.datepicker.validation.min.js", "js/Common.js", "js/crm.ajax.js", ); + // add wysiwyg editor + $editor = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id'); + $items[] = "js/wysiwyg/crm.wysiwyg.js"; + if ($editor == "CKEditor") { + $items[] = "bower_components/ckeditor/ckeditor.js"; + $items[] = "js/wysiwyg/crm.ckeditor.js"; + $ckConfig = CRM_Admin_Page_CKEditorConfig::getConfigUrl(); + if ($ckConfig) { + $items[] = array('config' => array('CKEditorCustomConfig' => $ckConfig)); + } + } // These scripts are only needed by back-office users if (CRM_Core_Permission::check('access CiviCRM')) { - $items[] = "packages/jquery/plugins/jquery.menu$min.js"; + $items[] = "packages/jquery/plugins/jquery.menu.min.js"; $items[] = "css/navigation.css"; - $items[] = "packages/jquery/plugins/jquery.jeditable$min.js"; - $items[] = "packages/jquery/plugins/jquery.notify$min.js"; + $items[] = "packages/jquery/plugins/jquery.jeditable.min.js"; + $items[] = "packages/jquery/plugins/jquery.notify.min.js"; $items[] = "js/jquery/jquery.crmeditable.js"; } @@ -809,4 +816,19 @@ class CRM_Core_Resources { return $filters; } + /** + * In debug mode, look for a non-minified version of this file + * + * @param string $fileName + * @param string $extName + */ + private function resolveFileName(&$fileName, $extName) { + if (CRM_Core_Config::singleton()->debug && strpos($fileName, '.min.') !== FALSE) { + $nonMiniFile = str_replace('.min.', '.', $fileName); + if ($this->getPath($extName, $nonMiniFile)) { + $fileName = $nonMiniFile; + } + } + } + }