/administrator/modules/mod_quickicon/helper.php

https://github.com/sengann/iks-school.com · PHP · 145 lines · 103 code · 7 blank · 35 comment · 4 complexity · 98fd28e3ffed62495320dee5358964c1 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: helper.php 19482 2010-11-15 18:44:36Z dextercowley $
  4. * @package Joomla.Administrator
  5. * @subpackage mod_quickicon
  6. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. // No direct access.
  10. defined('_JEXEC') or die;
  11. /**
  12. * @package Joomla.Administrator
  13. * @subpackage mod_quickicon
  14. * @since 1.6
  15. */
  16. abstract class QuickIconHelper
  17. {
  18. /**
  19. * Stack to hold default buttons
  20. *
  21. * @since 1.6
  22. */
  23. protected static $buttons = array();
  24. /**
  25. * Helper method to generate a button in administrator panel
  26. *
  27. * @param array A named array with keys link, image, text, access and imagePath
  28. *
  29. * @return string HTML for button
  30. * @since 1.6
  31. */
  32. public static function button($button)
  33. {
  34. if (!empty($button['access'])) {
  35. if (!JFactory::getUser()->authorise($button['access'][0], $button['access'][1])) {
  36. return '';
  37. }
  38. }
  39. if (empty($button['imagePath'])) {
  40. $template = JFactory::getApplication()->getTemplate();
  41. $button['imagePath'] = '/templates/'. $template .'/images/header/';
  42. }
  43. ob_start();
  44. require JModuleHelper::getLayoutPath('mod_quickicon', 'default_button');
  45. $html = ob_get_clean();
  46. return $html;
  47. }
  48. /**
  49. * Helper method to return button list.
  50. *
  51. * This method returns the array by reference so it can be
  52. * used to add custom buttons or remove default ones.
  53. *
  54. * @return array An array of buttons
  55. * @since 1.6
  56. */
  57. public static function &getButtons()
  58. {
  59. if (empty(self::$buttons)) {
  60. $userid = JFactory::getUser()->id;
  61. self::$buttons = array(
  62. array(
  63. 'link' => JRoute::_('index.php?option=com_content&task=article.add'),
  64. 'image' => 'icon-48-article-add.png',
  65. 'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE'),
  66. 'access' => array('core.create', 'com_content')
  67. ),
  68. array(
  69. 'link' => JRoute::_('index.php?option=com_content'),
  70. 'image' => 'icon-48-article.png',
  71. 'text' => JText::_('MOD_QUICKICON_ARTICLE_MANAGER'),
  72. 'access' => array('core.manage', 'com_content')
  73. ),
  74. array(
  75. 'link' => JRoute::_('index.php?option=com_categories&extension=com_content'),
  76. 'image' => 'icon-48-category.png',
  77. 'text' => JText::_('MOD_QUICKICON_CATEGORY_MANAGER'),
  78. 'access' => array('core.manage', 'com_content')
  79. ),
  80. array(
  81. 'link' => JRoute::_('index.php?option=com_media'),
  82. 'image' => 'icon-48-media.png',
  83. 'text' => JText::_('MOD_QUICKICON_MEDIA_MANAGER'),
  84. 'access' => array('core.manage', 'com_media')
  85. ),
  86. array(
  87. 'link' => JRoute::_('index.php?option=com_menus'),
  88. 'image' => 'icon-48-menumgr.png',
  89. 'text' => JText::_('MOD_QUICKICON_MENU_MANAGER'),
  90. 'access' => array('core.manage', 'com_menus')
  91. ),
  92. array(
  93. 'link' => JRoute::_('index.php?option=com_users'),
  94. 'image' => 'icon-48-user.png',
  95. 'text' => JText::_('MOD_QUICKICON_USER_MANAGER'),
  96. 'access' => array('core.manage', 'com_users')
  97. ),
  98. array(
  99. 'link' => JRoute::_('index.php?option=com_modules'),
  100. 'image' => 'icon-48-module.png',
  101. 'text' => JText::_('MOD_QUICKICON_MODULE_MANAGER'),
  102. 'access' => array('core.manage', 'com_modules')
  103. ),
  104. array(
  105. 'link' => JRoute::_('index.php?option=com_installer'),
  106. 'image' => 'icon-48-extension.png',
  107. 'text' => JText::_('MOD_QUICKICON_EXTENSION_MANAGER'),
  108. 'access' => array('core.manage', 'com_installer')
  109. ),
  110. array(
  111. 'link' => JRoute::_('index.php?option=com_languages'),
  112. 'image' => 'icon-48-language.png',
  113. 'text' => JText::_('MOD_QUICKICON_LANGUAGE_MANAGER'),
  114. 'access' => array('core.manage', 'com_languages')
  115. ),
  116. array(
  117. 'link' => JRoute::_('index.php?option=com_config'),
  118. 'image' => 'icon-48-config.png',
  119. 'text' => JText::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'),
  120. 'access' => array('core.admin', 'com_config')
  121. ),
  122. array(
  123. 'link' => JRoute::_('index.php?option=com_users&task=user.edit&id='.$userid),
  124. 'image' => 'icon-48-user-profile.png',
  125. 'text' => JText::_('MOD_QUICKICON_PROFILE'),
  126. 'access' => array('core.manage', 'com_content')
  127. ),
  128. array(
  129. 'link' => JRoute::_('index.php?option=com_templates'),
  130. 'image' => 'icon-48-themes.png',
  131. 'text' => JText::_('MOD_QUICKICON_TEMPLATE_MANAGER'),
  132. 'access' => array('core.manage', 'com_templates')
  133. ),
  134. );
  135. }
  136. return self::$buttons;
  137. }
  138. }