Commit | Line | Data |
---|---|---|
aa40d9a7 CW |
1 | <?php |
2 | ||
3 | // AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file | |
4 | ||
5 | /** | |
6 | * The ExtensionUtil class provides small stubs for accessing resources of this | |
7 | * extension. | |
8 | */ | |
9 | class CRM_CivicrmAdminUi_ExtensionUtil { | |
10 | const SHORT_NAME = 'civicrm_admin_ui'; | |
11 | const LONG_NAME = 'civicrm_admin_ui'; | |
12 | const CLASS_PREFIX = 'CRM_CivicrmAdminUi'; | |
13 | ||
14 | /** | |
15 | * Translate a string using the extension's domain. | |
16 | * | |
17 | * If the extension doesn't have a specific translation | |
18 | * for the string, fallback to the default translations. | |
19 | * | |
20 | * @param string $text | |
21 | * Canonical message text (generally en_US). | |
22 | * @param array $params | |
23 | * @return string | |
24 | * Translated text. | |
25 | * @see ts | |
26 | */ | |
27 | public static function ts($text, $params = []) { | |
28 | if (!array_key_exists('domain', $params)) { | |
29 | $params['domain'] = [self::LONG_NAME, NULL]; | |
30 | } | |
31 | return ts($text, $params); | |
32 | } | |
33 | ||
34 | /** | |
35 | * Get the URL of a resource file (in this extension). | |
36 | * | |
37 | * @param string|NULL $file | |
38 | * Ex: NULL. | |
39 | * Ex: 'css/foo.css'. | |
40 | * @return string | |
41 | * Ex: 'http://example.org/sites/default/ext/org.example.foo'. | |
42 | * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'. | |
43 | */ | |
44 | public static function url($file = NULL) { | |
45 | if ($file === NULL) { | |
46 | return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/'); | |
47 | } | |
48 | return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file); | |
49 | } | |
50 | ||
51 | /** | |
52 | * Get the path of a resource file (in this extension). | |
53 | * | |
54 | * @param string|NULL $file | |
55 | * Ex: NULL. | |
56 | * Ex: 'css/foo.css'. | |
57 | * @return string | |
58 | * Ex: '/var/www/example.org/sites/default/ext/org.example.foo'. | |
59 | * Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'. | |
60 | */ | |
61 | public static function path($file = NULL) { | |
62 | // return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file); | |
63 | return __DIR__ . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file)); | |
64 | } | |
65 | ||
66 | /** | |
67 | * Get the name of a class within this extension. | |
68 | * | |
69 | * @param string $suffix | |
70 | * Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'. | |
71 | * @return string | |
72 | * Ex: 'CRM_Foo_Page_HelloWorld'. | |
73 | */ | |
74 | public static function findClass($suffix) { | |
75 | return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix); | |
76 | } | |
77 | ||
78 | } | |
79 | ||
80 | use CRM_CivicrmAdminUi_ExtensionUtil as E; | |
81 | ||
82 | /** | |
83 | * (Delegated) Implements hook_civicrm_config(). | |
84 | * | |
85 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config | |
86 | */ | |
87 | function _civicrm_admin_ui_civix_civicrm_config(&$config = NULL) { | |
88 | static $configured = FALSE; | |
89 | if ($configured) { | |
90 | return; | |
91 | } | |
92 | $configured = TRUE; | |
93 | ||
94 | $template =& CRM_Core_Smarty::singleton(); | |
95 | ||
96 | $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; | |
97 | $extDir = $extRoot . 'templates'; | |
98 | ||
99 | if (is_array($template->template_dir)) { | |
100 | array_unshift($template->template_dir, $extDir); | |
101 | } | |
102 | else { | |
103 | $template->template_dir = [$extDir, $template->template_dir]; | |
104 | } | |
105 | ||
106 | $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); | |
107 | set_include_path($include_path); | |
108 | } | |
109 | ||
110 | /** | |
111 | * (Delegated) Implements hook_civicrm_entityTypes(). | |
112 | * | |
113 | * Find any *.entityType.php files, merge their content, and return. | |
114 | * | |
115 | * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes | |
116 | */ | |
117 | function _civicrm_admin_ui_civix_civicrm_entityTypes(&$entityTypes) { | |
118 | $entityTypes = array_merge($entityTypes, []); | |
119 | } |