function getMenuData(&$params) { $menu = new RokNavMenuTree(); $menu->_params =& $params; $items =& JSite::getMenu(); // Get Menu Items $rows = $items->getItems('menutype', $params->get('menutype')); $maxdepth = $menu->getParameter('maxdepth', 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 getMenuData(&$params) { $menu = new RokNavMenuTree(); $menu->_params =& $params; $items =& JSite::getMenu(); // Get Menu Items $rows = $items->getItems('menutype', $params->get('menutype')); $maxdepth = $menu->getParameter('maxdepth', 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)) { // no parent yet so push item to back of list // SAM: But if the key isn't in the list and we dont _add_ this is infinite, so check the unresolved queue if (!array_key_exists($row->id, $unresolved) || $unresolved[$row->id] < $maxdepth) { array_push($rows, $row); // so let us do max $maxdepth passes // TODO: Put a time check in this loop in case we get too close to the PHP timeout if (!isset($unresolved[$row->id])) { $unresolved[$row->id] = 1; } else { $unresolved[$row->id]++; } } } } } return $menu; }