Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/html/parameter/element/menuitem.php

Documentation is available at menuitem.php

  1. <?php
  2. /**
  3. @version        $Id: menuitem.php 6612 2007-02-13 00:47:52Z Jinx $
  4. @package        Joomla.Framework
  5. @subpackage    Parameter
  6. @copyright    Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * Renders a menu item element
  20.  *
  21.  * @author         Louis Landry <[email protected]>
  22.  * @package     Joomla.Framework
  23.  * @subpackage        Parameter
  24.  * @since        1.5
  25.  */
  26.  
  27. class JElementMenuItem extends JElement
  28. {
  29.    /**
  30.     * Element name
  31.     *
  32.     * @access    protected
  33.     * @var        string 
  34.     */
  35.     var    $_name = 'MenuItem';
  36.  
  37.     function fetchElement($name$value&$node$control_name)
  38.     {
  39.         $db =JFactory::getDBO();
  40.  
  41.         $menuType $this->_parent->get('menu_type');
  42.         if (!empty($menuType)) {
  43.             $where ' WHERE menutype = "'.$menuType."'";
  44.         else {
  45.             $where ' WHERE 1';
  46.         }
  47.  
  48.         // load the list of menu types
  49.         // TODO: move query to model
  50.         $query 'SELECT menutype, title' .
  51.                 ' FROM #__menu_types' .
  52.                 ' ORDER BY title';
  53.         $db->setQuery$query );
  54.         $menuTypes $db->loadObjectList();
  55.  
  56.         if ($state $node->attributes('state')) {
  57.             $where .= ' AND published = "'.$state.'"';
  58.         }
  59.  
  60.         // load the list of menu items
  61.         // TODO: move query to model
  62.         $query 'SELECT id, parent, name, menutype' .
  63.                 ' FROM #__menu' .
  64.                 $where .
  65.                 ' ORDER BY menutype, parent, ordering'
  66.                 ;
  67.  
  68.         $db->setQuery($query);
  69.         $menuItems $db->loadObjectList();
  70.  
  71.         // establish the hierarchy of the menu
  72.         // TODO: use node model
  73.         $children array();
  74.  
  75.         if ($menuItems{
  76.             // first pass - collect children
  77.             foreach ($menuItems as $v{
  78.                 $pt     $v->parent;
  79.                 $list     @$children[$pt$children[$ptarray();
  80.                 array_push$list$v );
  81.                 $children[$pt$list;
  82.             }
  83.         }
  84.  
  85.         // second pass - get an indent list of the items
  86.         $list mosTreeRecurse0''array()$children99990);
  87.  
  88.         // assemble into menutype groups
  89.         $n count$list );
  90.         $groupedList array();
  91.         foreach ($list as $k => $v)
  92.         {
  93.             $groupedList[$v->menutype][&$list[$k];
  94.         }
  95.  
  96.         // assemble menu items to the array
  97.         $options     array();
  98.         $options[]    JHTMLSelect::option('''- '.JText::_('Select Item').' -');
  99.  
  100.         foreach ($menuTypes as $type)
  101.         {
  102.             if ($menuType == '')
  103.             {
  104.                 $options[]    JHTMLSelect::option'0''&nbsp;' );
  105.                 $options[]    JHTMLSelect::option$type->menutype$type->title ' - ' JText::_'Top' ) );
  106.             }
  107.             if (isset$groupedList[$type->menutype))
  108.             {
  109.                 $n count$groupedList[$type->menutype);
  110.                 for ($i 0$i $n$i++)
  111.                 {
  112.                     $item &$groupedList[$type->menutype][$i];
  113.                     $options[JHTMLSelect::option$item->id'&nbsp;&nbsp;&nbsp;' .$item->treename );
  114.  
  115.                 }
  116.             }
  117.         }
  118.  
  119.         return JHTMLSelect::genericList($options''.$control_name.'['.$name.']''class="inputbox"''value''text'$value$control_name.$name);
  120.     }
  121. }
  122. ?>

Documentation generated on Mon, 05 Mar 2007 21:10:37 +0000 by phpDocumentor 1.3.1