- +--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
-*/
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
* @param string|null $cacheCodeKey Random code to append to resource URLs; changing the code forces clients to reload resources
*/
public function __construct($extMapper, $cache, $cacheCodeKey = NULL) {
$this->extMapper = $extMapper;
* @param string|null $cacheCodeKey Random code to append to resource URLs; changing the code forces clients to reload resources
*/
public function __construct($extMapper, $cache, $cacheCodeKey = NULL) {
$this->extMapper = $extMapper;
$this->cacheCodeKey = $cacheCodeKey;
if ($cacheCodeKey !== NULL) {
$this->cacheCode = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $cacheCodeKey);
$this->cacheCodeKey = $cacheCodeKey;
if ($cacheCodeKey !== NULL) {
$this->cacheCode = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $cacheCodeKey);
- * @param $ext string, extension name; use 'civicrm' for core
- * @param $file string, file path -- relative to the extension base dir
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
- * @param $translate, whether to parse this file for strings enclosed in ts()
+ * @param string $ext
+ * extension name; use 'civicrm' for core.
+ * @param string $file
+ * file path -- relative to the extension base dir.
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
+ * @param bool|string $translate
+ * Whether to load translated strings for this file. Use one of:
+ * - FALSE: Do not load translated strings.
+ * - TRUE: Load translated strings. Use the $ext's default domain.
+ * - string: Load translated strings. Use a specific domain.
*
* @return CRM_Core_Resources
*/
public function addScriptFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION, $translate = TRUE) {
if ($translate) {
*
* @return CRM_Core_Resources
*/
public function addScriptFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION, $translate = TRUE) {
if ($translate) {
- * @param $url string
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
+ * @param string $url
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
* @return CRM_Core_Resources
*/
public function addScriptUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
* @return CRM_Core_Resources
*/
public function addScriptUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
- * @param $code string, JavaScript source code
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
+ * @param string $code
+ * JavaScript source code.
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
* @return CRM_Core_Resources
*/
public function addScript($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
* @return CRM_Core_Resources
*/
public function addScript($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
- * @param $ext string, extension name; use 'civicrm' for core
- * @param $file string, file path -- relative to the extension base dir
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
+ * @param string $ext
+ * extension name; use 'civicrm' for core.
+ * @param string $file
+ * file path -- relative to the extension base dir.
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
* @return CRM_Core_Resources
*/
public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
* @return CRM_Core_Resources
*/
public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
- * @param $url string
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
+ * @param string $url
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
* @return CRM_Core_Resources
*/
public function addStyleUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
* @return CRM_Core_Resources
*/
public function addStyleUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
- * @param $code string, CSS source code
- * @param $weight int, relative weight within a given region
- * @param $region string, location within the file; 'html-header', 'page-header', 'page-footer'
+ * @param string $code
+ * CSS source code.
+ * @param int $weight
+ * relative weight within a given region.
+ * @param string $region
+ * location within the file; 'html-header', 'page-header', 'page-footer'.
* @return CRM_Core_Resources
*/
public function addStyle($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
* @return CRM_Core_Resources
*/
public function addStyle($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) {
CRM_Core_Region::instance($region)->add(array(
+ /**
+ * Evaluate a glob pattern in the context of a particular extension.
+ *
+ * @param string $ext
+ * Extension name; use 'civicrm' for core.
+ * @param string|array $patterns
+ * Glob pattern; e.g. "*.html".
+ * @param null|int $flags
+ * See glob().
+ * @return array
+ * List of matching files, relative to the extension base dir.
+ * @see glob()
+ */
+ public function glob($ext, $patterns, $flags = NULL) {
+ $path = $this->getPath($ext);
+ $patterns = (array) $patterns;
+ $files = array();
+ foreach ($patterns as $pattern) {
+ if ($pattern{0} === '/') {
+ // Absolute path.
+ $files = array_merge($files, (array) glob($pattern, $flags));
+ }
+ else {
+ // Relative path.
+ $files = array_merge($files, (array) glob("$path/$pattern", $flags));
+ }
+ }
+ sort($files); // Deterministic order.
+ $files = array_unique($files);
+ return array_map(function ($file) use ($path) {
+ return CRM_Utils_File::relativize($file, "$path/");
+ }, $files);
+ }
+
foreach ($this->coreResourceList() as $file) {
if (substr($file, -2) == 'js') {
// Don't bother looking for ts() calls in packages, there aren't any
foreach ($this->coreResourceList() as $file) {
if (substr($file, -2) == 'js') {
// Don't bother looking for ts() calls in packages, there aren't any
- $settings = array('config' => array(
- 'ajaxPopupsEnabled' => $this->ajaxPopupsEnabled,
- 'isFrontend' => $config->userFrameworkFrontend,
- ));
+ $settings = array(
+ 'config' => array(
+ 'ajaxPopupsEnabled' => $this->ajaxPopupsEnabled,
+ 'isFrontend' => $config->userFrameworkFrontend,
+ ),
+ );
// Disable profile creation if user lacks permission
if (!CRM_Core_Permission::check('edit all contacts') && !CRM_Core_Permission::check('add contacts')) {
$settings['config']['entityRef']['contactCreate'] = FALSE;
// Disable profile creation if user lacks permission
if (!CRM_Core_Permission::check('edit all contacts') && !CRM_Core_Permission::check('add contacts')) {
$settings['config']['entityRef']['contactCreate'] = FALSE;
- * Translate strings in a javascript file
- *
- * @param $ext string, extension name
- * @param $file string, file path
- * @return void
- */
- private function translateScript($ext, $file) {
- // For each extension, maintain one cache record which
- // includes parsed (translatable) strings for all its JS files.
- $stringsByFile = $this->cache->get($ext); // array($file => array(...strings...))
- if (!$stringsByFile) {
- $stringsByFile = array();
- }
- if (!isset($stringsByFile[$file])) {
- $filePath = $this->getPath($ext, $file);
- if ($filePath && is_readable($filePath)) {
- $stringsByFile[$file] = CRM_Utils_JS::parseStrings(file_get_contents($filePath));
- } else {
- $stringsByFile[$file] = array();
- }
- $this->cache->set($ext, $stringsByFile);
- }
- $this->addString($stringsByFile[$file]);
+ * @return CRM_Core_Resources_Strings
+ */
+ public function getStrings() {
+ return $this->strings;
- "packages/jquery/jquery-1.11.1$min.js",
- "packages/jquery/jquery-ui/jquery-ui$min.js",
- "packages/jquery/jquery-ui/jquery-ui$min.css",
-
- "packages/backbone/lodash.compat$min.js",
-
+ "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/lodash-compat/lodash.min.js",
if ($config->lcMessages && $config->lcMessages != 'en_US') {
// Search for i18n file in order of specificity (try fr-CA, then fr)
list($lang) = explode('_', $config->lcMessages);
if ($config->lcMessages && $config->lcMessages != 'en_US') {
// Search for i18n file in order of specificity (try fr-CA, then fr)
list($lang) = explode('_', $config->lcMessages);
foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) {
$localizationFile = "$path/datepicker-{$language}.js";
if ($this->getPath('civicrm', $localizationFile)) {
foreach (array(str_replace('_', '-', $config->lcMessages), $lang) as $language) {
$localizationFile = "$path/datepicker-{$language}.js";
if ($this->getPath('civicrm', $localizationFile)) {
- return in_array(CRM_Utils_Array::value('snippet', $_REQUEST), array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON));
+ return in_array(CRM_Utils_Array::value('snippet', $_REQUEST), array(
+ CRM_Core_Smarty::PRINT_SNIPPET,
+ CRM_Core_Smarty::PRINT_NOFORM,
+ CRM_Core_Smarty::PRINT_JSON,
+ ));
- array('key' => 'start_date', 'value' => ts('Start Date'), 'options' => array(
- array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
- array('key' => '{"BETWEEN":["now - 3 month","now"]}', 'value' => ts('Past 3 Months')),
- array('key' => '{"BETWEEN":["now - 6 month","now"]}', 'value' => ts('Past 6 Months')),
- array('key' => '{"BETWEEN":["now - 1 year","now"]}', 'value' => ts('Past Year')),
- )),
+ array(
+ 'key' => 'start_date',
+ 'value' => ts('Start Date'),
+ 'options' => array(
+ array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
+ array('key' => '{"BETWEEN":["now - 3 month","now"]}', 'value' => ts('Past 3 Months')),
+ array('key' => '{"BETWEEN":["now - 6 month","now"]}', 'value' => ts('Past 6 Months')),
+ array('key' => '{"BETWEEN":["now - 1 year","now"]}', 'value' => ts('Past Year')),
+ ),
+ ),