PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/modules/mod_quickicon/helper.php

https://github.com/cosmocommerce/joomla
PHP | 114 lines | 79 code | 8 blank | 27 comment | 4 complexity | b3f7ecd262b9fe2350b6b891cd74662b MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7. // Check to ensure this file is included in Joomla!
  8. defined('_JEXEC') or die;
  9. /**
  10. * @package Joomla.Administrator
  11. * @subpackage mod_quickicon
  12. */
  13. abstract class QuickIconHelper
  14. {
  15. /**
  16. * Stack to hold default buttons
  17. */
  18. protected static $buttons = array();
  19. /**
  20. * Helper method to generate a button in administrator panel
  21. *
  22. * @param array A named array with keys link, image, text, access and imagePath
  23. * @return string HTML for button
  24. */
  25. public static function button($button)
  26. {
  27. if (!empty($button['access']))
  28. {
  29. if (!JFactory::getUser()->authorize($button['access'])) {
  30. return '';
  31. }
  32. }
  33. if (empty($button['imagePath']))
  34. {
  35. $template = JFactory::getApplication()->getTemplate();
  36. $button['imagePath'] = '/templates/'. $template .'/images/header/';
  37. }
  38. ob_start();
  39. require JModuleHelper::getLayoutPath('mod_quickicon', 'button');
  40. $html = ob_get_clean();
  41. return $html;
  42. }
  43. /**
  44. * Helper method to return button list.
  45. *
  46. * This method returns the array by reference so it can be
  47. * used to add custom buttons or remove default ones.
  48. *
  49. * @return array An array of buttons
  50. */
  51. public static function &getButtons()
  52. {
  53. if (empty(self::$buttons))
  54. {
  55. self::$buttons = array(
  56. array(
  57. 'link' => JRoute::_('index.php?option=com_content&task=article.add'),
  58. 'image' => 'icon-48-article-add.png',
  59. 'text' => JText::_('MOD_QUICKICON_ADD_NEW_ARTICLE')
  60. ),
  61. array(
  62. 'link' => JRoute::_('index.php?option=com_content'),
  63. 'image' => 'icon-48-article.png',
  64. 'text' => JText::_('MOD_QUICKICON_ARTICLE_MANAGER')
  65. ),
  66. array(
  67. 'link' => JRoute::_('index.php?option=com_categories&extension=com_content'),
  68. 'image' => 'icon-48-category.png',
  69. 'text' => JText::_('MOD_QUICKICON_CATEGORY_MANAGER')
  70. ),
  71. array(
  72. 'link' => JRoute::_('index.php?option=com_media'),
  73. 'image' => 'icon-48-media.png',
  74. 'text' => JText::_('MOD_QUICKICON_MEDIA_MANAGER')
  75. ),
  76. array(
  77. 'link' => JRoute::_('index.php?option=com_menus'),
  78. 'image' => 'icon-48-menumgr.png',
  79. 'text' => JText::_('MOD_QUICKICON_MENU_MANAGER'),
  80. 'access' => 'core.menus.manage'
  81. ),
  82. array(
  83. 'link' => JRoute::_('index.php?option=com_users'),
  84. 'image' => 'icon-48-user.png',
  85. 'text' => JText::_('MOD_QUICKICON_USER_MANAGER'),
  86. 'access' => 'core.users.manage'
  87. ),
  88. array(
  89. 'link' => JRoute::_('index.php?option=com_modules'),
  90. 'image' => 'icon-48-module.png',
  91. 'text' => JText::_('MOD_QUICKICON_MODULE_MANAGER'),
  92. ),
  93. array(
  94. 'link' => JRoute::_('index.php?option=com_installer'),
  95. 'image' => 'icon-48-extension.png',
  96. 'text' => JText::_('MOD_QUICKICON_EXTENSION_MANAGER'),
  97. ),array(
  98. 'link' => JRoute::_('index.php?option=com_languages'),
  99. 'image' => 'icon-48-language.png',
  100. 'text' => JText::_('MOD_QUICKICON_LANGUAGE_MANAGER'),
  101. )
  102. );
  103. }
  104. return self::$buttons;
  105. }
  106. }