[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Extension; 11 12 use Joomla\CMS\Factory; 13 use Joomla\Database\ParameterType; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('JPATH_PLATFORM') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Extension Helper class. 21 * 22 * @since 3.7.4 23 * 24 * @deprecated 4.0 Replace class with a non static methods for better testing 25 */ 26 class ExtensionHelper 27 { 28 /** 29 * The loaded extensions. 30 * 31 * @var array 32 * @since 4.0.0 33 */ 34 public static $extensions = [ModuleInterface::class => [], ComponentInterface::class => [], PluginInterface::class => []]; 35 36 /** 37 * The loaded extensions. 38 * 39 * @var array 40 * @since 4.0.0 41 */ 42 private static $loadedExtensions = []; 43 44 /** 45 * Array of core extensions 46 * Each element is an array with elements "type", "element", "folder" and 47 * "client_id". 48 * 49 * @var array 50 * @since 3.7.4 51 */ 52 protected static $coreExtensions = array( 53 // Format: `type`, `element`, `folder`, `client_id` 54 55 // Core component extensions 56 array('component', 'com_actionlogs', '', 1), 57 array('component', 'com_admin', '', 1), 58 array('component', 'com_ajax', '', 1), 59 array('component', 'com_associations', '', 1), 60 array('component', 'com_banners', '', 1), 61 array('component', 'com_cache', '', 1), 62 array('component', 'com_categories', '', 1), 63 array('component', 'com_checkin', '', 1), 64 array('component', 'com_config', '', 1), 65 array('component', 'com_contact', '', 1), 66 array('component', 'com_content', '', 1), 67 array('component', 'com_contenthistory', '', 1), 68 array('component', 'com_cpanel', '', 1), 69 array('component', 'com_fields', '', 1), 70 array('component', 'com_finder', '', 1), 71 array('component', 'com_installer', '', 1), 72 array('component', 'com_joomlaupdate', '', 1), 73 array('component', 'com_languages', '', 1), 74 array('component', 'com_login', '', 1), 75 array('component', 'com_mails', '', 1), 76 array('component', 'com_media', '', 1), 77 array('component', 'com_menus', '', 1), 78 array('component', 'com_messages', '', 1), 79 array('component', 'com_modules', '', 1), 80 array('component', 'com_newsfeeds', '', 1), 81 array('component', 'com_plugins', '', 1), 82 array('component', 'com_postinstall', '', 1), 83 array('component', 'com_privacy', '', 1), 84 array('component', 'com_redirect', '', 1), 85 array('component', 'com_scheduler', '', 1), 86 array('component', 'com_tags', '', 1), 87 array('component', 'com_templates', '', 1), 88 array('component', 'com_users', '', 1), 89 array('component', 'com_workflow', '', 1), 90 array('component', 'com_wrapper', '', 1), 91 92 // Core file extensions 93 array('file', 'joomla', '', 0), 94 95 // Core language extensions - administrator 96 array('language', 'en-GB', '', 1), 97 98 // Core language extensions - site 99 array('language', 'en-GB', '', 0), 100 101 // Core language extensions - API 102 array('language', 'en-GB', '', 3), 103 104 // Core library extensions 105 array('library', 'joomla', '', 0), 106 array('library', 'phpass', '', 0), 107 108 // Core module extensions - administrator 109 array('module', 'mod_custom', '', 1), 110 array('module', 'mod_feed', '', 1), 111 array('module', 'mod_frontend', '', 1), 112 array('module', 'mod_latest', '', 1), 113 array('module', 'mod_latestactions', '', 1), 114 array('module', 'mod_logged', '', 1), 115 array('module', 'mod_login', '', 1), 116 array('module', 'mod_loginsupport', '', 1), 117 array('module', 'mod_menu', '', 1), 118 array('module', 'mod_messages', '', 1), 119 array('module', 'mod_multilangstatus', '', 1), 120 array('module', 'mod_popular', '', 1), 121 array('module', 'mod_post_installation_messages', '', 1), 122 array('module', 'mod_privacy_dashboard', '', 1), 123 array('module', 'mod_privacy_status', '', 1), 124 array('module', 'mod_quickicon', '', 1), 125 array('module', 'mod_sampledata', '', 1), 126 array('module', 'mod_stats_admin', '', 1), 127 array('module', 'mod_submenu', '', 1), 128 array('module', 'mod_title', '', 1), 129 array('module', 'mod_toolbar', '', 1), 130 array('module', 'mod_user', '', 1), 131 array('module', 'mod_version', '', 1), 132 133 // Core module extensions - site 134 array('module', 'mod_articles_archive', '', 0), 135 array('module', 'mod_articles_categories', '', 0), 136 array('module', 'mod_articles_category', '', 0), 137 array('module', 'mod_articles_latest', '', 0), 138 array('module', 'mod_articles_news', '', 0), 139 array('module', 'mod_articles_popular', '', 0), 140 array('module', 'mod_banners', '', 0), 141 array('module', 'mod_breadcrumbs', '', 0), 142 array('module', 'mod_custom', '', 0), 143 array('module', 'mod_feed', '', 0), 144 array('module', 'mod_finder', '', 0), 145 array('module', 'mod_footer', '', 0), 146 array('module', 'mod_languages', '', 0), 147 array('module', 'mod_login', '', 0), 148 array('module', 'mod_menu', '', 0), 149 array('module', 'mod_random_image', '', 0), 150 array('module', 'mod_related_items', '', 0), 151 array('module', 'mod_stats', '', 0), 152 array('module', 'mod_syndicate', '', 0), 153 array('module', 'mod_tags_popular', '', 0), 154 array('module', 'mod_tags_similar', '', 0), 155 array('module', 'mod_users_latest', '', 0), 156 array('module', 'mod_whosonline', '', 0), 157 array('module', 'mod_wrapper', '', 0), 158 159 // Core package extensions 160 array('package', 'pkg_en-GB', '', 0), 161 162 // Core plugin extensions - actionlog 163 array('plugin', 'joomla', 'actionlog', 0), 164 165 // Core plugin extensions - API Authentication 166 array('plugin', 'basic', 'api-authentication', 0), 167 array('plugin', 'token', 'api-authentication', 0), 168 169 // Core plugin extensions - authentication 170 array('plugin', 'cookie', 'authentication', 0), 171 array('plugin', 'joomla', 'authentication', 0), 172 array('plugin', 'ldap', 'authentication', 0), 173 174 // Core plugin extensions - behaviour 175 array('plugin', 'taggable', 'behaviour', 0), 176 array('plugin', 'versionable', 'behaviour', 0), 177 178 // Core plugin extensions - captcha 179 array('plugin', 'recaptcha', 'captcha', 0), 180 array('plugin', 'recaptcha_invisible', 'captcha', 0), 181 182 // Core plugin extensions - content 183 array('plugin', 'confirmconsent', 'content', 0), 184 array('plugin', 'contact', 'content', 0), 185 array('plugin', 'emailcloak', 'content', 0), 186 array('plugin', 'fields', 'content', 0), 187 array('plugin', 'finder', 'content', 0), 188 array('plugin', 'joomla', 'content', 0), 189 array('plugin', 'loadmodule', 'content', 0), 190 array('plugin', 'pagebreak', 'content', 0), 191 array('plugin', 'pagenavigation', 'content', 0), 192 array('plugin', 'vote', 'content', 0), 193 194 // Core plugin extensions - editors 195 array('plugin', 'codemirror', 'editors', 0), 196 array('plugin', 'none', 'editors', 0), 197 array('plugin', 'tinymce', 'editors', 0), 198 199 // Core plugin extensions - editors xtd 200 array('plugin', 'article', 'editors-xtd', 0), 201 array('plugin', 'contact', 'editors-xtd', 0), 202 array('plugin', 'fields', 'editors-xtd', 0), 203 array('plugin', 'image', 'editors-xtd', 0), 204 array('plugin', 'menu', 'editors-xtd', 0), 205 array('plugin', 'module', 'editors-xtd', 0), 206 array('plugin', 'pagebreak', 'editors-xtd', 0), 207 array('plugin', 'readmore', 'editors-xtd', 0), 208 209 // Core plugin extensions - extension 210 array('plugin', 'joomla', 'extension', 0), 211 array('plugin', 'namespacemap', 'extension', 0), 212 array('plugin', 'finder', 'extension', 0), 213 214 // Core plugin extensions - fields 215 array('plugin', 'calendar', 'fields', 0), 216 array('plugin', 'checkboxes', 'fields', 0), 217 array('plugin', 'color', 'fields', 0), 218 array('plugin', 'editor', 'fields', 0), 219 array('plugin', 'imagelist', 'fields', 0), 220 array('plugin', 'integer', 'fields', 0), 221 array('plugin', 'list', 'fields', 0), 222 array('plugin', 'media', 'fields', 0), 223 array('plugin', 'radio', 'fields', 0), 224 array('plugin', 'sql', 'fields', 0), 225 array('plugin', 'subform', 'fields', 0), 226 array('plugin', 'text', 'fields', 0), 227 array('plugin', 'textarea', 'fields', 0), 228 array('plugin', 'url', 'fields', 0), 229 array('plugin', 'user', 'fields', 0), 230 array('plugin', 'usergrouplist', 'fields', 0), 231 232 // Core plugin extensions - filesystem 233 array('plugin', 'local', 'filesystem', 0), 234 235 // Core plugin extensions - finder 236 array('plugin', 'categories', 'finder', 0), 237 array('plugin', 'contacts', 'finder', 0), 238 array('plugin', 'content', 'finder', 0), 239 array('plugin', 'newsfeeds', 'finder', 0), 240 array('plugin', 'tags', 'finder', 0), 241 242 // Core plugin extensions - installer 243 array('plugin', 'folderinstaller', 'installer', 0), 244 array('plugin', 'override', 'installer', 0), 245 array('plugin', 'packageinstaller', 'installer', 0), 246 array('plugin', 'urlinstaller', 'installer', 0), 247 array('plugin', 'webinstaller', 'installer', 0), 248 249 // Core plugin extensions - media-action 250 array('plugin', 'crop', 'media-action', 0), 251 array('plugin', 'resize', 'media-action', 0), 252 array('plugin', 'rotate', 'media-action', 0), 253 254 // Core plugin extensions - Multi-factor Authentication 255 array('plugin', 'email', 'multifactorauth', 0), 256 array('plugin', 'fixed', 'multifactorauth', 0), 257 array('plugin', 'totp', 'multifactorauth', 0), 258 array('plugin', 'webauthn', 'multifactorauth', 0), 259 array('plugin', 'yubikey', 'multifactorauth', 0), 260 261 // Core plugin extensions - privacy 262 array('plugin', 'actionlogs', 'privacy', 0), 263 array('plugin', 'consents', 'privacy', 0), 264 array('plugin', 'contact', 'privacy', 0), 265 array('plugin', 'content', 'privacy', 0), 266 array('plugin', 'message', 'privacy', 0), 267 array('plugin', 'user', 'privacy', 0), 268 269 // Core plugin extensions - quick icon 270 array('plugin', 'downloadkey', 'quickicon', 0), 271 array('plugin', 'extensionupdate', 'quickicon', 0), 272 array('plugin', 'joomlaupdate', 'quickicon', 0), 273 array('plugin', 'overridecheck', 'quickicon', 0), 274 array('plugin', 'phpversioncheck', 'quickicon', 0), 275 array('plugin', 'privacycheck', 'quickicon', 0), 276 277 // Core plugin extensions - sample data 278 array('plugin', 'blog', 'sampledata', 0), 279 array('plugin', 'multilang', 'sampledata', 0), 280 281 // Core plugin extensions - system 282 array('plugin', 'accessibility', 'system', 0), 283 array('plugin', 'actionlogs', 'system', 0), 284 array('plugin', 'cache', 'system', 0), 285 array('plugin', 'debug', 'system', 0), 286 array('plugin', 'fields', 'system', 0), 287 array('plugin', 'highlight', 'system', 0), 288 array('plugin', 'httpheaders', 'system', 0), 289 array('plugin', 'jooa11y', 'system', 0), 290 array('plugin', 'languagecode', 'system', 0), 291 array('plugin', 'languagefilter', 'system', 0), 292 array('plugin', 'log', 'system', 0), 293 array('plugin', 'logout', 'system', 0), 294 array('plugin', 'logrotation', 'system', 0), 295 array('plugin', 'privacyconsent', 'system', 0), 296 array('plugin', 'redirect', 'system', 0), 297 array('plugin', 'remember', 'system', 0), 298 array('plugin', 'schedulerunner', 'system', 0), 299 array('plugin', 'sef', 'system', 0), 300 array('plugin', 'sessiongc', 'system', 0), 301 array('plugin', 'shortcut', 'system', 0), 302 array('plugin', 'skipto', 'system', 0), 303 array('plugin', 'stats', 'system', 0), 304 array('plugin', 'tasknotification', 'system', 0), 305 array('plugin', 'updatenotification', 'system', 0), 306 array('plugin', 'webauthn', 'system', 0), 307 308 // Core plugin extensions - task scheduler 309 array('plugin', 'checkfiles', 'task', 0), 310 array('plugin', 'demotasks', 'task', 0), 311 array('plugin', 'requests', 'task', 0), 312 array('plugin', 'sitestatus', 'task', 0), 313 314 // Core plugin extensions - user 315 array('plugin', 'contactcreator', 'user', 0), 316 array('plugin', 'joomla', 'user', 0), 317 array('plugin', 'profile', 'user', 0), 318 array('plugin', 'terms', 'user', 0), 319 array('plugin', 'token', 'user', 0), 320 321 // Core plugin extensions - webservices 322 array('plugin', 'banners', 'webservices', 0), 323 array('plugin', 'config', 'webservices', 0), 324 array('plugin', 'contact', 'webservices', 0), 325 array('plugin', 'content', 'webservices', 0), 326 array('plugin', 'installer', 'webservices', 0), 327 array('plugin', 'languages', 'webservices', 0), 328 array('plugin', 'media', 'webservices', 0), 329 array('plugin', 'menus', 'webservices', 0), 330 array('plugin', 'messages', 'webservices', 0), 331 array('plugin', 'modules', 'webservices', 0), 332 array('plugin', 'newsfeeds', 'webservices', 0), 333 array('plugin', 'plugins', 'webservices', 0), 334 array('plugin', 'privacy', 'webservices', 0), 335 array('plugin', 'redirect', 'webservices', 0), 336 array('plugin', 'tags', 'webservices', 0), 337 array('plugin', 'templates', 'webservices', 0), 338 array('plugin', 'users', 'webservices', 0), 339 340 // Core plugin extensions - workflow 341 array('plugin', 'featuring', 'workflow', 0), 342 array('plugin', 'notification', 'workflow', 0), 343 array('plugin', 'publishing', 'workflow', 0), 344 345 // Core template extensions - administrator 346 array('template', 'atum', '', 1), 347 348 // Core template extensions - site 349 array('template', 'cassiopeia', '', 0), 350 ); 351 352 /** 353 * Array of core extension IDs. 354 * 355 * @var array 356 * @since 4.0.0 357 */ 358 protected static $coreExtensionIds; 359 360 /** 361 * Gets the core extensions. 362 * 363 * @return array Array with core extensions. 364 * Each extension is an array with following format: 365 * `type`, `element`, `folder`, `client_id`. 366 * 367 * @since 3.7.4 368 */ 369 public static function getCoreExtensions() 370 { 371 return self::$coreExtensions; 372 } 373 374 /** 375 * Returns an array of core extension IDs. 376 * 377 * @return array 378 * 379 * @since 4.0.0 380 * @throws \RuntimeException 381 */ 382 public static function getCoreExtensionIds() 383 { 384 if (self::$coreExtensionIds !== null) { 385 return self::$coreExtensionIds; 386 } 387 388 $db = Factory::getDbo(); 389 $query = $db->getQuery(true) 390 ->select($db->quoteName('extension_id')) 391 ->from($db->quoteName('#__extensions')); 392 393 foreach (self::$coreExtensions as $extension) { 394 $values = $query->bindArray($extension, [ParameterType::STRING, ParameterType::STRING, ParameterType::STRING, ParameterType::INTEGER]); 395 $query->where( 396 '(' . $db->quoteName('type') . ' = ' . $values[0] . ' AND ' . $db->quoteName('element') . ' = ' . $values[1] 397 . ' AND ' . $db->quoteName('folder') . ' = ' . $values[2] . ' AND ' . $db->quoteName('client_id') . ' = ' . $values[3] . ')', 398 'OR' 399 ); 400 } 401 402 $db->setQuery($query); 403 self::$coreExtensionIds = $db->loadColumn(); 404 405 return self::$coreExtensionIds; 406 } 407 408 /** 409 * Check if an extension is core or not 410 * 411 * @param string $type The extension's type. 412 * @param string $element The extension's element name. 413 * @param integer $clientId The extension's client ID. Default 0. 414 * @param string $folder The extension's folder. Default ''. 415 * 416 * @return boolean True if core, false if not. 417 * 418 * @since 3.7.4 419 */ 420 public static function checkIfCoreExtension($type, $element, $clientId = 0, $folder = '') 421 { 422 return \in_array(array($type, $element, $folder, $clientId), self::$coreExtensions); 423 } 424 425 /** 426 * Returns an extension record for the given name. 427 * 428 * @param string $element The extension element 429 * @param string $type The extension type 430 * @param integer|null $clientId The client ID 431 * @param string|null $folder Plugin folder 432 * 433 * @return \stdClass|null The object or null if not found. 434 * 435 * @since 4.0.0 436 * @throws \InvalidArgumentException 437 */ 438 public static function getExtensionRecord(string $element, string $type, ?int $clientId = null, ?string $folder = null): ?\stdClass 439 { 440 if ($type === 'plugin' && $folder === null) { 441 throw new \InvalidArgumentException(sprintf('`$folder` is required when `$type` is `plugin` in %s()', __METHOD__)); 442 } 443 444 if (\in_array($type, ['module', 'language', 'template'], true) && $clientId === null) { 445 throw new \InvalidArgumentException( 446 sprintf('`$clientId` is required when `$type` is `module`, `language` or `template` in %s()', __METHOD__) 447 ); 448 } 449 450 $key = $element . '.' . $type . '.' . $clientId . '.' . $folder; 451 452 if (!\array_key_exists($key, self::$loadedExtensions)) { 453 $db = Factory::getDbo(); 454 $query = $db->getQuery(true) 455 ->select('*') 456 ->from($db->quoteName('#__extensions')) 457 ->where( 458 [ 459 $db->quoteName('element') . ' = :element', 460 $db->quoteName('type') . ' = :type', 461 ] 462 ) 463 ->bind(':element', $element) 464 ->bind(':type', $type); 465 466 if ($clientId !== null) { 467 $query->where($db->quoteName('client_id') . ' = :clientId') 468 ->bind(':clientId', $clientId, ParameterType::INTEGER); 469 } 470 471 if ($folder !== null) { 472 $query->where($db->quoteName('folder') . ' = :folder') 473 ->bind(':folder', $folder); 474 } 475 476 $query->setLimit(1); 477 $db->setQuery($query); 478 479 self::$loadedExtensions[$key] = $db->loadObject(); 480 } 481 482 return self::$loadedExtensions[$key]; 483 } 484 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |