function &expandLink(&$parent) { $items =& JSite::getMenu(); $extensions =& $this->_extensions; $rows = null; if (strpos($parent->link, '-menu-') === 0) { $menutype = str_replace('-menu-', '', $parent->link); // Get Menu Items $rows = $items->getItems('menutype', $menutype); } elseif ($parent->id) { $rows = $items->getItems('parent_id', $parent->id); } if ($rows) { foreach ($rows as $item) { if ($item->parent_id == $parent->id) { $node = new stdclass(); $node->name = $item->title; $node->id = $item->id; $node->uid = 'itemid' . $item->id; $node->link = $item->link; $node->expandible = true; $node->selectable = true; // Prepare the node link if (false === OSMapHelper::prepareMenuItem($node)) { continue; } if ($item->home) { $node->link = JURI::root(); } elseif (substr($item->link, 0, 9) == 'index.php' && $item->type != 'url') { if ($item->type == 'menulink') { // For Joomla 1.5 SEF compatibility $params = new JParameter($item->params); $node->link = 'index.php?Itemid=' . $params->get('menu_item'); } elseif (strpos($item->link, 'Itemid=') === FALSE) { $node->link = 'index.php?Itemid=' . $node->id; } } elseif ($item->type == 'separator') { $node->selectable = false; } $this->printNode($node); // Add to the internal list } } } if ($parent->id) { $option = null; if (preg_match('#^/?index.php.*option=(com_[^&]+)#', $parent->link, $matches)) { $option = $matches[1]; } $Itemid = JRequest::getInt('Itemid'); if (!$option && $Itemid) { $item = $items->getItem($Itemid); $link_query = parse_url($item->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $option = JArrayHelper::getValue($link_vars, 'option', ''); if ($option) { $parent->link = $item->link; } } if ($option && !empty($extensions[$option])) { $plugin = $extensions[$option]; $methodParams = array(&$this, &$node, &$plugin->params); $result = Alledia\Framework\Helper::callMethod($plugin->className, 'getTree', $methodParams); $parent->uid = $option; } } return $this->_list; }
/** * Call the function prepareMenuItem of the extension for the item (if any) * * @param object Menu item object * * @return void */ public static function prepareMenuItem($item) { $extensions = OSMapHelper::getExtensions(); $result = true; if (!empty($extensions[$item->option])) { $plugin = $extensions[$item->option]; // Check if the method is static or not $result = Alledia\Framework\Helper::callMethod($plugin->className, 'prepareMenuItem', array($item, &$plugin->params)); } if ($result === null) { $result = true; } return $result; }
protected function printMenuTree($menu, &$items) { $this->changeLevel(1); $router = JSite::getRouter(); foreach ($items as $i => $item) { // Add each menu entry to the root tree. $excludeExternal = false; $node = new stdclass(); $node->id = $item->id; $node->uid = $item->uid; $node->name = $item->title; // displayed name of node // $node->parent = $item->parent; // id of parent node $node->browserNav = $item->browserNav; // how to open link $node->priority = $item->priority; $node->changefreq = $item->changefreq; $node->type = $item->type; // menuentry-type $node->menutype = $menu->menutype; // menuentry-type $node->home = $item->home; // If it's a home menu entry // $node->link = isset( $item->link ) ? htmlspecialchars( $item->link ) : ''; $node->link = $item->link; $node->option = $item->option; $node->modified = @$item->modified; $node->secure = $item->params->get('secure'); // New on OSMap 2.0: send the menu params $node->params =& $item->params; if ($node->home == 1) { // Correct the URL for the home page. $node->link = JURI::base(); } switch ($item->type) { case 'separator': case 'heading': $node->browserNav = 3; break; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { // If this is an internal Joomla link, ensure the Itemid is set. $node->link = $node->link . '&Itemid=' . $node->id; } else { $excludeExternal = $this->view == 'xml'; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $node->link = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: if ($router->getMode() == JROUTER_MODE_SEF) { $node->link = 'index.php?Itemid=' . $node->id; } elseif (!$node->home) { $node->link .= '&Itemid=' . $node->id; } break; } if ($excludeExternal || $this->printNode($node)) { // Restore the original link $node->link = $item->link; $this->printMenuTree($node, $item->items); $matches = array(); if ($node->option && !empty($this->jview->extensions[$node->option])) { $plugin = $this->jview->extensions[$node->option]; // Check if the method is static or not $methodParams = array(&$this, &$node, &$plugin->params); Alledia\Framework\Helper::callMethod($plugin->className, 'getTree', $methodParams); $node->uid = $node->option; } } } $this->changeLevel(-1); }