3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
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 self
::$_singleton = Civi
::service('resources');
120 return self
::$_singleton;
124 * Construct a resource manager.
126 * @param CRM_Extension_Mapper $extMapper
127 * Map extension names to their base path or URLs.
128 * @param CRM_Utils_Cache_Interface $cache
129 * JS-localization cache.
130 * @param string|null $cacheCodeKey Random code to append to resource URLs; changing the code forces clients to reload resources
132 public function __construct($extMapper, $cache, $cacheCodeKey = NULL) {
133 $this->extMapper
= $extMapper;
134 $this->strings
= new CRM_Core_Resources_Strings($cache);
135 $this->cacheCodeKey
= $cacheCodeKey;
136 if ($cacheCodeKey !== NULL) {
137 $this->cacheCode
= Civi
::settings()->get($cacheCodeKey);
139 if (!$this->cacheCode
) {
140 $this->resetCacheCode();
142 $this->ajaxPopupsEnabled
= (bool) Civi
::settings()->get('ajaxPopupsEnabled');
143 $this->paths
= Civi
::paths();
147 * Export permission data to the client to enable smarter GUIs.
149 * Note: Application security stems from the server's enforcement
150 * of the security logic (e.g. in the API permissions). There's no way
151 * the client can use this info to make the app more secure; however,
152 * it can produce a better-tuned (non-broken) UI.
154 * @param array $permNames
155 * List of permission names to check/export.
156 * @return CRM_Core_Resources
158 public function addPermissions($permNames) {
159 $permNames = (array) $permNames;
161 foreach ($permNames as $permName) {
162 $perms[$permName] = CRM_Core_Permission
::check($permName);
164 return $this->addSetting(array(
165 'permissions' => $perms,
170 * Add a JavaScript file to the current page using <SCRIPT SRC>.
173 * extension name; use 'civicrm' for core.
174 * @param string $file
175 * file path -- relative to the extension base dir.
177 * relative weight within a given region.
178 * @param string $region
179 * location within the file; 'html-header', 'page-header', 'page-footer'.
180 * @param bool|string $translate
181 * Whether to load translated strings for this file. Use one of:
182 * - FALSE: Do not load translated strings.
183 * - TRUE: Load translated strings. Use the $ext's default domain.
184 * - string: Load translated strings. Use a specific domain.
186 * @return CRM_Core_Resources
188 public function addScriptFile($ext, $file, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
, $translate = TRUE) {
190 $domain = ($translate === TRUE) ?
$ext : $translate;
191 $this->addString($this->strings
->get($domain, $this->getPath($ext, $file), 'text/javascript'), $domain);
193 $this->resolveFileName($file, $ext);
194 return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
198 * Add a JavaScript file to the current page using <SCRIPT SRC>.
202 * relative weight within a given region.
203 * @param string $region
204 * location within the file; 'html-header', 'page-header', 'page-footer'.
205 * @return CRM_Core_Resources
207 public function addScriptUrl($url, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
208 CRM_Core_Region
::instance($region)->add(array(
210 'type' => 'scriptUrl',
219 * Add a JavaScript file to the current page using <SCRIPT SRC>.
221 * @param string $code
222 * JavaScript source code.
224 * relative weight within a given region.
225 * @param string $region
226 * location within the file; 'html-header', 'page-header', 'page-footer'.
227 * @return CRM_Core_Resources
229 public function addScript($code, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
230 CRM_Core_Region
::instance($region)->add(array(
231 // 'name' => automatic
241 * Add JavaScript variables to CRM.vars
245 * CRM_Core_Resources::singleton()->addVars('myNamespace', array('foo' => 'bar'));
246 * Access var from javascript:
247 * CRM.vars.myNamespace.foo // "bar"
249 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference
251 * @param string $nameSpace
252 * Usually the name of your extension.
254 * @return CRM_Core_Resources
256 public function addVars($nameSpace, $vars) {
257 $existing = CRM_Utils_Array
::value($nameSpace, CRM_Utils_Array
::value('vars', $this->settings
), array());
258 $vars = $this->mergeSettings($existing, $vars);
259 $this->addSetting(array('vars' => array($nameSpace => $vars)));
264 * Add JavaScript variables to the root of the CRM object.
265 * This function is usually reserved for low-level system use.
266 * Extensions and components should generally use addVars instead.
268 * @param array $settings
269 * @return CRM_Core_Resources
271 public function addSetting($settings) {
272 $this->settings
= $this->mergeSettings($this->settings
, $settings);
273 if (!$this->addedSettings
) {
274 $region = self
::isAjaxMode() ?
'ajax-snippet' : 'html-header';
276 CRM_Core_Region
::instance($region)->add(array(
277 'callback' => function (&$snippet, &$html) use ($resources) {
278 $html .= "\n" . $resources->renderSetting();
282 $this->addedSettings
= TRUE;
288 * Add JavaScript variables to the global CRM object via a callback function.
290 * @param callable $callable
291 * @return CRM_Core_Resources
293 public function addSettingsFactory($callable) {
294 // Make sure our callback has been registered
295 $this->addSetting(array());
296 $this->settingsFactories
[] = $callable;
301 * Helper fn for addSettingsFactory.
303 public function getSettings() {
304 $result = $this->settings
;
305 foreach ($this->settingsFactories
as $callable) {
306 $result = $this->mergeSettings($result, $callable());
308 CRM_Utils_Hook
::alterResourceSettings($result);
313 * @param array $settings
314 * @param array $additions
316 * combination of $settings and $additions
318 protected function mergeSettings($settings, $additions) {
319 foreach ($additions as $k => $v) {
320 if (isset($settings[$k]) && is_array($settings[$k]) && is_array($v)) {
329 * Helper fn for addSetting.
330 * Render JavaScript variables for the global CRM object.
334 public function renderSetting() {
335 // On a standard page request we construct the CRM object from scratch
336 if (!self
::isAjaxMode()) {
337 $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
339 // For an ajax request we append to it
341 $js = 'CRM.$.extend(true, CRM, ' . json_encode($this->getSettings()) . ');';
343 return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
347 * Add translated string to the js CRM object.
348 * It can then be retrived from the client-side ts() function
349 * Variable substitutions can happen from client-side
351 * Note: this function rarely needs to be called directly and is mostly for internal use.
352 * See CRM_Core_Resources::addScriptFile which automatically adds translated strings from js files
356 * CRM_Core_Resources::singleton()->addString('Hello');
357 * // The string is now available to javascript code i.e.
360 * Example with client-side substitutions:
362 * CRM_Core_Resources::singleton()->addString('Your %1 has been %2');
363 * // ts() in javascript works the same as in php, for example:
364 * ts('Your %1 has been %2', {1: objectName, 2: actionTaken});
366 * NOTE: This function does not work with server-side substitutions
367 * (as this might result in collisions and unwanted variable injections)
368 * Instead, use code like:
369 * CRM_Core_Resources::singleton()->addSetting(array('myNamespace' => array('myString' => ts('Your %1 has been %2', array(subs)))));
370 * And from javascript access it at CRM.myNamespace.myString
372 * @param string|array $text
373 * @param string|NULL $domain
374 * @return CRM_Core_Resources
376 public function addString($text, $domain = 'civicrm') {
377 foreach ((array) $text as $str) {
378 $translated = ts($str, array(
379 'domain' => ($domain == 'civicrm') ?
NULL : array($domain, NULL),
383 // We only need to push this string to client if the translation
384 // is actually different from the original
385 if ($translated != $str) {
386 $bucket = $domain == 'civicrm' ?
'strings' : 'strings::' . $domain;
387 $this->addSetting(array(
388 $bucket => array($str => $translated),
396 * Add a CSS file to the current page using <LINK HREF>.
399 * extension name; use 'civicrm' for core.
400 * @param string $file
401 * file path -- relative to the extension base dir.
403 * relative weight within a given region.
404 * @param string $region
405 * location within the file; 'html-header', 'page-header', 'page-footer'.
406 * @return CRM_Core_Resources
408 public function addStyleFile($ext, $file, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
409 $this->resolveFileName($file, $ext);
410 return $this->addStyleUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
414 * Add a CSS file to the current page using <LINK HREF>.
418 * relative weight within a given region.
419 * @param string $region
420 * location within the file; 'html-header', 'page-header', 'page-footer'.
421 * @return CRM_Core_Resources
423 public function addStyleUrl($url, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
424 CRM_Core_Region
::instance($region)->add(array(
426 'type' => 'styleUrl',
435 * Add a CSS content to the current page using <STYLE>.
437 * @param string $code
440 * relative weight within a given region.
441 * @param string $region
442 * location within the file; 'html-header', 'page-header', 'page-footer'.
443 * @return CRM_Core_Resources
445 public function addStyle($code, $weight = self
::DEFAULT_WEIGHT
, $region = self
::DEFAULT_REGION
) {
446 CRM_Core_Region
::instance($region)->add(array(
447 // 'name' => automatic
457 * Determine file path of a resource provided by an extension.
460 * extension name; use 'civicrm' for core.
461 * @param string|NULL $file
462 * file path -- relative to the extension base dir.
464 * @return bool|string
465 * full file path or FALSE if not found
467 public function getPath($ext, $file = NULL) {
468 // TODO consider caching results
469 $base = $this->paths
->hasVariable($ext)
470 ?
rtrim($this->paths
->getVariable($ext, 'path'), '/')
471 : $this->extMapper
->keyToBasePath($ext);
472 if ($file === NULL) {
475 $path = $base . '/' . $file;
476 if (is_file($path)) {
483 * Determine public URL of a resource provided by an extension.
486 * extension name; use 'civicrm' for core.
487 * @param string $file
488 * file path -- relative to the extension base dir.
489 * @param bool $addCacheCode
491 * @return string, URL
493 public function getUrl($ext, $file = NULL, $addCacheCode = FALSE) {
494 if ($file === NULL) {
498 $file = $this->addCacheCode($file);
500 // TODO consider caching results
501 $base = $this->paths
->hasVariable($ext)
502 ?
$this->paths
->getVariable($ext, 'url')
503 : ($this->extMapper
->keyToUrl($ext) . '/');
504 return $base . $file;
508 * Evaluate a glob pattern in the context of a particular extension.
511 * Extension name; use 'civicrm' for core.
512 * @param string|array $patterns
513 * Glob pattern; e.g. "*.html".
514 * @param null|int $flags
517 * List of matching files, relative to the extension base dir.
520 public function glob($ext, $patterns, $flags = NULL) {
521 $path = $this->getPath($ext);
522 $patterns = (array) $patterns;
524 foreach ($patterns as $pattern) {
525 if (preg_match(';^(assetBuilder|ext)://;', $pattern)) {
528 if (CRM_Utils_File
::isAbsolute($pattern)) {
530 $files = array_merge($files, (array) glob($pattern, $flags));
534 $files = array_merge($files, (array) glob("$path/$pattern", $flags));
537 sort($files); // Deterministic order.
538 $files = array_unique($files);
539 return array_map(function ($file) use ($path) {
540 return CRM_Utils_File
::relativize($file, "$path/");
547 public function getCacheCode() {
548 return $this->cacheCode
;
553 * @return CRM_Core_Resources
555 public function setCacheCode($value) {
556 $this->cacheCode
= $value;
557 if ($this->cacheCodeKey
) {
558 Civi
::settings()->set($this->cacheCodeKey
, $value);
564 * @return CRM_Core_Resources
566 public function resetCacheCode() {
567 $this->setCacheCode(CRM_Utils_String
::createRandom(5, CRM_Utils_String
::ALPHANUMERIC
));
568 // Also flush cms resource cache if needed
569 CRM_Core_Config
::singleton()->userSystem
->clearResourceCache();
574 * This adds CiviCRM's standard css and js to the specified region of the document.
575 * It will only run once.
577 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
578 * (like addCoreResources/addCoreStyles).
580 * @param string $region
581 * @return CRM_Core_Resources
583 public function addCoreResources($region = 'html-header') {
584 if (!isset($this->addedCoreResources
[$region]) && !self
::isAjaxMode()) {
585 $this->addedCoreResources
[$region] = TRUE;
586 $config = CRM_Core_Config
::singleton();
588 // Add resources from coreResourceList
590 foreach ($this->coreResourceList($region) as $item) {
591 if (is_array($item)) {
592 $this->addSetting($item);
594 elseif (substr($item, -2) == 'js') {
595 // Don't bother looking for ts() calls in packages, there aren't any
596 $translate = (substr($item, 0, 3) == 'js/');
597 $this->addScriptFile('civicrm', $item, $jsWeight++
, $region, $translate);
600 $this->addStyleFile('civicrm', $item, -100, $region);
604 $tsLocale = CRM_Core_I18n
::getLocale();
605 // Dynamic localization script
606 $this->addScriptUrl(CRM_Utils_System
::url('civicrm/ajax/l10n-js/' . $tsLocale, array('r' => $this->getCacheCode())), $jsWeight++
, $region);
608 // Add global settings
611 'isFrontend' => $config->userFrameworkFrontend
,
614 $contactID = CRM_Core_Session
::getLoggedInContactID();
616 $settings['config']['menuCacheCode'] = CRM_Core_BAO_Navigation
::getCacheKey($contactID);
618 // Disable profile creation if user lacks permission
619 if (!CRM_Core_Permission
::check('edit all contacts') && !CRM_Core_Permission
::check('add contacts')) {
620 $settings['config']['entityRef']['contactCreate'] = FALSE;
622 $this->addSetting($settings);
624 // Give control of jQuery and _ back to the CMS - this loads last
625 $this->addScriptFile('civicrm', 'js/noconflict.js', 9999, $region, FALSE);
627 $this->addCoreStyles($region);
633 * This will add CiviCRM's standard CSS
635 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
636 * (like addCoreResources/addCoreStyles).
638 * @param string $region
639 * @return CRM_Core_Resources
641 public function addCoreStyles($region = 'html-header') {
642 if (!isset($this->addedCoreStyles
[$region])) {
643 $this->addedCoreStyles
[$region] = TRUE;
645 // Load custom or core css
646 $config = CRM_Core_Config
::singleton();
647 if (!empty($config->customCSSURL
)) {
648 $customCSSURL = $this->addCacheCode($config->customCSSURL
);
649 $this->addStyleUrl($customCSSURL, 99, $region);
651 if (!Civi
::settings()->get('disable_core_css')) {
652 $this->addStyleFile('civicrm', 'css/civicrm.css', -99, $region);
654 // crm-i.css added ahead of other styles so it can be overridden by FA.
655 $this->addStyleFile('civicrm', 'css/crm-i.css', -101, $region);
661 * Flushes cached translated strings.
662 * @return CRM_Core_Resources
664 public function flushStrings() {
665 $this->strings
->flush();
670 * @return CRM_Core_Resources_Strings
672 public function getStrings() {
673 return $this->strings
;
677 * Create dynamic script for localizing js widgets.
679 public static function outputLocalizationJS() {
680 CRM_Core_Page_AJAX
::setJsHeaders();
681 $config = CRM_Core_Config
::singleton();
683 'moneyFormat' => json_encode(CRM_Utils_Money
::format(1234.56)),
684 'contactSearch' => json_encode($config->includeEmailInName ?
ts('Start typing a name or email...') : ts('Start typing a name...')),
685 'otherSearch' => json_encode(ts('Enter search term...')),
686 'entityRef' => array(
687 'contactCreate' => CRM_Core_BAO_UFGroup
::getCreateLinks(),
688 'filters' => self
::getEntityRefFilters(),
690 'ajaxPopupsEnabled' => self
::singleton()->ajaxPopupsEnabled
,
691 'allowAlertAutodismissal' => (bool) Civi
::settings()->get('allow_alert_autodismissal'),
692 'resourceCacheCode' => self
::singleton()->getCacheCode(),
694 print CRM_Core_Smarty
::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars);
695 CRM_Utils_System
::civiExit();
699 * List of core resources we add to every CiviCRM page.
701 * Note: non-compressed versions of .min files will be used in debug mode
703 * @param string $region
706 public function coreResourceList($region) {
707 $config = CRM_Core_Config
::singleton();
709 // Scripts needed by everyone, everywhere
710 // FIXME: This is too long; list needs finer-grained segmentation
712 "bower_components/jquery/dist/jquery.min.js",
713 "bower_components/jquery-ui/jquery-ui.min.js",
714 "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css",
715 "bower_components/lodash-compat/lodash.min.js",
716 "packages/jquery/plugins/jquery.mousewheel.min.js",
717 "bower_components/select2/select2.min.js",
718 "bower_components/select2/select2.min.css",
719 "bower_components/font-awesome/css/font-awesome.min.css",
720 "packages/jquery/plugins/jquery.form.min.js",
721 "packages/jquery/plugins/jquery.timeentry.min.js",
722 "packages/jquery/plugins/jquery.blockUI.min.js",
723 "bower_components/datatables/media/js/jquery.dataTables.min.js",
724 "bower_components/datatables/media/css/jquery.dataTables.min.css",
725 "bower_components/jquery-validation/dist/jquery.validate.min.js",
726 "packages/jquery/plugins/jquery.ui.datepicker.validation.min.js",
728 "js/crm.datepicker.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 $url = CRM_Utils_System
::getUrlPath();
797 return (strpos($url, 'civicrm/ajax') === 0) ||
(strpos($url, 'civicrm/angular') === 0);
801 * Provide a list of available entityRef filters.
802 * @todo: move component filters into their respective components (e.g. CiviEvent)
806 public static function getEntityRefFilters() {
808 $config = CRM_Core_Config
::singleton();
810 if (in_array('CiviEvent', $config->enableComponents
)) {
811 $filters['event'] = array(
812 array('key' => 'event_type_id', 'value' => ts('Event Type')),
814 'key' => 'start_date',
815 'value' => ts('Start Date'),
817 array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
819 'key' => '{"BETWEEN":["now - 3 month","now"]}',
820 'value' => ts('Past 3 Months'),
823 'key' => '{"BETWEEN":["now - 6 month","now"]}',
824 'value' => ts('Past 6 Months'),
827 'key' => '{"BETWEEN":["now - 1 year","now"]}',
828 'value' => ts('Past Year'),
835 $filters['activity'] = array(
836 array('key' => 'activity_type_id', 'value' => ts('Activity Type')),
837 array('key' => 'status_id', 'value' => ts('Activity Status')),
840 $filters['contact'] = array(
841 array('key' => 'contact_type', 'value' => ts('Contact Type')),
842 array('key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'),
843 array('key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'),
844 array('key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'),
845 array('key' => 'country', 'value' => ts('Country'), 'entity' => 'address'),
846 array('key' => 'gender_id', 'value' => ts('Gender')),
847 array('key' => 'is_deceased', 'value' => ts('Deceased')),
848 array('key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'),
849 array('key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'),
850 array('key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'),
853 if (in_array('CiviCase', $config->enableComponents
)) {
854 $filters['case'] = array(
856 'key' => 'case_id.case_type_id',
857 'value' => ts('Case Type'),
861 'key' => 'case_id.status_id',
862 'value' => ts('Case Status'),
866 foreach ($filters['contact'] as $filter) {
867 $filter +
= array('entity' => 'contact');
868 $filter['key'] = 'contact_id.' . $filter['key'];
869 $filters['case'][] = $filter;
873 CRM_Utils_Hook
::entityRefFilters($filters);
879 * In debug mode, look for a non-minified version of this file
881 * @param string $fileName
882 * @param string $extName
884 private function resolveFileName(&$fileName, $extName) {
885 if (CRM_Core_Config
::singleton()->debug
&& strpos($fileName, '.min.') !== FALSE) {
886 $nonMiniFile = str_replace('.min.', '.', $fileName);
887 if ($this->getPath($extName, $nonMiniFile)) {
888 $fileName = $nonMiniFile;
897 public function addCacheCode($url) {
898 $hasQuery = strpos($url, '?') !== FALSE;
899 $operator = $hasQuery ?
'&' : '?';
901 return $url . $operator . 'r=' . $this->cacheCode
;