Source for file helper.php

Documentation is available at helper.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  mod_quickicon
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Helper for mod_quickicon
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  mod_quickicon
  17.  * @since       1.6
  18.  */
  19. abstract class ModQuickIconHelper
  20. {
  21.     /**
  22.      * Stack to hold buttons
  23.      *
  24.      * @since   1.6
  25.      */
  26.     protected static $buttons array();
  27.  
  28.     /**
  29.      * Helper method to return button list.
  30.      *
  31.      * This method returns the array by reference so it can be
  32.      * used to add custom buttons or remove default ones.
  33.      *
  34.      * @param   JObject  $params  The module parameters.
  35.      *
  36.      * @return  array  An array of buttons
  37.      *
  38.      * @since   1.6
  39.      */
  40.     public static function &getButtons($params)
  41.     {
  42.         $key = (string) $params;
  43.  
  44.         if (!isset(self::$buttons[$key]))
  45.         {
  46.             $context $params->get('context''mod_quickicon');
  47.  
  48.             if ($context == 'mod_quickicon')
  49.             {
  50.                 // Load mod_quickicon language file in case this method is called before rendering the module
  51.                 JFactory::getLanguage()->load('mod_quickicon');
  52.  
  53.                 self::$buttons[$keyarray(
  54.                     array(
  55.                         'link' => JRoute::_('index.php?option=com_content&task=article.add'),
  56.                         'image' => 'pencil-2',
  57.                         'icon' => 'header/icon-48-article-add.png',
  58.                         'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE'),
  59.                         'access' => array('core.manage''com_content''core.create''com_content'),
  60.                         'group' => 'MOD_QUICKICON_CONTENT'
  61.                     ),
  62.                     array(
  63.                         'link' => JRoute::_('index.php?option=com_content'),
  64.                         'image' => 'stack',
  65.                         'icon' => 'header/icon-48-article.png',
  66.                         'text' => JText::_('MOD_QUICKICON_ARTICLE_MANAGER'),
  67.                         'access' => array('core.manage''com_content'),
  68.                         'group' => 'MOD_QUICKICON_CONTENT'
  69.                     ),
  70.                     array(
  71.                         'link' => JRoute::_('index.php?option=com_categories&extension=com_content'),
  72.                         'image' => 'folder',
  73.                         'icon' => 'header/icon-48-category.png',
  74.                         'text' => JText::_('MOD_QUICKICON_CATEGORY_MANAGER'),
  75.                         'access' => array('core.manage''com_content'),
  76.                         'group' => 'MOD_QUICKICON_CONTENT'
  77.                     ),
  78.                     array(
  79.                         'link' => JRoute::_('index.php?option=com_media'),
  80.                         'image' => 'pictures',
  81.                         'icon' => 'header/icon-48-media.png',
  82.                         'text' => JText::_('MOD_QUICKICON_MEDIA_MANAGER'),
  83.                         'access' => array('core.manage''com_media'),
  84.                         'group' => 'MOD_QUICKICON_CONTENT'
  85.                     ),
  86.                     array(
  87.                         'link' => JRoute::_('index.php?option=com_menus'),
  88.                         'image' => 'list-view',
  89.                         'icon' => 'header/icon-48-menumgr.png',
  90.                         'text' => JText::_('MOD_QUICKICON_MENU_MANAGER'),
  91.                         'access' => array('core.manage''com_menus'),
  92.                         'group' => 'MOD_QUICKICON_STRUCTURE'
  93.                     ),
  94.                     array(
  95.                         'link' => JRoute::_('index.php?option=com_users'),
  96.                         'image' => 'users',
  97.                         'icon' => 'header/icon-48-user.png',
  98.                         'text' => JText::_('MOD_QUICKICON_USER_MANAGER'),
  99.                         'access' => array('core.manage''com_users'),
  100.                         'group' => 'MOD_QUICKICON_USERS'
  101.                     ),
  102.                     array(
  103.                         'link' => JRoute::_('index.php?option=com_modules'),
  104.                         'image' => 'cube',
  105.                         'icon' => 'header/icon-48-module.png',
  106.                         'text' => JText::_('MOD_QUICKICON_MODULE_MANAGER'),
  107.                         'access' => array('core.manage''com_modules'),
  108.                         'group' => 'MOD_QUICKICON_STRUCTURE'
  109.                     ),
  110.                     array(
  111.                         'link' => JRoute::_('index.php?option=com_config'),
  112.                         'image' => 'cog',
  113.                         'icon' => 'header/icon-48-config.png',
  114.                         'text' => JText::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'),
  115.                         'access' => array('core.manage''com_config''core.admin''com_config'),
  116.                         'group' => 'MOD_QUICKICON_CONFIGURATION'
  117.                     ),
  118.                     array(
  119.                         'link' => JRoute::_('index.php?option=com_templates'),
  120.                         'image' => 'eye',
  121.                         'icon' => 'header/icon-48-themes.png',
  122.                         'text' => JText::_('MOD_QUICKICON_TEMPLATE_MANAGER'),
  123.                         'access' => array('core.manage''com_templates'),
  124.                         'group' => 'MOD_QUICKICON_CONFIGURATION'
  125.                     ),
  126.                     array(
  127.                         'link' => JRoute::_('index.php?option=com_languages'),
  128.                         'image' => 'comments-2',
  129.                         'icon' => 'header/icon-48-language.png',
  130.                         'text' => JText::_('MOD_QUICKICON_LANGUAGE_MANAGER'),
  131.                         'access' => array('core.manage''com_languages'),
  132.                         'group' => 'MOD_QUICKICON_CONFIGURATION'
  133.                     ),
  134.                     array(
  135.                         'link' => JRoute::_('index.php?option=com_installer'),
  136.                         'image' => 'download',
  137.                         'icon' => 'header/icon-48-extension.png',
  138.                         'text' => JText::_('MOD_QUICKICON_INSTALL_EXTENSIONS'),
  139.                         'access' => array('core.manage''com_installer'),
  140.                         'group' => 'MOD_QUICKICON_EXTENSIONS'
  141.                     )
  142.                 );
  143.             }
  144.             else
  145.             {
  146.                 self::$buttons[$keyarray();
  147.             }
  148.  
  149.             // Include buttons defined by published quickicon plugins
  150.             JPluginHelper::importPlugin('quickicon');
  151.             $app JFactory::getApplication();
  152.             $arrays = (array) $app->triggerEvent('onGetIcons'array($context));
  153.  
  154.             foreach ($arrays as $response)
  155.             {
  156.                 foreach ($response as $icon)
  157.                 {
  158.                     $default array(
  159.                         'link' => null,
  160.                         'image' => 'cog',
  161.                         'text' => null,
  162.                         'access' => true,
  163.                         'group' => 'MOD_QUICKICON_EXTENSIONS'
  164.                     );
  165.                     $icon array_merge($default$icon);
  166.  
  167.                     if (!is_null($icon['link']&& !is_null($icon['text']))
  168.                     {
  169.                         self::$buttons[$key][$icon;
  170.                     }
  171.                 }
  172.             }
  173.         }
  174.  
  175.         return self::$buttons[$key];
  176.     }
  177.  
  178.     /**
  179.      * Classifies the $buttons by group
  180.      *
  181.      * @param   array  $buttons  The buttons
  182.      *
  183.      * @return  array  The buttons sorted by groups
  184.      *
  185.      * @since   3.2
  186.      */
  187.     public static function groupButtons($buttons)
  188.     {
  189.         $groupedButtons array();
  190.  
  191.         foreach ($buttons as $button)
  192.         {
  193.             $groupedButtons[$button['group']][$button;
  194.         }
  195.         return $groupedButtons;
  196.     }
  197.  
  198.     /**
  199.      * Get the alternate title for the module
  200.      *
  201.      * @param   JObject  $params  The module parameters.
  202.      * @param   JObject  $module  The module.
  203.      *
  204.      * @return  string    The alternate title for the module.
  205.      */
  206.     public static function getTitle($params$module)
  207.     {
  208.         $key $params->get('context''mod_quickicon''_title';
  209.  
  210.         if (JFactory::getLanguage()->hasKey($key))
  211.         {
  212.             return JText::_($key);
  213.         }
  214.         else
  215.         {
  216.             return $module->title;
  217.         }
  218.     }
  219. }

Documentation generated on Tue, 19 Nov 2013 15:04:27 +0100 by phpDocumentor 1.4.3