[ 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.Downloadkey 6 * 7 * @copyright (C) 2019 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\Application\CMSApplication; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\Plugin\CMSPlugin; 16 use Joomla\Component\Installer\Administrator\Helper\InstallerHelper as ComInstallerHelper; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Joomla! update notification plugin 24 * 25 * @since 4.0.0 26 */ 27 class PlgQuickiconDownloadkey extends CMSPlugin 28 { 29 /** 30 * Load the language file on instantiation. 31 * 32 * @var boolean 33 * @since 4.0.0 34 */ 35 protected $autoloadLanguage = true; 36 37 /** 38 * Application object. 39 * 40 * @var CMSApplication 41 * @since 4.0.0 42 */ 43 protected $app; 44 45 /** 46 * Returns an icon definition for an icon which looks for extensions updates 47 * via AJAX and displays a notification when such updates are found. 48 * 49 * @param string $context The calling context 50 * 51 * @return array A list of icon definition associative arrays, consisting of the 52 * keys link, image, text and access. 53 * 54 * @since 4.0.0 55 */ 56 public function onGetIcons($context) 57 { 58 if ( 59 $context !== $this->params->get('context', 'update_quickicon') 60 || !$this->app->getIdentity()->authorise('core.manage', 'com_installer') 61 ) { 62 return []; 63 } 64 65 $info = $this->getMissingDownloadKeyInfo(); 66 67 // No extensions need a download key. The icon is not rendered. 68 if (!$info['supported']) { 69 return []; 70 } 71 72 $iconDefinition = [ 73 'link' => 'index.php?option=com_installer&view=updatesites&filter[supported]=1', 74 'image' => 'icon-key', 75 'icon' => '', 76 'text' => Text::_('PLG_QUICKICON_DOWNLOADKEY_OK'), 77 'class' => 'success', 78 'id' => 'plg_quickicon_downloadkey', 79 'group' => 'MOD_QUICKICON_MAINTENANCE', 80 ]; 81 82 if ($info['missing'] !== 0) { 83 $iconDefinition = array_merge($iconDefinition, [ 84 'link' => 'index.php?option=com_installer&view=updatesites&filter[supported]=-1', 85 'text' => Text::plural('PLG_QUICKICON_DOWNLOADKEY_N_MISSING', $info['missing']), 86 'class' => 'danger', 87 ]); 88 } 89 90 return [ 91 $iconDefinition, 92 ]; 93 } 94 95 /** 96 * Gets the information about update sites requiring but missing a download key. 97 * 98 * The return array has two keys: 99 * - supported Number of update sites supporting Download Key 100 * - missing Number of update sites missing a Download Key 101 * 102 * If 'supported' is zero you do not need to provide any download keys. All your extensions are free downloads. 103 * 104 * If 'supported' is non-zero and 'missing' is zero you have entered a download key for all paid extensions. 105 * 106 * If 'supported' is non-zero and 'missing' is also non-zero you need to enter one or more download keys. 107 * 108 * @return array 109 * @since 4.0.0 110 */ 111 public function getMissingDownloadKeyInfo(): array 112 { 113 $ret = [ 114 'supported' => 0, 115 'missing' => 0, 116 ]; 117 118 if (!class_exists('Joomla\Component\Installer\Administrator\Helper\InstallerHelper')) { 119 require_once JPATH_ADMINISTRATOR . '/components/com_installer/Helper/InstallerHelper.php'; 120 } 121 122 $supported = ComInstallerHelper::getDownloadKeySupportedSites(true); 123 $ret['supported'] = count($supported); 124 125 if ($ret['supported'] === 0) { 126 return $ret; 127 } 128 129 $missing = ComInstallerHelper::getDownloadKeyExistsSites(false, true); 130 $ret['missing'] = count($missing); 131 132 return $ret; 133 } 134 }
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 |