function _getMenuData(&$params) { $menu = new GantryMenuTree(); $menu->_params =& $params; $items =& JSite::getMenu(); // Get Menu Items $rows = $items->getItems('menutype', $params->get('menutype')); $maxdepth = $menu->getParameter('endLevel', 10); // Build Menu Tree root down (orphan proof - child might have lower id than parent) $user =& JFactory::getUser(); $ids = array(); $ids[0] = true; $last = null; $unresolved = array(); // pop the first item until the array is empty if there is any item if (is_array($rows)) { while (count($rows) && !is_null($row = array_shift($rows))) { $row->ionly = $params->get('menu_images_link'); if (!$menu->addNode($params, $row)) { if (!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth) { array_push($rows, $row); if (!isset($unresolved[$row->id])) { $unresolved[$row->id] = 1; } else { $unresolved[$row->id]++; } } } } } return $menu; }
function _getItemData(&$params, $item) { //Create the new Node $node = new GantryMenuNode(); $tmp = null; // Menu Link is a special type that is a link to another item if ($item->type == 'menulink') { $menu =& JSite::getMenu(); if ($newItem = $menu->getItem($item->query['Itemid'])) { $tmp = clone $newItem; $tmp->name = addslashes(htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')); $tmp->mid = $item->id; $tmp->parent_id = $item->parent_id; $tmp->params = $item->params; $tmp->url = null; $tmp->nav = 'current'; $tmp->menualias = true; } } if ($item->type != 'menulink' || $item->type == 'menulink' && $tmp == null) { $tmp = clone $item; $tmp->name = addslashes(htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')); $tmp->mid = $tmp->id; $tmp->url = null; $tmp->nav = 'current'; $tmp->menualias = false; } $iParams = new JParameter($tmp->params); if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) { $image = JURI::base(true) . '/images/stories/' . $iParams->get('menu_image'); if ($tmp->ionly) { $tmp->name = null; } } else { $image = null; } switch ($tmp->type) { case 'separator': $tmp->outtype = 'separator'; break; case 'url': if (strpos($tmp->link, 'index.php?') === 0 && strpos($tmp->link, 'Itemid=') === false) { $tmp->url = $tmp->link . '&Itemid=' . $tmp->id; } else { $tmp->url = $tmp->link; } $tmp->outtype = 'menuitem'; break; default: $router = JSite::getRouter(); $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id; $tmp->outtype = 'menuitem'; break; } if ($tmp->url != null) { // set the target based on menu item options switch ($tmp->browserNav) { case 0: $tmp->nav = 'current'; break; case 1: $tmp->nav = 'new'; break; case 2: $tmp->url = str_replace('index.php', 'index2.php', $tmp->url); $tmp->nav = 'newnotool'; break; default: $tmp->nav = 'current'; break; } // Get the final URL if ($tmp->home == 1) { // Set Home Links to the Base $tmp->url = JURI::base(); } if ($tmp->type != 'separator' && $tmp->type != 'url') { $iSecure = $iParams->get('secure', 0); if ($this->_params->get('url_type', 'relative') == 'full') { $url = JRoute::_($tmp->url, true, $iSecure); $base = !preg_match("/^http/", $tmp->url) ? preg_replace("#/\$#", "", JURI::base(false)) : ''; $routed = $base . $url; $secure = GantryMenuTree::_getSecureUrl($routed, $iSecure); $tmp->url = $secure; } else { $tmp->url = JRoute::_($tmp->url, true, $iSecure); } } else { if ($tmp->type == 'url') { $tmp->url = str_replace('&', '&', $tmp->url); } else { } } } $node->id = $tmp->mid; $node->parent = $tmp->parent_id; $node->title = $tmp->name; $node->access = $tmp->access; $node->link = $tmp->url; $node->level = $item->level; $node->image = $image; $node->alias = $tmp->alias; $node->nav = $tmp->nav; $node->displayType = $tmp->browserNav; $node->setParameters($tmp->params); $node->type = $tmp->outtype; //$node->order = $item->ordering; $node->addListItemClass("item" . $node->id); $node->addSpanClass($tmp->outtype); return $node; }