[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/quickicon/extensionupdate/ -> extensionupdate.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Quickicon.Extensionupdate
   6   *
   7   * @copyright   (C) 2011 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\Extension\ExtensionHelper;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\Plugin\CMSPlugin;
  16  use Joomla\CMS\Session\Session;
  17  use Joomla\CMS\Uri\Uri;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Joomla! update notification plugin
  25   *
  26   * @since  2.5
  27   */
  28  class PlgQuickiconExtensionupdate extends CMSPlugin
  29  {
  30      /**
  31       * Load the language file on instantiation.
  32       *
  33       * @var    boolean
  34       * @since  3.1
  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       * Returns an icon definition for an icon which looks for extensions updates
  48       * via AJAX and displays a notification when such updates are found.
  49       *
  50       * @param   string  $context  The calling context
  51       *
  52       * @return  array  A list of icon definition associative arrays, consisting of the
  53       *                 keys link, image, text and access.
  54       *
  55       * @since   2.5
  56       */
  57      public function onGetIcons($context)
  58      {
  59          if ($context !== $this->params->get('context', 'update_quickicon') || !$this->app->getIdentity()->authorise('core.manage', 'com_installer')) {
  60              return array();
  61          }
  62  
  63          $token    = Session::getFormToken() . '=1';
  64          $options  = array(
  65              'url' => Uri::base() . 'index.php?option=com_installer&view=update&task=update.find&' . $token,
  66              'ajaxUrl' => Uri::base() . 'index.php?option=com_installer&view=update&task=update.ajax&' . $token
  67                  . '&cache_timeout=3600&eid=0&skip=' . ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id,
  68          );
  69  
  70          $this->app->getDocument()->addScriptOptions('js-extensions-update', $options);
  71  
  72          Text::script('PLG_QUICKICON_EXTENSIONUPDATE_UPTODATE');
  73          Text::script('PLG_QUICKICON_EXTENSIONUPDATE_UPDATEFOUND');
  74          Text::script('PLG_QUICKICON_EXTENSIONUPDATE_ERROR');
  75          Text::script('MESSAGE');
  76          Text::script('ERROR');
  77          Text::script('INFO');
  78          Text::script('WARNING');
  79  
  80          $this->app->getDocument()->getWebAssetManager()
  81              ->registerAndUseScript(
  82                  'plg_quickicon_extensionupdate',
  83                  'plg_quickicon_extensionupdate/extensionupdatecheck.min.js',
  84                  [],
  85                  ['defer' => true],
  86                  ['core']
  87              );
  88  
  89          return array(
  90              array(
  91                  'link'  => 'index.php?option=com_installer&view=update&task=update.find&' . $token,
  92                  'image' => 'icon-star',
  93                  'icon'  => '',
  94                  'text'  => Text::_('PLG_QUICKICON_EXTENSIONUPDATE_CHECKING'),
  95                  'id'    => 'plg_quickicon_extensionupdate',
  96                  'group' => 'MOD_QUICKICON_MAINTENANCE',
  97              ),
  98          );
  99      }
 100  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer