CRM-14383 - Add CRM.$ and CRM._ noconflict objects
[civicrm-core.git] / CRM / Core / Resources.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26*/
27
28/**
29 * This class facilitates the loading of resources
30 * such as JavaScript files and CSS files.
31 *
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).
35 *
36 * TODO: This is currently a thin wrapper over CRM_Core_Region. We
37 * should incorporte services for aggregation, minimization, etc.
38 *
39 * @package CRM
40 * @copyright CiviCRM LLC (c) 2004-2013
41 * $Id$
42 *
43 */
44class CRM_Core_Resources {
45 const DEFAULT_WEIGHT = 0;
46 const DEFAULT_REGION = 'page-footer';
47
48 /**
49 * We don't have a container or dependency-injection, so use singleton instead
50 *
51 * @var object
52 * @static
53 */
54 private static $_singleton = NULL;
55
56 /**
57 * @var CRM_Extension_Mapper
58 */
59 private $extMapper = NULL;
60
61 /**
62 * @var CRM_Utils_Cache_Interface
63 */
64 private $cache = NULL;
65
66 /**
67 * @var array free-form data tree
68 */
69 protected $settings = array();
70 protected $addedSettings = FALSE;
71
72 /**
73 * @var array of callables
74 */
75 protected $settingsFactories = array();
76
77 /**
78 * @var array ($regionName => bool)
79 */
80 protected $addedCoreResources = array();
81
82 /**
83 * @var array ($regionName => bool)
84 */
85 protected $addedCoreStyles = array();
86
87 /**
88 * @var string a value to append to JS/CSS URLs to coerce cache resets
89 */
90 protected $cacheCode = NULL;
91
92 /**
93 * @var string the name of a setting which persistently stores the cacheCode
94 */
95 protected $cacheCodeKey = NULL;
96
53f2643c
CW
97 /**
98 * @var bool
99 */
100 public $ajaxPopupsEnabled;
101
6a488035
TO
102 /**
103 * Get or set the single instance of CRM_Core_Resources
104 *
105 * @param $instance CRM_Core_Resources, new copy of the manager
106 * @return CRM_Core_Resources
107 */
108 static public function singleton(CRM_Core_Resources $instance = NULL) {
109 if ($instance !== NULL) {
110 self::$_singleton = $instance;
111 }
112 if (self::$_singleton === NULL) {
113 $sys = CRM_Extension_System::singleton();
114 $cache = new CRM_Utils_Cache_SqlGroup(array(
115 'group' => 'js-strings',
116 'prefetch' => FALSE,
117 ));
118 self::$_singleton = new CRM_Core_Resources(
119 $sys->getMapper(),
120 $cache,
eb897088 121 CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode'
6a488035
TO
122 );
123 }
124 return self::$_singleton;
125 }
126
127 /**
128 * Construct a resource manager
129 *
130 * @param CRM_Extension_Mapper $extMapper Map extension names to their base path or URLs.
131 */
132 public function __construct($extMapper, $cache, $cacheCodeKey = NULL) {
133 $this->extMapper = $extMapper;
134 $this->cache = $cache;
135 $this->cacheCodeKey = $cacheCodeKey;
136 if ($cacheCodeKey !== NULL) {
137 $this->cacheCode = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $cacheCodeKey);
138 }
150f50c1 139 if (!$this->cacheCode) {
6a488035
TO
140 $this->resetCacheCode();
141 }
53f2643c
CW
142 $this->ajaxPopupsEnabled = (bool) CRM_Core_BAO_Setting::getItem(
143 CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE
144 );
6a488035
TO
145 }
146
147 /**
148 * Add a JavaScript file to the current page using <SCRIPT SRC>.
149 *
150 * @param $ext string, extension name; use 'civicrm' for core
151 * @param $file string, file path -- relative to the extension base dir
152 * @param $weight int, relative weight within a given region
153 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
154 * @param $translate, whether to parse this file for strings enclosed in ts()
155 *
156 * @return CRM_Core_Resources
157 */
158 public function addScriptFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION, $translate = TRUE) {
159 if ($translate) {
160 $this->translateScript($ext, $file);
161 }
162 return $this->addScriptUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
163 }
164
165 /**
166 * Add a JavaScript file to the current page using <SCRIPT SRC>.
167 *
168 * @param $url string
169 * @param $weight int, relative weight within a given region
170 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
171 * @return CRM_Core_Resources
172 */
173 public function addScriptUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
174 CRM_Core_Region::instance($region)->add(array(
175 'name' => $url,
176 'type' => 'scriptUrl',
177 'scriptUrl' => $url,
178 'weight' => $weight,
179 'region' => $region,
180 ));
181 return $this;
182 }
183
184 /**
185 * Add a JavaScript file to the current page using <SCRIPT SRC>.
186 *
187 * @param $code string, JavaScript source code
188 * @param $weight int, relative weight within a given region
189 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
190 * @return CRM_Core_Resources
191 */
192 public function addScript($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
193 CRM_Core_Region::instance($region)->add(array(
194 // 'name' => automatic
195 'type' => 'script',
196 'script' => $code,
197 'weight' => $weight,
198 'region' => $region,
199 ));
200 return $this;
201 }
202
203 /**
204 * Add JavaScript variables to the global CRM object.
205 *
132fc68e
CW
206 * Example:
207 * From the server:
208 * CRM_Core_Resources::singleton()->addSetting(array('myNamespace' => array('foo' => 'bar')));
209 * From javascript:
210 * CRM.myNamespace.foo // "bar"
211 *
01478033 212 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference
132fc68e 213 *
6a488035
TO
214 * @param $settings array
215 * @return CRM_Core_Resources
216 */
217 public function addSetting($settings) {
218 $this->settings = $this->mergeSettings($this->settings, $settings);
219 if (!$this->addedSettings) {
220 $resources = $this;
d759bd10 221 CRM_Core_Region::instance('html-header')->add(array(
6a488035
TO
222 'callback' => function(&$snippet, &$html) use ($resources) {
223 $html .= "\n" . $resources->renderSetting();
8cb324cc
CW
224 },
225 'weight' => -100000,
6a488035
TO
226 ));
227 $this->addedSettings = TRUE;
228 }
229 return $this;
230 }
231
232 /**
69847402 233 * Add JavaScript variables to the global CRM object via a callback function.
6a488035
TO
234 *
235 * @param $callable function
236 * @return CRM_Core_Resources
237 */
238 public function addSettingsFactory($callable) {
d937dbcd
CW
239 // Make sure our callback has been registered
240 $this->addSetting(array());
6a488035
TO
241 $this->settingsFactories[] = $callable;
242 return $this;
243 }
244
69847402
CW
245 /**
246 * Helper fn for addSettingsFactory
247 */
6a488035
TO
248 public function getSettings() {
249 $result = $this->settings;
250 foreach ($this->settingsFactories as $callable) {
251 $result = $this->mergeSettings($result, $callable());
252 }
253 return $result;
254 }
255
256 /**
257 * @param array $settings
258 * @param array $additions
259 * @return array combination of $settings and $additions
260 */
261 protected function mergeSettings($settings, $additions) {
262 foreach ($additions as $k => $v) {
263 if (isset($settings[$k]) && is_array($settings[$k]) && is_array($v)) {
264 $v += $settings[$k];
265 }
266 $settings[$k] = $v;
267 }
268 return $settings;
269 }
270
271 /**
272 * Helper fn for addSetting
273 * Render JavaScript variables for the global CRM object.
274 *
6a488035
TO
275 * @return string
276 */
277 public function renderSetting() {
8cb324cc 278 $js = 'var CRM = ' . json_encode($this->getSettings()) . ';';
d759bd10 279 return sprintf("<script type=\"text/javascript\">\n%s\n</script>\n", $js);
6a488035
TO
280 }
281
282 /**
283 * Add translated string to the js CRM object.
284 * It can then be retrived from the client-side ts() function
285 * Variable substitutions can happen from client-side
8ef12e64 286 *
6a488035
TO
287 * Note: this function rarely needs to be called directly and is mostly for internal use.
288 * @see CRM_Core_Resources::addScriptFile which automatically adds translated strings from js files
289 *
290 * Simple example:
291 * // From php:
292 * CRM_Core_Resources::singleton()->addString('Hello');
293 * // The string is now available to javascript code i.e.
294 * ts('Hello');
295 *
296 * Example with client-side substitutions:
297 * // From php:
298 * CRM_Core_Resources::singleton()->addString('Your %1 has been %2');
299 * // ts() in javascript works the same as in php, for example:
300 * ts('Your %1 has been %2', {1: objectName, 2: actionTaken});
301 *
302 * NOTE: This function does not work with server-side substitutions
303 * (as this might result in collisions and unwanted variable injections)
304 * Instead, use code like:
305 * CRM_Core_Resources::singleton()->addSetting(array('myNamespace' => array('myString' => ts('Your %1 has been %2', array(subs)))));
306 * And from javascript access it at CRM.myNamespace.myString
307 *
308 * @param $text string|array
309 * @return CRM_Core_Resources
310 */
311 public function addString($text) {
312 foreach ((array) $text as $str) {
313 $translated = ts($str);
314 // We only need to push this string to client if the translation
315 // is actually different from the original
316 if ($translated != $str) {
317 $this->addSetting(array('strings' => array($str => $translated)));
318 }
319 }
320 return $this;
321 }
322
323 /**
324 * Add a CSS file to the current page using <LINK HREF>.
325 *
326 * @param $ext string, extension name; use 'civicrm' for core
327 * @param $file string, file path -- relative to the extension base dir
328 * @param $weight int, relative weight within a given region
329 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
330 * @return CRM_Core_Resources
331 */
332 public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
333 return $this->addStyleUrl($this->getUrl($ext, $file, TRUE), $weight, $region);
334 }
335
336 /**
337 * Add a CSS file to the current page using <LINK HREF>.
338 *
339 * @param $url string
340 * @param $weight int, relative weight within a given region
341 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
342 * @return CRM_Core_Resources
343 */
344 public function addStyleUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
345 CRM_Core_Region::instance($region)->add(array(
346 'name' => $url,
347 'type' => 'styleUrl',
348 'styleUrl' => $url,
349 'weight' => $weight,
350 'region' => $region,
351 ));
352 return $this;
353 }
354
355 /**
356 * Add a CSS content to the current page using <STYLE>.
357 *
358 * @param $code string, CSS source code
359 * @param $weight int, relative weight within a given region
360 * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
361 * @return CRM_Core_Resources
362 */
363 public function addStyle($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
364 CRM_Core_Region::instance($region)->add(array(
365 // 'name' => automatic
366 'type' => 'style',
367 'style' => $code,
368 'weight' => $weight,
369 'region' => $region,
370 ));
371 return $this;
372 }
373
374 /**
375 * Determine file path of a resource provided by an extension
376 *
377 * @param $ext string, extension name; use 'civicrm' for core
378 * @param $file string, file path -- relative to the extension base dir
379 *
380 * @return (string|bool), full file path or FALSE if not found
381 */
382 public function getPath($ext, $file) {
383 // TODO consider caching results
384 $path = $this->extMapper->keyToBasePath($ext) . '/' . $file;
385 if (is_file($path)) {
386 return $path;
387 }
388 return FALSE;
389 }
390
391 /**
392 * Determine public URL of a resource provided by an extension
393 *
394 * @param $ext string, extension name; use 'civicrm' for core
395 * @param $file string, file path -- relative to the extension base dir
396 * @return string, URL
397 */
398 public function getUrl($ext, $file = NULL, $addCacheCode = FALSE) {
399 if ($file === NULL) {
400 $file = '';
401 }
402 if ($addCacheCode) {
403 $file .= '?r=' . $this->getCacheCode();
404 }
405 // TODO consider caching results
406 return $this->extMapper->keyToUrl($ext) . '/' . $file;
407 }
408
409 public function getCacheCode() {
410 return $this->cacheCode;
411 }
412
413 public function setCacheCode($value) {
414 $this->cacheCode = $value;
415 if ($this->cacheCodeKey) {
416 CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $this->cacheCodeKey);
417 }
418 }
419
420 public function resetCacheCode() {
421 $this->setCacheCode(CRM_Utils_String::createRandom(5, CRM_Utils_String::ALPHANUMERIC));
422 }
423
424 /**
425 * This adds CiviCRM's standard css and js to the specified region of the document.
426 * It will only run once.
427 *
428 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
429 * (like addCoreResources/addCoreStyles).
430 *
431 * @return CRM_Core_Resources
432 * @access public
433 */
434 public function addCoreResources($region = 'html-header') {
435 if (!isset($this->addedCoreResources[$region])) {
436 $this->addedCoreResources[$region] = TRUE;
437 $config = CRM_Core_Config::singleton();
438
a43b1583 439 // Add resources from coreResourceList
6a488035 440 $jsWeight = -9999;
5409628b 441 foreach ($this->coreResourceList() as $file) {
a43b1583 442 if (substr($file, -2) == 'js') {
74227f77
CW
443 // Don't bother looking for ts() calls in packages, there aren't any
444 $translate = (substr($file, 0, 9) != 'packages/');
445 $this->addScriptFile('civicrm', $file, $jsWeight++, $region, $translate);
6a488035 446 }
a43b1583 447 else {
6a488035
TO
448 $this->addStyleFile('civicrm', $file, -100, $region);
449 }
450 }
451
5ec182d9 452 // Initialize CRM.url and CRM.formatMoney
8053ab8a 453 $url = CRM_Utils_System::url('civicrm/example', 'placeholder', FALSE, NULL, FALSE);
5ec182d9 454 $js = "CRM.url('init', '$url');\n";
f0c40b90 455 $js .= "CRM.formatMoney('init', " . json_encode(CRM_Utils_Money::format(1234.56)) . ");";
c66581f5
CW
456
457 $this->addLocalization($js);
8053ab8a
CW
458 $this->addScript($js, $jsWeight++, $region);
459
d759bd10
CW
460 // Add global settings
461 $settings = array(
4a7fe6f4
CW
462 'userFramework' => $config->userFramework,
463 'resourceBase' => $config->resourceBase,
1ec934ce 464 'lcMessages' => $config->lcMessages,
53f2643c 465 'ajaxPopupsEnabled' => $this->ajaxPopupsEnabled,
d759bd10
CW
466 );
467 $this->addSetting(array('config' => $settings));
468
6a488035 469 // Give control of jQuery back to the CMS - this loads last
c2777586 470 $this->addScriptFile('civicrm', 'js/noconflict.js', 9999, $region, FALSE);
6a488035
TO
471
472 $this->addCoreStyles($region);
473 }
474 return $this;
475 }
476
477 /**
478 * This will add CiviCRM's standard CSS
479 *
480 * TODO: Separate the functional code (like addStyle/addScript) from the policy code
481 * (like addCoreResources/addCoreStyles).
482 *
483 * @param string $region
484 * @return CRM_Core_Resources
485 */
486 public function addCoreStyles($region = 'html-header') {
487 if (!isset($this->addedCoreStyles[$region])) {
488 $this->addedCoreStyles[$region] = TRUE;
489
490 // Load custom or core css
491 $config = CRM_Core_Config::singleton();
492 if (!empty($config->customCSSURL)) {
57018a3e 493 $this->addStyleUrl($config->customCSSURL, 99, $region);
6a488035 494 }
14f20d22 495 if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'disable_core_css')) {
6a488035 496 $this->addStyleFile('civicrm', 'css/civicrm.css', -99, $region);
6a488035
TO
497 }
498 }
499 return $this;
500 }
501
627668e8
CW
502 /**
503 * Flushes cached translated strings
504 */
505 public function flushStrings() {
506 $this->cache->flush();
507 }
508
6a488035
TO
509 /**
510 * Translate strings in a javascript file
511 *
512 * @param $ext string, extension name
513 * @param $file string, file path
514 * @return void
515 */
516 private function translateScript($ext, $file) {
517 // For each extension, maintain one cache record which
518 // includes parsed (translatable) strings for all its JS files.
519 $stringsByFile = $this->cache->get($ext); // array($file => array(...strings...))
520 if (!$stringsByFile) {
521 $stringsByFile = array();
522 }
523 if (!isset($stringsByFile[$file])) {
524 $filePath = $this->getPath($ext, $file);
525 if ($filePath && is_readable($filePath)) {
526 $stringsByFile[$file] = CRM_Utils_JS::parseStrings(file_get_contents($filePath));
527 } else {
528 $stringsByFile[$file] = array();
529 }
530 $this->cache->set($ext, $stringsByFile);
531 }
532 $this->addString($stringsByFile[$file]);
533 }
534
c66581f5
CW
535 /**
536 * Add inline scripts needed to localize js widgets
537 * @param string $js
538 */
539 function addLocalization(&$js) {
a88cf11a
CW
540 $config = CRM_Core_Config::singleton();
541
542 // Localize select2 strings
543 $contactSearch = json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...'));
544 $otherSearch = json_encode(ts('Enter search term...'));
545 $js .= "
546 $.fn.select2.defaults.formatNoMatches = " . json_encode(ts("None found.")) . ";
547 $.fn.select2.defaults.formatLoadMore = " . json_encode(ts("Loading...")) . ";
548 $.fn.select2.defaults.formatSearching = " . json_encode(ts("Searching...")) . ";
549 $.fn.select2.defaults.formatInputTooShort = function(){return cj(this).data('api-entity') == 'contact' ? $contactSearch : $otherSearch};
550 ";
a4799f04
CW
551
552 // Contact create profiles with localized names
553 if (CRM_Core_Permission::check('edit all contacts') || CRM_Core_Permission::check('add contacts')) {
554 $this->addSetting(array('profile' => array('contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks())));
555 }
c66581f5
CW
556 }
557
6a488035 558 /**
a43b1583 559 * List of core resources we add to every CiviCRM page
6a488035 560 *
a43b1583 561 * @return array
6a488035 562 */
dbe0bbc6
CW
563 public function coreResourceList() {
564 $config = CRM_Core_Config::singleton();
565 // Use minified files for production, uncompressed in debug mode
566 $min = $config->debug ? '' : '.min';
a43b1583 567
4968e732
CW
568 // Scripts needed by everyone, everywhere
569 // FIXME: This is too long; list needs finer-grained segmentation
a0c8b50e 570 $items = array(
f2b7caed 571 "packages/jquery/jquery-1.11.0$min.js",
4968e732 572 "packages/jquery/jquery-migrate-1.2.1.js", // TODO: Remove before 4.5 release
f2b7caed
CW
573 "packages/jquery/jquery-ui/js/jquery-ui-1.10.4.custom$min.js",
574 "packages/jquery/jquery-ui/css/theme/jquery-ui-1.10.4.custom$min.css",
79ae07d9 575
a88cf11a 576 "packages/backbone/lodash.compat$min.js",
430b9048 577
c04d6c92 578 "packages/jquery/plugins/jquery.mousewheel$min.js",
b77d5b35 579
79ae07d9 580 "packages/jquery/plugins/select2/select2.js", // No mini until release of select2 3.4.6
f7b92fcd
CW
581 "packages/jquery/plugins/select2/select2.css",
582
4968e732 583 // TODO: Remove before 4.5 release
a0c8b50e
CW
584 "packages/jquery/plugins/jquery.autocomplete.js",
585 "packages/jquery/css/jquery.autocomplete.css",
a43b1583 586
a0c8b50e 587 "packages/jquery/plugins/jquery.tableHeader.js",
a43b1583 588
a0c8b50e 589 "packages/jquery/plugins/jquery.textarearesizer.js",
a43b1583 590
a0c8b50e 591 "packages/jquery/plugins/jquery.form$min.js",
a43b1583 592
a0c8b50e 593 "packages/jquery/plugins/jquery.timeentry$min.js",
a43b1583 594
a0c8b50e 595 "packages/jquery/plugins/DataTables/media/js/jquery.dataTables$min.js",
a43b1583 596
8ec6dd48 597 "packages/jquery/plugins/jquery.FormNavigate$min.js",
a43b1583 598
a0c8b50e
CW
599 "packages/jquery/plugins/jquery.validate$min.js",
600 "packages/jquery/plugins/jquery.ui.datepicker.validation.pack.js",
a43b1583 601
a0c8b50e 602 "js/Common.js",
53f2643c 603 "js/crm.ajax.js",
a43b1583 604 );
dbe0bbc6 605
4968e732
CW
606 // These scripts are only needed by back-office users
607 if (CRM_Core_Permission::check('access CiviCRM')) {
608 $items[] = "packages/jquery/plugins/jquery.menu$min.js";
609 $items[] = "packages/jquery/css/menu.css";
610 $items[] = "packages/jquery/plugins/jquery.jeditable$min.js";
611 $items[] = "packages/jquery/plugins/jquery.blockUI$min.js";
612 $items[] = "packages/jquery/plugins/jquery.notify$min.js";
613 $items[] = "js/jquery/jquery.crmeditable.js";
614
615 // TODO: tokeninput is deprecated in favor of select2 and will be removed soon
616 $items[] = "packages/jquery/plugins/jquery.tokeninput$min.js";
617 $items[] = "packages/jquery/css/token-input-facebook.css";
618 }
619
53f2643c
CW
620 // Enable administrators to edit option lists in a dialog
621 if (CRM_Core_Permission::check('administer CiviCRM') && $this->ajaxPopupsEnabled) {
622 $items[] = "js/crm.optionEdit.js";
623 }
624
dbe0bbc6
CW
625 // Add localized jQuery UI files
626 if ($config->lcMessages && $config->lcMessages != 'en_US') {
627 // Search for i18n file in order of specificity (try fr-CA, then fr)
628 list($lang) = explode('_', $config->lcMessages);
629 $path = "packages/jquery/jquery-ui/development-bundle/ui/" . ($min ? 'minified/' : '') . "i18n";
630 foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) {
631 $localizationFile = "$path/jquery.ui.datepicker-{$language}{$min}.js";
632 if ($this->getPath('civicrm', $localizationFile)) {
633 $items[] = $localizationFile;
634 break;
635 }
636 }
637 }
6a488035
TO
638 return $items;
639 }
640}