get('gid')) { switch ($user->get('usertype')) { case 'Super Administrator': $intUserType = 0; break; case 'Administrator': $intUserType = 1; break; case 'Editor': $intUserType = 2; break; case 'Registered': $intUserType = 3; break; case 'Author': $intUserType = 4; break; case 'Publisher': $intUserType = 5; break; case 'Manager': $intUserType = 6; break; } } else { $intUserType = 0; } if ($config->getValue('config.shonoauth')) { $query = "SELECT m.*, count(p.parent) as cnt" . " FROM #__menu AS m" . " LEFT JOIN #__menu AS p ON p.parent = m.id" . " WHERE m.menutype=".$db->Quote($menutype) . " AND m.published='1'" . " GROUP BY m.id" . " ORDER BY m.parent, m.ordering"; } else { $query = "SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt" . " FROM #__menu AS m" . " LEFT JOIN #__menu AS p ON p.parent = m.id" . " WHERE m.menutype=".$db->Quote($menutype) . " AND m.published='1'" . " AND m.access <= ".$user->get('gid') . " GROUP BY m.id" . " ORDER BY m.parent, m.ordering"; } $db->setQuery($query); $rows = $db->loadObjectList('id'); echo $db->getErrorMsg(); $query = "SELECT m.*" . " FROM #__menu AS m" . " WHERE menutype=".$db->Quote($menutype) . " AND m.published='1'"; $db->setQuery($query); $subrows = $db->loadObjectList('id'); $maxrecurse = 5; $parentid = $Itemid; //this makes sure toplevel stays hilighted when submenu active while ($maxrecurse-- > 0) { $parentid = getTheParentRow($subrows, $parentid); if (isset ($parentid) && $parentid >= 0 && $subrows[$parentid]) { $hilightid = $parentid; } else { break; } } echo "\n"; $indents = array(array("")); $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; myRecurseListMenu(0, 0, $children, $open, $indents, $class_sfx, $hilightid); } function myRecurseListMenu($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]; $current_itemid = $Itemid; if ($row->link != "seperator" && $current_itemid == $row->id || $row->id == $highlight || (JRoute::_(substr($_SERVER['PHP_SELF'], 0, -9) . $row->link)) == $_SERVER['REQUEST_URI'] || (JRoute::_(substr($_SERVER['PHP_SELF'], 0, -9) . $row->link)) == $HTTP_SERVER_VARS['REQUEST_URI']) { $li = "
  • "; } echo $li; echo myGetLink($row, $level, $class_sfx); myRecurseListMenu($row->id, $level +1, $children, $open, $indents, $class_sfx, ""); echo $indents[$n][2]; } echo "\n" . $indents[$n][3]; } } function getTheParentRow($rows, $id) { if (isset ($rows[$id]) && $rows[$id]) { if ($rows[$id]->parent > 0) { return $rows[$id]->parent; } } return -1; } function myGetLink($menulevel, $level, $class_sfx = '') { global $Itemid; $txt = ''; $menulevel->link = str_replace('&', '&', $menulevel->link); if (strcasecmp(substr($menulevel->link, 0, 4), "http")) { $menulevel->link = JRoute::_($menulevel->link); } switch ($menulevel->browserNav) { case 1 : if ($menulevel->cnt > 0) { if ($level == 0) { $txt = "link\">$menulevel->name"; } else { $txt = "link\">$menulevel->name"; } } else { $txt = "link\" target=\"_window\" >$menulevel->name\n"; } break; case 2 : if ($menulevel->cnt > 0) { if ($level == 0) { $txt = "link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$menulevel->name\n"; } else { $txt = "link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$menulevel->name\n"; } } else { $txt = "link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$menulevel->name\n"; } break; case 3 : if ($menulevel->cnt > 0) { if ($level == 0) { $txt = "$menulevel->name"; } else { $txt = "$menulevel->name"; } } else { $txt = "$menulevel->name\n"; } break; default : if (isset ($menulevel->cnt) && $menulevel->cnt > 0) { if ($level == 0) { $txt = "link\">$menulevel->name"; } else { $txt = "link\"> $menulevel->name"; } } else { $txt = "link\">$menulevel->name"; } break; } return $txt; }