';
else
echo $indents[$n][0];
foreach ($children[$id] as $row) {
switch ($row->type) {
case 'separator':
$row->link = "javascript:;";
break;
case 'url':
if ($row->link == "javascript:;") {
$row->link = "javascript:;";
}
else {
$row->link .= "";
}
break;
default:
$row->link .= "&Itemid=$row->id";
break;
}
$li = "\n".$indents[$n][1] ;
$current_itemid = trim( JRequest::getVar( 'Itemid', 0 ) );
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']) {
if ($row->type != "url") {
$li = "
";
}
}
echo $li;
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];
}
}
function getTheParentRow($rows, $id) {
if (isset($rows[$id]) && $rows[$id]) {
if($rows[$id]->parent > 0) {
return $rows[$id]->parent;
}
}
return -1;
}
function mosGetLink( $mitem, $level, $class_sfx='' ) {
global $Itemid;
$txt = '';
$menuclass = '';
$main = 'top';
$router = JSite::getRouter();
$mitem->url2 = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$mitem->id : $mitem->link.'&Itemid='.$mitem->id;
JRoute::_('$mitem->link');
$menui = 'true';
if ($menui == 'true')
{
$menu_params = new stdClass();
$menu_params = new JParameter($mitem->params);
}
if ($mitem->url2{10} == "I") {
if ($mitem->type != "url" && $mitem->type != "separator") {
$sef_suf =& JFactory::getApplication();
$sef_value = $sef_suf->getCfg('sef_suffix');
$mitem->link = JRoute::_($mitem->alias);
if ($sef_value == "1") {
$mitem->link = "$mitem->link.html";
$router = JSite::getRouter();
$mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$mitem->id : $mitem->link.'&Itemid='.$mitem->id;
}
else if ($sef_value == "0") {
$router = JSite::getRouter();
$mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$mitem->id : $mitem->link.'&Itemid='.$mitem->id;
}
else {
$mitem->link = $mitem->link;
}
}
}
$s5_check_itemid = strrpos($mitem->link,"frontpage&Itemid=1");
if ($s5_check_itemid > 1) {
$mitem->link = "";
}
switch ($mitem->browserNav) {
case 1:
if ($mitem->cnt > 0) {
if ($level == 0) {
$txt = "link\">$mitem->name";
$main = "main";
} else {
$txt = "link\">$mitem->name";
}
} else {
$txt = "link\" class=\"sub\" target=\"_window\" >$mitem->name\n";
}
break;
case 2:
if ($mitem->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\">$mitem->name\n";
$main = "main";
} else {
$txt = "link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$mitem->name\n";
}
} else {
$txt = "link', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$mitem->name\n";
}
break;
case 3:
if ($mitem->cnt > 0) {
if ($level == 0) {
$txt = "$mitem->name";
$main = "main";
} else {
$txt = "$mitem->name";
}
} else {
$txt = "$mitem->name\n";
}
break;
default:
if (isset($mitem->cnt) && $mitem->cnt > 0) {
$random = (rand()%30000000000000);
if ($level == 0) {
$txt = "link\">$mitem->name";
$main = "main";
} else {
$txt = "link\"> $mitem->name";
}
} else {
if ($level == 0) {
$txt = "link\">$mitem->name";
}
else if ($level > 0) {
$txt = "link\">$mitem->name";
}
}
break;
}
return $txt;
}
ini_set('arg_separator.output','&');
function mosShowListMenu($menutype) {
global $app, $Itemid;
$database = JFactory::getDBO();
$user = JFactory::getUser();
$class_sfx = null;
$hilightid = null;
if ($app->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') . // Picks up the access-id
"\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( '' ),
array( "\t\t" ),
array( "\t\t" ),
array( "\t\t\t", "\t\t\t\t- " , '
', "\t\t\t
" ),
array( "\t\t\t\t", "\t\t\t\t\t- " , '
', "\t\t\t\t
" ),
);
$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 );
}
?>