function _getItemData(&$params, $item) { //Create the new Node $node = new RokNavMenuNode(); $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 = $item->name; $tmp->mid = $item->id; $tmp->parent = $item->parent; $tmp->url = null; $tmp->nav = 'current'; } } if ($item->type != 'menulink' || $item->type == 'menulink' && $tmp == null) { $tmp = clone $item; $tmp->name = $item->name; $tmp->mid = $tmp->id; $tmp->url = null; $tmp->nav = 'current'; } $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) { default: case 1: $tmp->nav = 'new'; break; case 2: $tmp->url = str_replace('index.php', 'index2.php', $tmp->url); $tmp->nav = 'newnotool'; break; case 0: default: $tmp->nav = 'current'; break; } // Get the final URL if ($tmp->home == 1) { // Set Home Links to the Base $tmp->url = JURI::base(); } else { if ($tmp->type != 'separator' && $tmp->type != 'url') { $iSecure = $iParams->def('secure', 0); // Set Content links that can be put through JRoute through it if (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->url, 'index.php?') !== false) { $prefix = ''; if ($this->_params->get('url_type', 'relative') == 'full') { $uri =& JURI::getInstance(); $prefix = $uri->toString(array('scheme', 'host', 'port')); } $tmp->url = $prefix . JRoute::_($tmp->url, true, $iSecure); } else { if (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->url, 'index.php2?') !== false) { } } } else { if ($tmp->type == 'url') { $tmp->url = str_replace('&', '&', $tmp->url); } else { } } } } $node->id = $tmp->mid; $node->parent = $tmp->parent; $node->title = $tmp->name; $node->access = $tmp->access; $node->link = $tmp->url; $node->level = $item->sublevel; $node->image = $image; $node->alias = $tmp->alias; $node->nav = $tmp->nav; $node->setParameters($tmp->params); $node->type = $tmp->outtype; $node->order = $item->ordering; $node->addListItemClass("item" . $node->id); $node->addSpanClass($tmp->outtype); return $node; }
protected function convertNodes(RokMenuNodeTree $menu) { $top = new RokNavMenuTree(); $top->_params = $this->convertArgsToParams(); $subnodes = array(); // convert the nodes to an array of old school node types $itr = new RecursiveIteratorIterator($menu, RecursiveIteratorIterator::SELF_FIRST); foreach ($itr as $tmp) { $node = new RokNavMenuNode(); $node->id = $tmp->getId(); $node->parent = $tmp->getParent(); $node->title = $tmp->getTitle(); $node->access = $tmp->getAccess(); $node->link = $tmp->getLink(); $node->level = $tmp->getLevel(); $node->image = $tmp->getImage(); $node->alias = $tmp->isAlias(); $node->nav = $tmp->getTarget(); $node->access = $tmp->getAccess(); switch ($tmp->getTarget()) { case 'newnotool': $node->displayType = 2; break; case 'new': $node->displayType = 1; break; default: $node->displayType = 0; break; } $node->setParameters($tmp->getParams()); $node->type = $tmp->getType(); //$node->order = $item->ordering; foreach (explode(" ", $tmp->getListItemClasses()) as $class) { $node->addListItemClass($class); } foreach (explode(" ", $tmp->getSpanClasses()) as $class) { $node->addSpanClass($class); } foreach (explode(" ", $tmp->getLinkClasses()) as $class) { $node->addLinkClass($class); } foreach ($tmp->getLinkAttribsArray() as $name => $attrib) { $node->addLinkAttrib($name, $attrib); } foreach ($tmp->getLinkAdditionsArray() as $name => $value) { $node->addLinkAddition($name, $value); } if ($node->parent == RokNavMenu::TOP_LEVEL_PARENT_ID) { $node->_parentRef = $top; $top->_children[$node->id] = $node; } else { foreach ($subnodes as $subnode) { if ($node->parent == $subnode->id) { $subnode->addChild($node); break; } } } $subnodes[] = $node; } return $top; }
function _getItemData(&$params, $item) { //Create the new Node $node = new RokNavMenuNode(); $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->name, ENT_QUOTES, 'UTF-8')); $tmp->mid = $item->id; $tmp->parent = $item->parent; $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->name, ENT_QUOTES, 'UTF-8')); $tmp->mid = $tmp->id; $tmp->url = null; $tmp->nav = 'current'; $tmp->menualias = false; } $iParams = new JRegistry($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 = str_replace(array($tmp->route . '/', $tmp->route), '', JRoute::_($tmp->url)); } 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) ? rtrim(JURI::base(false), '/') : ''; $routed = $base . $url; $secure = RokNavMenuTree::_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; $node->title = $tmp->name; $node->access = $tmp->access; $node->link = $tmp->url; $node->level = $item->sublevel; $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; }