3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * This class facilitates the loading of resources
30 * such as JavaScript files and CSS files.
32 * Any URLs generated for resources may include a 'cache-code'. By resetting the
33 * cache-code, one may force clients to re-download resource files (regardless of
34 * any HTTP caching rules).
36 * TODO: This is currently a thin wrapper over CRM_Core_Region. We
37 * should incorporte services for aggregation, minimization, etc.
40 * @copyright CiviCRM LLC (c) 2004-2018
44 class CRM_Core_Resources
{
45 const DEFAULT_WEIGHT
= 0;
46 const DEFAULT_REGION
= 'page-footer';
49 * We don't have a container or dependency-injection, so use singleton instead
53 private static $_singleton = NULL;
56 * @var CRM_Extension_Mapper
58 private $extMapper = NULL;
61 * @var CRM_Core_Resources_Strings
63 private $strings = NULL;
66 * @var array free-form data tree
68 protected $settings = array();
69 protected $addedSettings = FALSE;
72 * @var array of callables
74 protected $settingsFactories = array();
77 * @var array ($regionName => bool)
79 protected $addedCoreResources = array();
82 * @var array ($regionName => bool)
84 protected $addedCoreStyles = array();
87 * @var string a value to append to JS/CSS URLs to coerce cache resets
89 protected $cacheCode = NULL;
92 * @var string the name of a setting which persistently stores the cacheCode
94 protected $cacheCodeKey = NULL;
99 public $ajaxPopupsEnabled;
102 * @var \Civi\Core\Paths
107 * Get or set the single instance of CRM_Core_Resources.
109 * @param CRM_Core_Resources $instance
110 * New copy of the manager.
111 * @return CRM_Core_Resources
113 static public function singleton(CRM_Core_Resources
$instance = NULL) {
114 if ($instance !== NULL) {
115 self
::$_singleton = $instance;
117 if (self
::$_singleton === NULL) {
118 $sys = CRM_Extension_System
::singleton();
119 $cache = Civi
::cache('js_strings');
120 self
::$_singleton = new CRM_Core_Resources(
123 CRM_Core_Config
::isUpgradeMode() ?
NULL : 'resCacheCode'
126 return self
::$_singleton;
130 * Construct a resource manager.
132 * @param CRM_Extension_Mapper $extMapper
133 * Map extension names to their base path or URLs.
134 * @param CRM_Utils_Cache_Interface $cache
135 * JS-localization cache.
136 * @param string|null $cacheCodeKey Random code to append to resource URLs; changing the code forces clients to reload resources
138 public function __construct($extMapper, $cache, $cacheCodeKey = NULL) {
139 $this->extMapper
= $extMapper;
140 $this->strings
= new CRM_Core_Resources_Strings($cache);
141 $this->cacheCodeKey
= $cacheCodeKey;
142 if ($cacheCodeKey !== NULL) {
143 $this->cacheCode
= Civi
::settings()->get($cacheCodeKey);
145 if (!$this->cacheCode
) {
146 $this->resetCacheCode();
148 $this->ajaxPopupsEnabled
= (bool) Civi
::settings()->get('ajaxPopupsEnabled');
149 $this->paths
= Civi
::paths();
153 * Export permission data to the client to enable smarter GUIs.
155 * Note: Application security stems from the server's enforcement
156 * of the security logic (e.g. in the API permissions). There's no way
157 * the client can use this info to make the app more secure; however,
158 * it can produce a better-tuned (non-broken) UI.
160 * @param array $permNames
161 * List of permission names to check/export.
162 * @return CRM_Core_Resources
164 public function addPermissions($permNames) {
165 $permNames = (array) $permNames;
167 foreach ($permNames as $permName) {
168 $perms[$permName] = CRM_Core_Permission
::check($permName);
170 return $this->addSetting(array(
171 'permissions' => $perms,
176 * Add a JavaScript file to the current page using <SCRIPT SRC>.
179 * extension name; use 'civicrm' for core.
180 * @param string $file
181 * file path -- relative to the extension base dir.
183 * relative weight within a given region.
184 * @param string $region
185 * location within the file; 'html-header', 'page-header', 'page-footer'.
186 * @param bool|string $translate
187 * Whether to load translated strings for this file. Use one of:
188 * - FALSE: Do not load translated strings.
189 * - TRUE: Load translated strings. Use the $ext's default domain.
190 * - string: Load translated strings. Use a specific domain.
192 * @return CRM_Core_Resources
194 public function addScriptFile($ext, $file, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
, $translate = TRUE) {
196 $domain = ($translate === TRUE) ?
$ext : $translate;
197 $this->addString($this->strings
->get($domain, $this->getPath($ext, $file), 'text/javascript'), $domain);
199 $this->resolveFileName($file, $ext);
200 return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
204 * Add a JavaScript file to the current page using <SCRIPT SRC>.
208 * relative weight within a given region.
209 * @param string $region
210 * location within the file; 'html-header', 'page-header', 'page-footer'.
211 * @return CRM_Core_Resources
213 public function addScriptUrl($url, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
214 CRM_Core_Region
::instance($region)->add(array(
216 'type' => 'scriptUrl',
225 * Add a JavaScript file to the current page using <SCRIPT SRC>.
227 * @param string $code
228 * JavaScript source code.
230 * relative weight within a given region.
231 * @param string $region
232 * location within the file; 'html-header', 'page-header', 'page-footer'.
233 * @return CRM_Core_Resources
235 public function addScript($code, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
236 CRM_Core_Region
::instance($region)->add(array(
237 // 'name' => automatic
247 * Add JavaScript variables to CRM.vars
251 * CRM_Core_Resources::singleton()->addVars('myNamespace', array('foo' => 'bar'));
252 * Access var from javascript:
253 * CRM.vars.myNamespace.foo // "bar"
255 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference
257 * @param string $nameSpace
258 * Usually the name of your extension.
260 * @return CRM_Core_Resources
262 public function addVars($nameSpace, $vars) {
263 $existing = CRM_Utils_Array
::value($nameSpace, CRM_Utils_Array
::value('vars', $this->settings
), array());
264 $vars = $this->mergeSettings($existing, $vars);
265 $this->addSetting(array('vars' => array($nameSpace => $vars)));
270 * Add JavaScript variables to the root of the CRM object.
271 * This function is usually reserved for low-level system use.
272 * Extensions and components should generally use addVars instead.
274 * @param array $settings
275 * @return CRM_Core_Resources
277 public function addSetting($settings) {
278 $this->settings
= $this->mergeSettings($this->settings
, $settings);
279 if (!$this->addedSettings
) {
280 $region = self
::isAjaxMode() ?
'ajax-snippet' : 'html-header';
282 CRM_Core_Region
::instance($region)->add(array(
283 'callback' => function (&$snippet, &$html) use ($resources) {
284 $html .= "\n" . $resources->renderSetting();
288 $this->addedSettings
= TRUE;
294 * Add JavaScript variables to the global CRM object via a callback function.
296 * @param callable $callable
297 * @return CRM_Core_Resources
299 public function addSettingsFactory($callable) {
300 // Make sure our callback has been registered
301 $this->addSetting(array());
302 $this->settingsFactories
[] = $callable;
307 * Helper fn for addSettingsFactory.
309 public function getSettings() {
310 $result = $this->settings
;
311 foreach ($this->settingsFactories
as $callable) {
312 $result = $this->mergeSettings($result, $callable());
314 CRM_Utils_Hook
::alterResourceSettings($result);
319 * @param array $settings
320 * @param array $additions
322 * combination of $settings and $additions
324 protected function mergeSettings($settings, $additions) {
325 foreach ($additions as $k => $v) {
326 if (isset($settings[$k]) && is_array($settings[$k]) && is_array($v)) {
335 * Helper fn for addSetting.
336 * Render JavaScript variables for the global CRM object.
340 public function renderSetting() {
341 // On a standard page request we construct the CRM object from scratch
342 if (!self
::isAjaxMode()) {
343 $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
345 // For an ajax request we append to it
347 $js = 'CRM.$.extend(true, CRM, ' . json_encode($this->getSettings()) . ');';
349 return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
353 * Add translated string to the js CRM object.
354 * It can then be retrived from the client-side ts() function
355 * Variable substitutions can happen from client-side
357 * Note: this function rarely needs to be called directly and is mostly for internal use.
358 * See CRM_Core_Resources::addScriptFile which automatically adds translated strings from js files
362 * CRM_Core_Resources::singleton()->addString('Hello');
363 * // The string is now available to javascript code i.e.
366 * Example with client-side substitutions:
368 * CRM_Core_Resources::singleton()->addString('Your %1 has been %2');
369 * // ts() in javascript works the same as in php, for example:
370 * ts('Your %1 has been %2', {1: objectName, 2: actionTaken});
372 * NOTE: This function does not work with server-side substitutions
373 * (as this might result in collisions and unwanted variable injections)
374 * Instead, use code like:
375 * CRM_Core_Resources::singleton()->addSetting(array('myNamespace' => array('myString' => ts('Your %1 has been %2', array(subs)))));
376 * And from javascript access it at CRM.myNamespace.myString
378 * @param string|array $text
379 * @param string|NULL $domain
380 * @return CRM_Core_Resources
382 public function addString($text, $domain = 'civicrm') {
383 foreach ((array) $text as $str) {
384 $translated = ts($str, array(
385 'domain' => ($domain == 'civicrm') ?
NULL : array($domain, NULL),
389 // We only need to push this string to client if the translation
390 // is actually different from the original
391 if ($translated != $str) {
392 $bucket = $domain == 'civicrm' ?
'strings' : 'strings::' . $domain;
393 $this->addSetting(array(
394 $bucket => array($str => $translated),
402 * Add a CSS file to the current page using <LINK HREF>.
405 * extension name; use 'civicrm' for core.
406 * @param string $file
407 * file path -- relative to the extension base dir.
409 * relative weight within a given region.
410 * @param string $region
411 * location within the file; 'html-header', 'page-header', 'page-footer'.
412 * @return CRM_Core_Resources
414 public function addStyleFile($ext, $file, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
415 $this->resolveFileName($file, $ext);
416 return $this->addStyleUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
420 * Add a CSS file to the current page using <LINK HREF>.
424 * relative weight within a given region.
425 * @param string $region
426 * location within the file; 'html-header', 'page-header', 'page-footer'.
427 * @return CRM_Core_Resources
429 public function addStyleUrl($url, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
430 CRM_Core_Region
::instance($region)->add(array(
432 'type' => 'styleUrl',
441 * Add a CSS content to the current page using <STYLE>.
443 * @param string $code
446 * relative weight within a given region.
447 * @param string $region
448 * location within the file; 'html-header', 'page-header', 'page-footer'.
449 * @return CRM_Core_Resources
451 public function addStyle($code, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
452 CRM_Core_Region
::instance($region)->add(array(
453 // 'name' => automatic
463 * Determine file path of a resource provided by an extension.
466 * extension name; use 'civicrm' for core.
467 * @param string|NULL $file
468 * file path -- relative to the extension base dir.
470 * @return bool|string
471 * full file path or FALSE if not found
473 public function getPath($ext, $file = NULL) {
474 // TODO consider caching results
475 $base = $this->paths
->hasVariable($ext)
476 ?
rtrim($this->paths
->getVariable($ext, 'path'), '/')
477 : $this->extMapper
->keyToBasePath($ext);
478 if ($file === NULL) {
481 $path = $base . '/' . $file;
482 if (is_file($path)) {
489 * Determine public URL of a resource provided by an extension.
492 * extension name; use 'civicrm' for core.
493 * @param string $file
494 * file path -- relative to the extension base dir.
495 * @param bool $addCacheCode
497 * @return string, URL
499 public function getUrl($ext, $file = NULL, $addCacheCode = FALSE) {
500 if ($file === NULL) {
504 $file = $this->addCacheCode($file);
506 // TODO consider caching results
507 $base = $this->paths
->hasVariable($ext)
508 ?
$this->paths
->getVariable($ext, 'url')
509 : ($this->extMapper
->keyToUrl($ext) . '/');
510 return $base . $file;
514 * Evaluate a glob pattern in the context of a particular extension.
517 * Extension name; use 'civicrm' for core.
518 * @param string|array $patterns
519 * Glob pattern; e.g. "*.html".
520 * @param null|int $flags
523 * List of matching files, relative to the extension base dir.
526 public function glob($ext, $patterns, $flags = NULL) {
527 $path = $this->getPath($ext);
528 $patterns = (array) $patterns;
530 foreach ($patterns as $pattern) {
531 if (preg_match(';^(assetBuilder|ext)://;', $pattern)) {
534 if (CRM_Utils_File
::isAbsolute($pattern)) {
536 $files = array_merge($files, (array) glob($pattern, $flags));
540 $files = array_merge($files, (array) glob("$path/$pattern", $flags));
543 sort($files); // Deterministic order.
544 $files = array_unique($files);
545 return array_map(function ($file) use ($path) {
546 return CRM_Utils_File
::relativize($file, "$path/");
553 public function getCacheCode() {
554 return $this->cacheCode
;
559 * @return CRM_Core_Resources
561 public function setCacheCode($value) {
562 $this->cacheCode
= $value;
563 if ($this->cacheCodeKey
) {
564 Civi
::settings()->set($this->cacheCodeKey
, $value);
570 * @return CRM_Core_Resources
572 public function resetCacheCode() {
573 $this->setCacheCode(CRM_Utils_String
::createRandom(5, CRM_Utils_String
::ALPHANUMERIC
));
574 // Also flush cms resource cache if needed
575 CRM_Core_Config
::singleton()->userSystem
->clearResourceCache();
580 * This adds CiviCRM's standard css and js to the specified region of the document.
581 * It will only run once.
583 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
584 * (like addCoreResources/addCoreStyles).
586 * @param string $region
587 * @return CRM_Core_Resources
589 public function addCoreResources($region = 'html-header') {
590 if (!isset($this->addedCoreResources
[$region]) && !self
::isAjaxMode()) {
591 $this->addedCoreResources
[$region] = TRUE;
592 $config = CRM_Core_Config
::singleton();
594 // Add resources from coreResourceList
596 foreach ($this->coreResourceList($region) as $item) {
597 if (is_array($item)) {
598 $this->addSetting($item);
600 elseif (substr($item, -2) == 'js') {
601 // Don't bother looking for ts() calls in packages, there aren't any
602 $translate = (substr($item, 0, 3) == 'js/');
603 $this->addScriptFile('civicrm', $item, $jsWeight++
, $region, $translate);
606 $this->addStyleFile('civicrm', $item, -100, $region);
610 $tsLocale = CRM_Core_I18n
::getLocale();
611 // Dynamic localization script
612 $this->addScriptUrl(CRM_Utils_System
::url('civicrm/ajax/l10n-js/' . $tsLocale, array('r' => $this->getCacheCode())), $jsWeight++
, $region);
614 // Add global settings
617 'isFrontend' => $config->userFrameworkFrontend
,
620 // Disable profile creation if user lacks permission
621 if (!CRM_Core_Permission
::check('edit all contacts') && !CRM_Core_Permission
::check('add contacts')) {
622 $settings['config']['entityRef']['contactCreate'] = FALSE;
624 $this->addSetting($settings);
626 // Give control of jQuery and _ back to the CMS - this loads last
627 $this->addScriptFile('civicrm', 'js/noconflict.js', 9999, $region, FALSE);
629 $this->addCoreStyles($region);
635 * This will add CiviCRM's standard CSS
637 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
638 * (like addCoreResources/addCoreStyles).
640 * @param string $region
641 * @return CRM_Core_Resources
643 public function addCoreStyles($region = 'html-header') {
644 if (!isset($this->addedCoreStyles
[$region])) {
645 $this->addedCoreStyles
[$region] = TRUE;
647 // Load custom or core css
648 $config = CRM_Core_Config
::singleton();
649 if (!empty($config->customCSSURL
)) {
650 $customCSSURL = $this->addCacheCode($config->customCSSURL
);
651 $this->addStyleUrl($customCSSURL, 99, $region);
653 if (!Civi
::settings()->get('disable_core_css')) {
654 $this->addStyleFile('civicrm', 'css/civicrm.css', -99, $region);
656 // crm-i.css added ahead of other styles so it can be overridden by FA.
657 $this->addStyleFile('civicrm', 'css/crm-i.css', -101, $region);
663 * Flushes cached translated strings.
664 * @return CRM_Core_Resources
666 public function flushStrings() {
667 $this->strings
->flush();
672 * @return CRM_Core_Resources_Strings
674 public function getStrings() {
675 return $this->strings
;
679 * Create dynamic script for localizing js widgets.
681 public static function outputLocalizationJS() {
682 CRM_Core_Page_AJAX
::setJsHeaders();
683 $config = CRM_Core_Config
::singleton();
685 'moneyFormat' => json_encode(CRM_Utils_Money
::format(1234.56)),
686 'contactSearch' => json_encode($config->includeEmailInName ?
ts('Start typing a name or email...') : ts('Start typing a name...')),
687 'otherSearch' => json_encode(ts('Enter search term...')),
688 'entityRef' => array(
689 'contactCreate' => CRM_Core_BAO_UFGroup
::getCreateLinks(),
690 'filters' => self
::getEntityRefFilters(),
692 'ajaxPopupsEnabled' => self
::singleton()->ajaxPopupsEnabled
,
693 'allowAlertAutodismissal' => (bool) Civi
::settings()->get('allow_alert_autodismissal'),
695 print CRM_Core_Smarty
::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars);
696 CRM_Utils_System
::civiExit();
700 * List of core resources we add to every CiviCRM page.
702 * Note: non-compressed versions of .min files will be used in debug mode
704 * @param string $region
707 public function coreResourceList($region) {
708 $config = CRM_Core_Config
::singleton();
710 // Scripts needed by everyone, everywhere
711 // FIXME: This is too long; list needs finer-grained segmentation
713 "bower_components/jquery/dist/jquery.min.js",
714 "bower_components/jquery-ui/jquery-ui.min.js",
715 "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css",
716 "bower_components/lodash-compat/lodash.min.js",
717 "packages/jquery/plugins/jquery.mousewheel.min.js",
718 "bower_components/select2/select2.min.js",
719 "bower_components/select2/select2.min.css",
720 "bower_components/font-awesome/css/font-awesome.min.css",
721 "packages/jquery/plugins/jquery.form.min.js",
722 "packages/jquery/plugins/jquery.timeentry.min.js",
723 "packages/jquery/plugins/jquery.blockUI.min.js",
724 "bower_components/datatables/media/js/jquery.dataTables.min.js",
725 "bower_components/datatables/media/css/jquery.dataTables.min.css",
726 "bower_components/jquery-validation/dist/jquery.validate.min.js",
727 "packages/jquery/plugins/jquery.ui.datepicker.validation.min.js",
730 "js/wysiwyg/crm.wysiwyg.js",
732 // add wysiwyg editor
733 $editor = Civi
::settings()->get('editor_id');
734 if ($editor == "CKEditor") {
735 CRM_Admin_Page_CKEditorConfig
::setConfigDefault();
738 'wysisygScriptLocation' => Civi
::paths()->getUrl("[civicrm.root]/js/wysiwyg/crm.ckeditor.js"),
739 'CKEditorCustomConfig' => CRM_Admin_Page_CKEditorConfig
::getConfigUrl(),
744 // These scripts are only needed by back-office users
745 if (CRM_Core_Permission
::check('access CiviCRM')) {
746 $items[] = "packages/jquery/plugins/jquery.tableHeader.js";
747 $items[] = "packages/jquery/plugins/jquery.menu.min.js";
748 $items[] = "css/civicrmNavigation.css";
749 $items[] = "packages/jquery/plugins/jquery.notify.min.js";
752 // JS for multilingual installations
753 if (!empty($config->languageLimit
) && count($config->languageLimit
) > 1 && CRM_Core_Permission
::check('translate CiviCRM')) {
754 $items[] = "js/crm.multilingual.js";
757 // Enable administrators to edit option lists in a dialog
758 if (CRM_Core_Permission
::check('administer CiviCRM') && $this->ajaxPopupsEnabled
) {
759 $items[] = "js/crm.optionEdit.js";
762 $tsLocale = CRM_Core_I18n
::getLocale();
763 // Add localized jQuery UI files
764 if ($tsLocale && $tsLocale != 'en_US') {
765 // Search for i18n file in order of specificity (try fr-CA, then fr)
766 list($lang) = explode('_', $tsLocale);
767 $path = "bower_components/jquery-ui/ui/i18n";
768 foreach (array(str_replace('_', '-', $tsLocale), $lang) as $language) {
769 $localizationFile = "$path/datepicker-{$language}.js";
770 if ($this->getPath('civicrm', $localizationFile)) {
771 $items[] = $localizationFile;
777 // Allow hooks to modify this list
778 CRM_Utils_Hook
::coreResourceList($items, $region);
785 * is this page request an ajax snippet?
787 public static function isAjaxMode() {
788 if (in_array(CRM_Utils_Array
::value('snippet', $_REQUEST), array(
789 CRM_Core_Smarty
::PRINT_SNIPPET
,
790 CRM_Core_Smarty
::PRINT_NOFORM
,
791 CRM_Core_Smarty
::PRINT_JSON
,
796 return strpos(CRM_Utils_System
::getUrlPath(), 'civicrm/ajax') === 0;
800 * Provide a list of available entityRef filters.
801 * @todo: move component filters into their respective components (e.g. CiviEvent)
805 public static function getEntityRefFilters() {
807 $config = CRM_Core_Config
::singleton();
809 if (in_array('CiviEvent', $config->enableComponents
)) {
810 $filters['event'] = array(
811 array('key' => 'event_type_id', 'value' => ts('Event Type')),
813 'key' => 'start_date',
814 'value' => ts('Start Date'),
816 array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
818 'key' => '{"BETWEEN":["now - 3 month","now"]}',
819 'value' => ts('Past 3 Months'),
822 'key' => '{"BETWEEN":["now - 6 month","now"]}',
823 'value' => ts('Past 6 Months'),
826 'key' => '{"BETWEEN":["now - 1 year","now"]}',
827 'value' => ts('Past Year'),
834 $filters['activity'] = array(
835 array('key' => 'activity_type_id', 'value' => ts('Activity Type')),
836 array('key' => 'status_id', 'value' => ts('Activity Status')),
839 $filters['contact'] = array(
840 array('key' => 'contact_type', 'value' => ts('Contact Type')),
841 array('key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'),
842 array('key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'),
843 array('key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'),
844 array('key' => 'country', 'value' => ts('Country'), 'entity' => 'address'),
845 array('key' => 'gender_id', 'value' => ts('Gender')),
846 array('key' => 'is_deceased', 'value' => ts('Deceased')),
847 array('key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'),
848 array('key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'),
849 array('key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'),
852 if (in_array('CiviCase', $config->enableComponents
)) {
853 $filters['case'] = array(
855 'key' => 'case_id.case_type_id',
856 'value' => ts('Case Type'),
860 'key' => 'case_id.status_id',
861 'value' => ts('Case Status'),
865 foreach ($filters['contact'] as $filter) {
866 $filter +
= array('entity' => 'contact');
867 $filter['key'] = 'contact_id.' . $filter['key'];
868 $filters['case'][] = $filter;
872 CRM_Utils_Hook
::entityRefFilters($filters);
878 * In debug mode, look for a non-minified version of this file
880 * @param string $fileName
881 * @param string $extName
883 private function resolveFileName(&$fileName, $extName) {
884 if (CRM_Core_Config
::singleton()->debug
&& strpos($fileName, '.min.') !== FALSE) {
885 $nonMiniFile = str_replace('.min.', '.', $fileName);
886 if ($this->getPath($extName, $nonMiniFile)) {
887 $fileName = $nonMiniFile;
896 public function addCacheCode($url) {
897 $hasQuery = strpos($url, '?') !== FALSE;
898 $operator = $hasQuery ?
'&' : '?';
900 return $url . $operator . 'r=' . $this->cacheCode
;