<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
$domain = ($translate === TRUE) ? $ext : $translate;
$this->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);
}
* @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);
}
// 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);
}
}
/**
* 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";
}
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;
+ }
+ }
+ }
+
}