| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: menu.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage HTML 6 * @copyright Copyright (C) 2005 - 2010 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 // no direct access 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 /** 19 * Utility class working with menu select lists 20 * 21 * @static 22 * @package Joomla.Framework 23 * @subpackage HTML 24 * @since 1.5 25 */ 26 class JHTMLMenu 27 { 28 /** 29 * Build the select list for Menu Ordering 30 */ 31 function ordering( &$row, $id ) 32 { 33 $db =& JFactory::getDBO(); 34 35 if ( $id ) 36 { 37 $query = 'SELECT ordering AS value, name AS text' 38 . ' FROM #__menu' 39 . ' WHERE menutype = '.$db->Quote($row->menutype) 40 . ' AND parent = '.(int) $row->parent 41 . ' AND published != -2' 42 . ' ORDER BY ordering'; 43 $order = JHTML::_('list.genericordering', $query ); 44 $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); 45 } 46 else 47 { 48 $ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. JText::_( 'DESCNEWITEMSLAST' ); 49 } 50 return $ordering; 51 } 52 53 /** 54 * Build the multiple select list for Menu Links/Pages 55 */ 56 function linkoptions( $all=false, $unassigned=false ) 57 { 58 $db =& JFactory::getDBO(); 59 60 // get a list of the menu items 61 $query = 'SELECT m.id, m.parent, m.name, m.menutype' 62 . ' FROM #__menu AS m' 63 . ' WHERE m.published = 1' 64 . ' ORDER BY m.menutype, m.parent, m.ordering' 65 ; 66 $db->setQuery( $query ); 67 $mitems = $db->loadObjectList(); 68 $mitems_temp = $mitems; 69 70 // establish the hierarchy of the menu 71 $children = array(); 72 // first pass - collect children 73 foreach ( $mitems as $v ) 74 { 75 $id = $v->id; 76 $pt = $v->parent; 77 $list = @$children[$pt] ? $children[$pt] : array(); 78 array_push( $list, $v ); 79 $children[$pt] = $list; 80 } 81 // second pass - get an indent list of the items 82 $list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); 83 84 // Code that adds menu name to Display of Page(s) 85 $mitems_spacer = $mitems_temp[0]->menutype; 86 87 $mitems = array(); 88 if ($all | $unassigned) { 89 $mitems[] = JHTML::_('select.option', '<OPTGROUP>', JText::_( 'Menus' ) ); 90 91 if ( $all ) { 92 $mitems[] = JHTML::_('select.option', 0, JText::_( 'All' ) ); 93 } 94 if ( $unassigned ) { 95 $mitems[] = JHTML::_('select.option', -1, JText::_( 'Unassigned' ) ); 96 } 97 98 $mitems[] = JHTML::_('select.option', '</OPTGROUP>' ); 99 } 100 101 $lastMenuType = null; 102 $tmpMenuType = null; 103 foreach ($list as $list_a) 104 { 105 if ($list_a->menutype != $lastMenuType) 106 { 107 if ($tmpMenuType) { 108 $mitems[] = JHTML::_('select.option', '</OPTGROUP>' ); 109 } 110 $mitems[] = JHTML::_('select.option', '<OPTGROUP>', $list_a->menutype ); 111 $lastMenuType = $list_a->menutype; 112 $tmpMenuType = $list_a->menutype; 113 } 114 115 $mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename ); 116 } 117 if ($lastMenuType !== null) { 118 $mitems[] = JHTML::_('select.option', '</OPTGROUP>' ); 119 } 120 121 return $mitems; 122 } 123 124 function treerecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) 125 { 126 if (@$children[$id] && $level <= $maxlevel) 127 { 128 foreach ($children[$id] as $v) 129 { 130 $id = $v->id; 131 132 if ( $type ) { 133 $pre = '<sup>|_</sup> '; 134 $spacer = '. '; 135 } else { 136 $pre = '- '; 137 $spacer = ' '; 138 } 139 140 if ( $v->parent == 0 ) { 141 $txt = $v->name; 142 } else { 143 $txt = $pre . $v->name; 144 } 145 $pt = $v->parent; 146 $list[$id] = $v; 147 $list[$id]->treename = "$indent$txt"; 148 $list[$id]->children = count( @$children[$id] ); 149 $list = JHTMLMenu::TreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type ); 150 } 151 } 152 return $list; 153 } 154 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |