Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
15 | * @copyright CiviCRM LLC | |
6a488035 TO |
16 | * |
17 | */ | |
18 | ||
19 | /** | |
20 | * Determine the URL of a resource file | |
21 | * | |
16b10e64 | 22 | * @param array $params |
502492c2 TO |
23 | * Identify the resource by either 'ext'+'file' or 'expr'. |
24 | * | |
16b10e64 CW |
25 | * Array with keys: |
26 | * - ext: string, extension name. see CRM_Core_Resources::getUrl | |
27 | * - file: string, relative file path. see CRM_Core_Resources::getUrl | |
502492c2 | 28 | * - expr: string, a dynamic path expression. See: \Civi\Core\Paths::getUrl() |
16b10e64 | 29 | * @param CRM_Core_Smarty $smarty |
77b97be7 EM |
30 | * |
31 | * @return string | |
6a488035 TO |
32 | */ |
33 | function smarty_function_crmResURL($params, &$smarty) { | |
502492c2 TO |
34 | if (!empty($params['expr'])) { |
35 | return Civi::paths()->getUrl($params['expr'], 'absolute'); | |
36 | } | |
37 | ||
6a488035 TO |
38 | $res = CRM_Core_Resources::singleton(); |
39 | if (!array_key_exists('file', $params)) { | |
40 | $params['file'] = NULL; | |
41 | } | |
83afe752 | 42 | return $res->getUrl($params['ext'], $params['file'], $params['addCacheCode'] ?? FALSE); |
6a488035 | 43 | } |