Files
@ 7ec91347b83f
Branch filter:
Location: hot67beta/libraries/joomla/html/html/menu.php
7ec91347b83f
4.1 KiB
text/x-php
there we go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | <?php
/**
* @version $Id: menu.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla.Framework
* @subpackage HTML
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* Utility class working with menu select lists
*
* @static
* @package Joomla.Framework
* @subpackage HTML
* @since 1.5
*/
class JHTMLMenu
{
/**
* Build the select list for Menu Ordering
*/
function ordering( &$row, $id )
{
$db =& JFactory::getDBO();
if ( $id )
{
$query = 'SELECT ordering AS value, name AS text'
. ' FROM #__menu'
. ' WHERE menutype = '.$db->Quote($row->menutype)
. ' AND parent = '.(int) $row->parent
. ' AND published != -2'
. ' ORDER BY ordering';
$order = JHTML::_('list.genericordering', $query );
$ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) );
}
else
{
$ordering = '<input type="hidden" name="ordering" value="'. $row->ordering .'" />'. JText::_( 'DESCNEWITEMSLAST' );
}
return $ordering;
}
/**
* Build the multiple select list for Menu Links/Pages
*/
function linkoptions( $all=false, $unassigned=false )
{
$db =& JFactory::getDBO();
// get a list of the menu items
$query = 'SELECT m.id, m.parent, m.name, m.menutype'
. ' FROM #__menu AS m'
. ' WHERE m.published = 1'
. ' ORDER BY m.menutype, m.parent, m.ordering'
;
$db->setQuery( $query );
$mitems = $db->loadObjectList();
$mitems_temp = $mitems;
// establish the hierarchy of the menu
$children = array();
// first pass - collect children
foreach ( $mitems as $v )
{
$id = $v->id;
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
// second pass - get an indent list of the items
$list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 );
// Code that adds menu name to Display of Page(s)
$mitems_spacer = $mitems_temp[0]->menutype;
$mitems = array();
if ($all | $unassigned) {
$mitems[] = JHTML::_('select.option', '<OPTGROUP>', JText::_( 'Menus' ) );
if ( $all ) {
$mitems[] = JHTML::_('select.option', 0, JText::_( 'All' ) );
}
if ( $unassigned ) {
$mitems[] = JHTML::_('select.option', -1, JText::_( 'Unassigned' ) );
}
$mitems[] = JHTML::_('select.option', '</OPTGROUP>' );
}
$lastMenuType = null;
$tmpMenuType = null;
foreach ($list as $list_a)
{
if ($list_a->menutype != $lastMenuType)
{
if ($tmpMenuType) {
$mitems[] = JHTML::_('select.option', '</OPTGROUP>' );
}
$mitems[] = JHTML::_('select.option', '<OPTGROUP>', $list_a->menutype );
$lastMenuType = $list_a->menutype;
$tmpMenuType = $list_a->menutype;
}
$mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename );
}
if ($lastMenuType !== null) {
$mitems[] = JHTML::_('select.option', '</OPTGROUP>' );
}
return $mitems;
}
function treerecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 )
{
if (@$children[$id] && $level <= $maxlevel)
{
foreach ($children[$id] as $v)
{
$id = $v->id;
if ( $type ) {
$pre = '<sup>|_</sup> ';
$spacer = '. ';
} else {
$pre = '- ';
$spacer = ' ';
}
if ( $v->parent == 0 ) {
$txt = $v->name;
} else {
$txt = $pre . $v->name;
}
$pt = $v->parent;
$list[$id] = $v;
$list[$id]->treename = "$indent$txt";
$list[$id]->children = count( @$children[$id] );
$list = JHTMLMenu::TreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type );
}
}
return $list;
}
}
|