[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/modules/mod_quickicon/src/Helper/ -> QuickIconHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  mod_quickicon
   6   *
   7   * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Module\Quickicon\Administrator\Helper;
  12  
  13  use Joomla\CMS\Application\CMSApplication;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Plugin\PluginHelper;
  16  use Joomla\CMS\Router\Route;
  17  use Joomla\Module\Quickicon\Administrator\Event\QuickIconsEvent;
  18  use Joomla\Registry\Registry;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('_JEXEC') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * Helper for mod_quickicon
  26   *
  27   * @since  1.6
  28   */
  29  class QuickIconHelper
  30  {
  31      /**
  32       * Stack to hold buttons
  33       *
  34       * @var     array[]
  35       * @since   1.6
  36       */
  37      protected $buttons = array();
  38  
  39      /**
  40       * Helper method to return button list.
  41       *
  42       * This method returns the array by reference so it can be
  43       * used to add custom buttons or remove default ones.
  44       *
  45       * @param   Registry        $params       The module parameters
  46       * @param   CMSApplication  $application  The application
  47       *
  48       * @return  array  An array of buttons
  49       *
  50       * @since   1.6
  51       */
  52      public function getButtons(Registry $params, CMSApplication $application = null)
  53      {
  54          if ($application == null) {
  55              $application = Factory::getApplication();
  56          }
  57  
  58          $key     = (string) $params;
  59          $context = (string) $params->get('context', 'mod_quickicon');
  60  
  61          if (!isset($this->buttons[$key])) {
  62              // Load mod_quickicon language file in case this method is called before rendering the module
  63              $application->getLanguage()->load('mod_quickicon');
  64  
  65              $this->buttons[$key] = [];
  66  
  67              if ($params->get('show_users')) {
  68                  $tmp = [
  69                      'image'   => 'icon-users',
  70                      'link'    => Route::_('index.php?option=com_users&view=users'),
  71                      'linkadd' => Route::_('index.php?option=com_users&task=user.add'),
  72                      'name'    => 'MOD_QUICKICON_USER_MANAGER',
  73                      'access'  => array('core.manage', 'com_users', 'core.create', 'com_users'),
  74                      'group'   => 'MOD_QUICKICON_SITE',
  75                  ];
  76  
  77                  if ($params->get('show_users') == 2) {
  78                      $tmp['ajaxurl'] = 'index.php?option=com_users&amp;task=users.getQuickiconContent&amp;format=json';
  79                  }
  80  
  81                  $this->buttons[$key][] = $tmp;
  82              }
  83  
  84              if ($params->get('show_menuitems')) {
  85                  $tmp = [
  86                      'image'   => 'icon-list',
  87                      'link'    => Route::_('index.php?option=com_menus&view=items&menutype='),
  88                      'linkadd' => Route::_('index.php?option=com_menus&task=item.add'),
  89                      'name'    => 'MOD_QUICKICON_MENUITEMS_MANAGER',
  90                      'access'  => array('core.manage', 'com_menus', 'core.create', 'com_menus'),
  91                      'group'   => 'MOD_QUICKICON_STRUCTURE',
  92                  ];
  93  
  94                  if ($params->get('show_menuitems') == 2) {
  95                      $tmp['ajaxurl'] = 'index.php?option=com_menus&amp;task=items.getQuickiconContent&amp;format=json';
  96                  }
  97  
  98                  $this->buttons[$key][] = $tmp;
  99              }
 100  
 101              if ($params->get('show_articles')) {
 102                  $tmp = [
 103                      'image'   => 'icon-file-alt',
 104                      'link'    => Route::_('index.php?option=com_content&view=articles'),
 105                      'linkadd' => Route::_('index.php?option=com_content&task=article.add'),
 106                      'name'    => 'MOD_QUICKICON_ARTICLE_MANAGER',
 107                      'access'  => array('core.manage', 'com_content', 'core.create', 'com_content'),
 108                      'group'   => 'MOD_QUICKICON_SITE',
 109                  ];
 110  
 111                  if ($params->get('show_articles') == 2) {
 112                      $tmp['ajaxurl'] = 'index.php?option=com_content&amp;task=articles.getQuickiconContent&amp;format=json';
 113                  }
 114  
 115                  $this->buttons[$key][] = $tmp;
 116              }
 117  
 118              if ($params->get('show_tags')) {
 119                  $tmp = [
 120                      'image'   => 'icon-tag',
 121                      'link'    => Route::_('index.php?option=com_tags&view=tags'),
 122                      'linkadd' => Route::_('index.php?option=com_tags&task=tag.edit'),
 123                      'name'    => 'MOD_QUICKICON_TAGS_MANAGER',
 124                      'access'  => array('core.manage', 'com_tags', 'core.create', 'com_tags'),
 125                      'group'   => 'MOD_QUICKICON_SITE',
 126                  ];
 127  
 128                  if ($params->get('show_tags') == 2) {
 129                      $tmp['ajaxurl'] = 'index.php?option=com_tags&amp;task=tags.getQuickiconContent&amp;format=json';
 130                  }
 131  
 132                  $this->buttons[$key][] = $tmp;
 133              }
 134  
 135              if ($params->get('show_categories')) {
 136                  $tmp = [
 137                      'image'   => 'icon-folder-open',
 138                      'link'    => Route::_('index.php?option=com_categories&view=categories&extension=com_content'),
 139                      'linkadd' => Route::_('index.php?option=com_categories&task=category.add'),
 140                      'name'    => 'MOD_QUICKICON_CATEGORY_MANAGER',
 141                      'access'  => array('core.manage', 'com_categories', 'core.create', 'com_categories'),
 142                      'group'   => 'MOD_QUICKICON_SITE',
 143                  ];
 144  
 145                  if ($params->get('show_categories') == 2) {
 146                      $tmp['ajaxurl'] = 'index.php?option=com_categories&amp;task=categories.getQuickiconContent&amp;extension=content&amp;format=json';
 147                  }
 148  
 149                  $this->buttons[$key][] = $tmp;
 150              }
 151  
 152              if ($params->get('show_media')) {
 153                  $this->buttons[$key][] = [
 154                      'image'  => 'icon-images',
 155                      'link'   => Route::_('index.php?option=com_media'),
 156                      'name'   => 'MOD_QUICKICON_MEDIA_MANAGER',
 157                      'access' => array('core.manage', 'com_media'),
 158                      'group'  => 'MOD_QUICKICON_SITE',
 159                  ];
 160              }
 161  
 162              if ($params->get('show_modules')) {
 163                  $tmp = [
 164                      'image'   => 'icon-cube',
 165                      'link'    => Route::_('index.php?option=com_modules&view=modules&client_id=0'),
 166                      'linkadd' => Route::_('index.php?option=com_modules&view=select&client_id=0'),
 167                      'name'    => 'MOD_QUICKICON_MODULE_MANAGER',
 168                      'access'  => array('core.manage', 'com_modules'),
 169                      'group'   => 'MOD_QUICKICON_SITE'
 170                  ];
 171  
 172                  if ($params->get('show_modules') == 2) {
 173                      $tmp['ajaxurl'] = 'index.php?option=com_modules&amp;task=modules.getQuickiconContent&amp;format=json';
 174                  }
 175  
 176                  $this->buttons[$key][] = $tmp;
 177              }
 178  
 179              if ($params->get('show_plugins')) {
 180                  $tmp = [
 181                      'image'  => 'icon-plug',
 182                      'link'   => Route::_('index.php?option=com_plugins'),
 183                      'name'   => 'MOD_QUICKICON_PLUGIN_MANAGER',
 184                      'access' => array('core.manage', 'com_plugins'),
 185                      'group'  => 'MOD_QUICKICON_SITE'
 186                  ];
 187  
 188                  if ($params->get('show_plugins') == 2) {
 189                      $tmp['ajaxurl'] = 'index.php?option=com_plugins&amp;task=plugins.getQuickiconContent&amp;format=json';
 190                  }
 191  
 192                  $this->buttons[$key][] = $tmp;
 193              }
 194  
 195              if ($params->get('show_template_styles')) {
 196                  $this->buttons[$key][] = [
 197                      'image'  => 'icon-paint-brush',
 198                      'link'   => Route::_('index.php?option=com_templates&view=styles&client_id=0'),
 199                      'name'   => 'MOD_QUICKICON_TEMPLATE_STYLES',
 200                      'access' => array('core.admin', 'com_templates'),
 201                      'group'  => 'MOD_QUICKICON_SITE'
 202                  ];
 203              }
 204  
 205              if ($params->get('show_template_code')) {
 206                  $this->buttons[$key][] = [
 207                      'image'  => 'icon-code',
 208                      'link'   => Route::_('index.php?option=com_templates&view=templates&client_id=0'),
 209                      'name'   => 'MOD_QUICKICON_TEMPLATE_CODE',
 210                      'access' => array('core.admin', 'com_templates'),
 211                      'group'  => 'MOD_QUICKICON_SITE'
 212                  ];
 213              }
 214  
 215              if ($params->get('show_checkin')) {
 216                  $tmp = [
 217                      'image'   => 'icon-unlock-alt',
 218                      'link'    => Route::_('index.php?option=com_checkin'),
 219                      'name'    => 'MOD_QUICKICON_CHECKINS',
 220                      'access'  => array('core.admin', 'com_checkin'),
 221                      'group'   => 'MOD_QUICKICON_SYSTEM'
 222                  ];
 223  
 224                  if ($params->get('show_checkin') == 2) {
 225                      $tmp['ajaxurl'] = 'index.php?option=com_checkin&amp;task=getQuickiconContent&amp;format=json';
 226                  }
 227  
 228                  $this->buttons[$key][] = $tmp;
 229              }
 230  
 231              if ($params->get('show_cache')) {
 232                  $tmp = [
 233                      'image'   => 'icon-cloud',
 234                      'link'    => Route::_('index.php?option=com_cache'),
 235                      'name'    => 'MOD_QUICKICON_CACHE',
 236                      'access'  => array('core.admin', 'com_cache'),
 237                      'group'   => 'MOD_QUICKICON_SYSTEM'
 238                  ];
 239  
 240                  if ($params->get('show_cache') == 2) {
 241                      $tmp['ajaxurl'] = 'index.php?option=com_cache&amp;task=display.getQuickiconContent&amp;format=json';
 242                  }
 243  
 244                  $this->buttons[$key][] = $tmp;
 245              }
 246  
 247              if ($params->get('show_global')) {
 248                  $this->buttons[$key][] = [
 249                      'image'  => 'icon-cog',
 250                      'link'   => Route::_('index.php?option=com_config'),
 251                      'name'   => 'MOD_QUICKICON_GLOBAL_CONFIGURATION',
 252                      'access' => array('core.manage', 'com_config', 'core.admin', 'com_config'),
 253                      'group'  => 'MOD_QUICKICON_SYSTEM',
 254                  ];
 255              }
 256  
 257              PluginHelper::importPlugin('quickicon');
 258  
 259              $arrays = (array) $application->triggerEvent(
 260                  'onGetIcons',
 261                  new QuickIconsEvent('onGetIcons', ['context' => $context])
 262              );
 263  
 264              foreach ($arrays as $response) {
 265                  if (!\is_array($response)) {
 266                      continue;
 267                  }
 268  
 269                  foreach ($response as $icon) {
 270                      $default = array(
 271                          'link'    => null,
 272                          'image'   => null,
 273                          'text'    => null,
 274                          'name'    => null,
 275                          'linkadd' => null,
 276                          'access'  => true,
 277                          'class'   => null,
 278                          'group'   => 'MOD_QUICKICON',
 279                      );
 280  
 281                      $icon = array_merge($default, $icon);
 282  
 283                      if (!\is_null($icon['link']) && (!\is_null($icon['text']) || !\is_null($icon['name']))) {
 284                          $this->buttons[$key][] = $icon;
 285                      }
 286                  }
 287              }
 288          }
 289  
 290          return $this->buttons[$key];
 291      }
 292  }


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