/administrator/components/com_menus/helpers/html/menus.php

https://github.com/gnomeontherun/joomla-cms · PHP · 174 lines · 135 code · 8 blank · 31 comment · 2 complexity · 111678a9b219b2b8135742cba75945ee MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage com_menus
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
  11. /**
  12. * @package Joomla.Administrator
  13. * @subpackage com_menus
  14. */
  15. abstract class MenusHtmlMenus
  16. {
  17. /**
  18. * @param int $itemid The menu item id
  19. */
  20. public static function association($itemid)
  21. {
  22. // Get the associations
  23. $associations = MenusHelper::getAssociations($itemid);
  24. // Get the associated menu items
  25. $db = JFactory::getDbo();
  26. $query = $db->getQuery(true);
  27. $query->select('m.*');
  28. $query->select('mt.title as menu_title');
  29. $query->from('#__menu as m');
  30. $query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype');
  31. $query->where('m.id IN ('.implode(',', array_values($associations)).')');
  32. $query->leftJoin('#__languages as l ON m.language=l.lang_code');
  33. $query->select('l.image');
  34. $query->select('l.title as language_title');
  35. $db->setQuery($query);
  36. try
  37. {
  38. $items = $db->loadObjectList('id');
  39. }
  40. catch (RuntimeException $e)
  41. {
  42. JError::raiseWarning(500, $e->getMessage());
  43. return false;
  44. }
  45. // Construct html
  46. $text = array();
  47. foreach ($associations as $tag => $associated)
  48. {
  49. if ($associated != $itemid)
  50. {
  51. $text[] = JText::sprintf('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/' . $items[$associated]->image . '.gif', $items[$associated]->language_title, array('title' => $items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title);
  52. }
  53. }
  54. return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png');
  55. }
  56. /**
  57. * Returns a published state on a grid
  58. *
  59. * @param integer $value The state value.
  60. * @param integer $i The row index
  61. * @param boolean $enabled An optional setting for access control on the action.
  62. * @param string $checkbox An optional prefix for checkboxes.
  63. *
  64. * @return string The Html code
  65. *
  66. * @see JHtmlJGrid::state
  67. *
  68. * @since 1.7.1
  69. */
  70. public static function state($value, $i, $enabled = true, $checkbox = 'cb')
  71. {
  72. $states = array(
  73. 7 => array(
  74. 'unpublish',
  75. '',
  76. 'COM_MENUS_HTML_UNPUBLISH_SEPARATOR',
  77. '',
  78. false,
  79. 'publish',
  80. 'publish'
  81. ),
  82. 6 => array(
  83. 'publish',
  84. '',
  85. 'COM_MENUS_HTML_PUBLISH_SEPARATOR',
  86. '',
  87. false,
  88. 'unpublish',
  89. 'unpublish'
  90. ),
  91. 5 => array(
  92. 'unpublish',
  93. '',
  94. 'COM_MENUS_HTML_UNPUBLISH_ALIAS',
  95. '',
  96. false,
  97. 'publish',
  98. 'publish'
  99. ),
  100. 4 => array(
  101. 'publish',
  102. '',
  103. 'COM_MENUS_HTML_PUBLISH_ALIAS',
  104. '',
  105. false,
  106. 'unpublish',
  107. 'unpublish'
  108. ),
  109. 3 => array(
  110. 'unpublish',
  111. '',
  112. 'COM_MENUS_HTML_UNPUBLISH_URL',
  113. '',
  114. false,
  115. 'publish',
  116. 'publish'
  117. ),
  118. 2 => array(
  119. 'publish',
  120. '',
  121. 'COM_MENUS_HTML_PUBLISH_URL',
  122. '',
  123. false,
  124. 'unpublish',
  125. 'unpublish'
  126. ),
  127. 1 => array(
  128. 'unpublish',
  129. 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
  130. 'COM_MENUS_HTML_UNPUBLISH_ENABLED',
  131. 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
  132. true,
  133. 'publish',
  134. 'publish'
  135. ),
  136. 0 => array(
  137. 'publish',
  138. 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
  139. 'COM_MENUS_HTML_PUBLISH_ENABLED',
  140. 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
  141. true,
  142. 'unpublish',
  143. 'unpublish'
  144. ),
  145. -1 => array(
  146. 'unpublish',
  147. 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
  148. 'COM_MENUS_HTML_UNPUBLISH_DISABLED',
  149. 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
  150. true,
  151. 'warning',
  152. 'warning'
  153. ),
  154. -2 => array(
  155. 'publish',
  156. 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
  157. 'COM_MENUS_HTML_PUBLISH_DISABLED',
  158. 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
  159. true,
  160. 'unpublish',
  161. 'unpublish'
  162. ),
  163. );
  164. return JHtml::_('jgrid.state', $states, $value, $i, 'items.', $enabled, true, $checkbox);
  165. }
  166. }