Source for file menus.php

Documentation is available at menus.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_menus
  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. JLoader::register('MenusHelper'JPATH_ADMINISTRATOR '/components/com_menus/helpers/menus.php');
  13.  
  14. /**
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_menus
  17.  */
  18. abstract class MenusHtmlMenus
  19. {
  20.     /**
  21.      * @param   int $itemid    The menu item id
  22.      */
  23.     public static function association($itemid)
  24.     {
  25.         // Defaults
  26.         $html '';
  27.  
  28.         // Get the associations
  29.         if ($associations MenusHelper::getAssociations($itemid))
  30.         {
  31.             // Get the associated menu items
  32.             $db JFactory::getDbo();
  33.             $query $db->getQuery(true)
  34.                 ->select('m.id, m.title')
  35.                 ->select('l.sef as lang_sef')
  36.                 ->select('mt.title as menu_title')
  37.                 ->from('#__menu as m')
  38.                 ->join('LEFT''#__menu_types as mt ON mt.menutype=m.menutype')
  39.                 ->where('m.id IN (' implode(','array_values($associations)) ')')
  40.                 ->join('LEFT''#__languages as l ON m.language=l.lang_code')
  41.                 ->select('l.image')
  42.                 ->select('l.title as language_title');
  43.             $db->setQuery($query);
  44.  
  45.             try
  46.             {
  47.                 $items $db->loadObjectList('id');
  48.             }
  49.             catch (runtimeException $e)
  50.             {
  51.                 throw new Exception($e->getMessage()500);
  52.             }
  53.  
  54.             // Construct html
  55.             if ($items)
  56.             {
  57.                 foreach ($items as &$item)
  58.                 {
  59.                     $text strtoupper($item->lang_sef);
  60.                     $url JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id);
  61.                     $tooltipParts array(
  62.                         JHtml::_('image''mod_languages/' $item->image '.gif',
  63.                             $item->language_title,
  64.                             array('title' => $item->language_title),
  65.                             true
  66.                         ),
  67.                         $item->title,
  68.                         '(' $item->menu_title ')'
  69.                     );
  70.                     $item->link JHtml::_('tooltip'implode(' '$tooltipParts)nullnull$text$urlnull'hasTooltip label label-association label-' $item->lang_sef);
  71.                 }
  72.             }
  73.  
  74.             $html JLayoutHelper::render('joomla.content.associations'$items);
  75.         }
  76.  
  77.         return $html;
  78.     }
  79.  
  80.     /**
  81.      * Returns a published state on a grid
  82.      *
  83.      * @param   integer       $value            The state value.
  84.      * @param   integer       $i                The row index
  85.      * @param   boolean       $enabled            An optional setting for access control on the action.
  86.      * @param   string        $checkbox            An optional prefix for checkboxes.
  87.      *
  88.      * @return  string        The Html code
  89.      *
  90.      * @see JHtmlJGrid::state
  91.      *
  92.      * @since   1.7.1
  93.      */
  94.     public static function state($value$i$enabled true$checkbox 'cb')
  95.     {
  96.         $states    array(
  97.             9    => array(
  98.                 'unpublish',
  99.                 '',
  100.                 'COM_MENUS_HTML_UNPUBLISH_HEADING',
  101.                 '',
  102.                 false,
  103.                 'publish',
  104.                 'publish'
  105.             ),
  106.             8    => array(
  107.                 'publish',
  108.                 '',
  109.                 'COM_MENUS_HTML_PUBLISH_HEADING',
  110.                 '',
  111.                 false,
  112.                 'unpublish',
  113.                 'unpublish'
  114.             ),
  115.             7    => array(
  116.                 'unpublish',
  117.                 '',
  118.                 'COM_MENUS_HTML_UNPUBLISH_SEPARATOR',
  119.                 '',
  120.                 false,
  121.                 'publish',
  122.                 'publish'
  123.             ),
  124.             6    => array(
  125.                 'publish',
  126.                 '',
  127.                 'COM_MENUS_HTML_PUBLISH_SEPARATOR',
  128.                 '',
  129.                 false,
  130.                 'unpublish',
  131.                 'unpublish'
  132.             ),
  133.             5    => array(
  134.                 'unpublish',
  135.                 '',
  136.                 'COM_MENUS_HTML_UNPUBLISH_ALIAS',
  137.                 '',
  138.                 false,
  139.                 'publish',
  140.                 'publish'
  141.             ),
  142.             4    => array(
  143.                 'publish',
  144.                 '',
  145.                 'COM_MENUS_HTML_PUBLISH_ALIAS',
  146.                 '',
  147.                 false,
  148.                 'unpublish',
  149.                 'unpublish'
  150.             ),
  151.             3    => array(
  152.                 'unpublish',
  153.                 '',
  154.                 'COM_MENUS_HTML_UNPUBLISH_URL',
  155.                 '',
  156.                 false,
  157.                 'publish',
  158.                 'publish'
  159.             ),
  160.             2    => array(
  161.                 'publish',
  162.                 '',
  163.                 'COM_MENUS_HTML_PUBLISH_URL',
  164.                 '',
  165.                 false,
  166.                 'unpublish',
  167.                 'unpublish'
  168.             ),
  169.             1    => array(
  170.                 'unpublish',
  171.                 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
  172.                 'COM_MENUS_HTML_UNPUBLISH_ENABLED',
  173.                 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED',
  174.                 true,
  175.                 'publish',
  176.                 'publish'
  177.             ),
  178.             0    => array(
  179.                 'publish',
  180.                 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
  181.                 'COM_MENUS_HTML_PUBLISH_ENABLED',
  182.                 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED',
  183.                 true,
  184.                 'unpublish',
  185.                 'unpublish'
  186.             ),
  187.             -1    => array(
  188.                 'unpublish',
  189.                 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
  190.                 'COM_MENUS_HTML_UNPUBLISH_DISABLED',
  191.                 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED',
  192.                 true,
  193.                 'warning',
  194.                 'warning'
  195.             ),
  196.             -2    => array(
  197.                 'publish',
  198.                 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
  199.                 'COM_MENUS_HTML_PUBLISH_DISABLED',
  200.                 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED',
  201.                 true,
  202.                 'unpublish',
  203.                 'unpublish'
  204.             ),
  205.         );
  206.  
  207.         return JHtml::_('jgrid.state'$states$value$i'items.'$enabledtrue$checkbox);
  208.     }
  209. }

Documentation generated on Tue, 19 Nov 2013 15:07:58 +0100 by phpDocumentor 1.4.3