[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage Quickicon.Overridecheck 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 10 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace 11 */ 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\Plugin\CMSPlugin; 15 use Joomla\CMS\Session\Session; 16 use Joomla\CMS\Uri\Uri; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Joomla! template override notification plugin 24 * 25 * @since 4.0.0 26 */ 27 class PlgQuickiconOverrideCheck extends CMSPlugin 28 { 29 /** 30 * Load the language file on instantiation. 31 * 32 * @var boolean 33 * 34 * @since 4.0.0 35 */ 36 protected $autoloadLanguage = true; 37 38 /** 39 * Application object. 40 * 41 * @var \Joomla\CMS\Application\CMSApplication 42 * @since 3.7.0 43 */ 44 protected $app; 45 46 /** 47 * Database object 48 * 49 * @var \Joomla\Database\DatabaseInterface 50 * 51 * @since 3.8.0 52 */ 53 protected $db; 54 55 /** 56 * Returns an icon definition for an icon which looks for overrides update 57 * via AJAX and displays a notification when such overrides are updated. 58 * 59 * @param string $context The calling context 60 * 61 * @return array A list of icon definition associative arrays, consisting of the 62 * keys link, image, text and access. 63 * 64 * @since 4.0.0 65 */ 66 public function onGetIcons($context) 67 { 68 if ($context !== $this->params->get('context', 'update_quickicon') || !$this->app->getIdentity()->authorise('core.manage', 'com_installer')) { 69 return array(); 70 } 71 72 $token = Session::getFormToken() . '=1'; 73 $options = array( 74 'url' => Uri::base() . 'index.php?option=com_templates&view=templates', 75 'ajaxUrl' => Uri::base() . 'index.php?option=com_templates&view=templates&task=template.ajax&' . $token, 76 'pluginId' => $this->getOverridePluginId(), 77 ); 78 79 $this->app->getDocument()->addScriptOptions('js-override-check', $options); 80 81 Text::script('PLG_QUICKICON_OVERRIDECHECK_ERROR', true); 82 Text::script('PLG_QUICKICON_OVERRIDECHECK_ERROR_ENABLE', true); 83 Text::script('PLG_QUICKICON_OVERRIDECHECK_UPTODATE', true); 84 Text::script('PLG_QUICKICON_OVERRIDECHECK_OVERRIDEFOUND', true); 85 86 $this->app->getDocument()->getWebAssetManager() 87 ->registerAndUseScript('plg_quickicon_overridecheck', 'plg_quickicon_overridecheck/overridecheck.js', [], ['defer' => true], ['core']); 88 89 return array( 90 array( 91 'link' => 'index.php?option=com_templates&view=templates', 92 'image' => 'icon-file', 93 'icon' => '', 94 'text' => Text::_('PLG_QUICKICON_OVERRIDECHECK_CHECKING'), 95 'id' => 'plg_quickicon_overridecheck', 96 'group' => 'MOD_QUICKICON_MAINTENANCE', 97 ), 98 ); 99 } 100 101 /** 102 * Gets the installer override plugin extension id. 103 * 104 * @return integer The installer override plugin extension id. 105 * 106 * @since 4.0.0 107 */ 108 private function getOverridePluginId() 109 { 110 $query = $this->db->getQuery(true) 111 ->select($this->db->quoteName('extension_id')) 112 ->from($this->db->quoteName('#__extensions')) 113 ->where($this->db->quoteName('folder') . ' = ' . $this->db->quote('installer')) 114 ->where($this->db->quoteName('element') . ' = ' . $this->db->quote('override')); 115 $this->db->setQuery($query); 116 117 try { 118 $result = (int) $this->db->loadResult(); 119 } catch (\RuntimeException $e) { 120 $this->app->enqueueMessage($e->getMessage(), 'error'); 121 } 122 123 return $result; 124 } 125 }
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 |