function mosShowListMenu($menutype) { global $mainframe, $Itemid; $database = JFactory::getDBO(); $user = JFactory::getUser(); $class_sfx = null; $hilightid = null; if ($mainframe->getCfg('shownoauth')) { $sql = "SELECT m.*, count(p.parent) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1'" . "\nGROUP BY m.id ORDER BY m.parent, m.ordering "; } else { $sql = "SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" . "\nFROM #__menu AS m" . "\nLEFT JOIN #__menu AS p ON p.parent = m.id" . "\nWHERE m.menutype='{$menutype}' AND m.published='1' AND m.access <= " . $user->get('gid') . "\nGROUP BY m.id ORDER BY m.parent, m.ordering "; } $database->setQuery($sql); $rows = $database->loadObjectList('id'); echo $database->getErrorMsg(); $sql = "SELECT m.* FROM #__menu AS m" . "\nWHERE menutype='" . $menutype . "' AND m.published='1'"; $database->setQuery($sql); $subrows = $database->loadObjectList('id'); $maxrecurse = 5; $parentid = $Itemid; while ($maxrecurse-- > 0) { $parentid = getTheParentRow($subrows, $parentid); if (isset($parentid) && $parentid >= 0 && $subrows[$parentid]) { $hilightid = $parentid; } else { break; } } $indents = array(array('<ul id="navlist">', "\t<li>", '</li>', '</ul>'), array("\t\t<ul><li class='s5_toparrow'></li>", "\t\t\t<li class='noback'>", '</li>', "\t\t<li class='s5_menubottom'></li></ul>"), array("\t\t<ul><li class='s5_menutop'></li>", "\t\t\t<li>", '</li>', "\t\t<li class='s5_menubottom'></li></ul>"), array("\t\t\t<ul><li class='s5_menutop'></li>", "\t\t\t\t<li>", '</li>', "\t\t\t<li class='s5_menubottom'></li></ul>"), array("\t\t\t\t<ul><li class='s5_menutop'></li>", "\t\t\t\t\t<li>", '</li>', "\t\t\t\t<li class='s5_menubottom'></li></ul>")); $children = array(); foreach ($rows as $v) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } $open = array($Itemid); $count = 20; // maximum levels - to prevent runaway loop $id = $Itemid; while (--$count) { if (isset($rows[$id]) && $rows[$id]->parent > 0) { $id = $rows[$id]->parent; $open[] = $id; } else { break; } } $class_sfx = null; mosRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid); }
/** * Utility function to recursively work through a vertically indented * hierarchial menu */ function mosRecurseListMenu($id, $level, &$children, $open, &$indents, $class_sfx, $highlight) { global $Itemid; global $HTTP_SERVER_VARS, $mosConfig_live_site; if (@$children[$id]) { $n = min($level, count($indents) - 1); echo $indents[$n][0]; foreach ($children[$id] as $row) { switch ($row->type) { case 'separator': // do nothing $row->link = "seperator"; break; case 'url': if (eregi('index.php\\?', $row->link)) { if (!eregi('Itemid=', $row->link)) { $row->link .= '&Itemid=' . $row->id; } } break; default: $row->link .= "&Itemid={$row->id}"; break; } $li = "\n" . $indents[$n][1]; /* ANDROMEDA CHANGE */ if (defined('_ANDROMEDA_JOOMLA')) { $current_itemid = ''; if ($row->id == SessionGet('AGMENU_MODULE')) { if (vgfGet('menu_mode') != 'x4') { $li = "<li class='active'>"; } } } else { $current_itemid = trim(mosGetParam($_REQUEST, 'Itemid', 0)); if ($row->link != "seperator" && $current_itemid == $row->id || $row->id == $highlight || sefRelToAbs(substr($_SERVER['PHP_SELF'], 0, -9) . $row->link) == $_SERVER['REQUEST_URI'] || sefRelToAbs(substr($_SERVER['PHP_SELF'], 0, -9) . $row->link) == $HTTP_SERVER_VARS['REQUEST_URI']) { $li = "<li class='active'>"; } } echo $li; // KFD change 4/9/07, AJAX-ification effort //echo hjxCheckFirst($row->name,$row->link); //txt = "<a href=\"$mitem->link\">$mitem->name</a>"; echo mosGetLink($row, $level, $class_sfx); mosRecurseListMenu($row->id, $level + 1, $children, $open, $indents, $class_sfx, ""); echo $indents[$n][2]; } echo "\n" . $indents[$n][3]; } }