function xmapShowNavigatorLinks($config) { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'XmapNav.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'XmapPlugins.php'; require_once JPATH_SITE . DS . 'includes' . DS . 'application.php'; # DEBUG ini_set('display_errors', 1); error_reporting(E_ALL); # DEBUG $sitemapid = JRequest::getInt('sitemap', 0); $link = urldecode(JRequest::getVar('link', '')); $name = JRequest::getCmd('e_name', ''); $Itemid = JRequest::getInt('Itemid'); if (!$sitemapid) { $sitemapid = $config->sitemap_default; } $sitemap = new XmapSitemap($database); if (!$sitemap->load($sitemapid)) { echo _XMAP_INVALID_SITEMAP; return false; } $menus = $sitemap->getMenus(); $list = array(); // Show the menu items if (!$link && !$Itemid) { foreach ($menus as $menutype => $menu) { $node = new stdclass(); $menu->id = 0; $menu->menutype = $menutype; $node->uid = $menu->uid = "menu" . $menu->id; $node->menutype = $menutype; $node->ordering = $menu->ordering; $node->priority = $menu->priority; $node->changefreq = $menu->changefreq; $node->browserNav = 3; $node->type = 'separator'; if (!($node->name = getMenuTitle($menutype, @$menu->module))) { $node->name = $menutype; } $node->link = '-menu-' . $menutype; $node->expandible = true; $node->selectable = false; //$node->name = $this->getMenuTitle($menutype,@$menu->module); // get the mod_mainmenu title from modules table $list[] = $node; } } else { $nav = new XmapNav($config, $sitemap); $extensions = XmapPlugins::loadAvailablePlugins(); $parent = new stdClass(); if ($Itemid) { $items =& JSite::getMenu(); $item =& $items->getItem($Itemid); if (isset($menus[$item->menutype])) { $parent->name = $item->name; $parent->id = $item->id; $parent->uid = 'itemid' . $item->id; $parent->link = $link; $parent->type = $item->type; $parent->browserNav = $item->browserNav; $parent->priority = $menus[$item->menutype]->priority; $parent->changefreq = $menus[$item->menutype]->changefreq; $parent->menutype = $item->menutype; $parent->selectable = false; $parent->expandible = true; } } else { $parent->id = 0; $parent->link = $link; } $list = $nav->expandLink($parent, $extensions); } XmapAdminHtml::showNavigatorLinks($sitemapid, $list, $name); }
/** Get a Menu's tree * Get the complete list of menu entries where the menu is in $menutype. * If the component, that is linked to the menuentry, has a registered handler, * this function will call the handler routine and add the complete tree. * A tree with subtrees for each menuentry is returned. */ function printMenuTree(&$menu, &$cache, $plugins) { global $database; if (strlen($menu->menutype) == 0) { $result = null; return $result; } $menuExluded = explode(',', $this->sitemap->exclmenus); // by mic: fill array with excluded menu IDs /* * noauth is true: - Will show links to registered content, even if the client is not logged in. - The user will need to login to see the item in full. * noauth is false: - Will show only links to content for which the logged in client has access. */ $sql = "SELECT m.id, m.name, m.parent, m.link, m.type, m.browserNav, m.menutype, m.ordering, m.params, m.componentid, c.name AS component" . "\n FROM #__menu AS m" . "\n LEFT JOIN #__components AS c ON m.type='components' AND c.id=m.componentid" . "\n WHERE m.published='1' AND m.parent=" . $menu->id . " AND m.menutype = '" . $menu->menutype . "'" . ($this->noauth ? '' : "\n AND m.access <= '" . $this->gid . "'") . "\n ORDER BY m.menutype,m.parent,m.ordering"; // Load all menuentries $database->setQuery($sql); $items = $database->loadObjectList(); if (count($items) <= 0) { //ignore empty menus $result = null; return $result; } $this->changeLevel(1); $isJ15 = defined('_JEXEC') && defined('JPATH_COMPONENT'); foreach ($items as $i => $item) { // Add each menu entry to the root tree. $item->priority = $menu->priority; $item->changefreq = $menu->changefreq; if (in_array($item->id, $menuExluded)) { // ignore exluded menu-items continue; } $node = new stdclass(); $node->id = $item->id; $node->uid = "item" . $item->id; $node->name = $item->name; // displayed name of node $node->parent = $item->parent; // id of parent node $node->browserNav = $item->browserNav; // how to open link $node->ordering = isset($item->ordering) ? $item->ordering : $i; // display-order of the menuentry $node->priority = $item->priority; $node->changefreq = $item->changefreq; $node->type = $item->type; // menuentry-type $node->menutype = $item->menutype; // menuentry-type if ($isJ15 && substr($item->link, 0, 9) == 'index.php') { $node->link = 'index.php?Itemid=' . $node->id; // For Joomla 1.5 SEF compatibility } else { $node->link = isset($item->link) ? htmlspecialchars($item->link) : ''; // convert link to valid xml } $this->printNode($node); XmapPlugins::printTree($this, $item, $cache, $plugins); // Determine the menu entry's type and call it's handler $this->printMenuTree($node, $cache, $plugins); } $this->changeLevel(-1); }
/** Get a Menu's tree * Get the complete list of menu entries where the menu is in $menutype. * If the component, that is linked to the menuentry, has a registered handler, * this function will call the handler routine and add the complete tree. * A tree with subtrees for each menuentry is returned. */ function printMenuTree(&$menu, &$cache, $extensions) { $database =& JFactory::getDBO(); if (strlen($menu->menutype) == 0) { $result = null; return $result; } $menuExluded = explode(',', $this->sitemap->exclmenus); // by mic: fill array with excluded menu IDs /* * noauth is true: - Will show links to registered content, even if the client is not logged in. - The user will need to login to see the item in full. * noauth is false: - Will show only links to content for which the logged in client has access. */ $sql = "SELECT m.id, m.name, m.parent, m.link, m.type, m.browserNav, m.menutype, m.ordering, m.params, m.componentid,m.home, c.name AS component" . "\n FROM #__menu AS m" . "\n LEFT JOIN #__components AS c ON m.type='components' AND c.id=m.componentid" . "\n WHERE m.published='1' AND m.parent=" . $menu->id . " AND m.menutype = '" . $menu->menutype . "'" . ($this->noauth ? '' : "\n AND m.access <= '" . $this->gid . "'") . "\n ORDER BY m.menutype,m.parent,m.ordering"; // Load all menuentries $database->setQuery($sql); $items = $database->loadObjectList(); if (count($items) <= 0) { //ignore empty menus $result = null; return $result; } $this->changeLevel(1); $router = JSite::getRouter(); foreach ($items as $i => $item) { // Add each menu entry to the root tree. $item->priority = @$menu->priority; $item->changefreq = @$menu->changefreq; if (in_array($item->id, $menuExluded)) { // ignore exluded menu-items continue; } if ($item->type == 'menulink') { $menu =& JSite::getMenu(); $params = new JParameter($item->params); if ($newItem = $menu->getItem($params->get('menu_item'))) { $item->type = $newItem->type; $item->id = $newItem->id; $item->parent = $newItem->parent; $item->link = $newItem->link; $item->home = $newItem->home; } } $node = new stdclass(); $node->id = $item->id; $node->uid = "itemid" . $item->id; $node->name = $item->name; // displayed name of node $node->parent = $item->parent; // id of parent node $node->browserNav = $item->browserNav; // how to open link $node->ordering = isset($item->ordering) ? $item->ordering : $i; // display-order of the menuentry $node->priority = $item->priority; $node->changefreq = $item->changefreq; $node->type = $item->type; // menuentry-type $node->menutype = $item->menutype; // menuentry-type $node->home = $item->home; // menuentry-type $node->link = isset($item->link) ? htmlspecialchars($item->link) : ''; if ($node->type == 'separator') { $node->browserNav = 3; } XmapPlugins::prepareMenuItem($node, $extensions); // Let's see if the extension wants to do somenthing with this node before it's printed if ($node->home) { $node->link = JURI::base(); } elseif (substr($item->link, 0, 9) == 'index.php' && $item->type != 'url' && $item->type != 'separator') { if (strpos($node->link, 'Itemid=') === FALSE) { $node->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $node->id : $node->link . '&Itemid=' . $node->id; } } if ($this->printNode($node)) { if (preg_match('/option=(com_[a-z0-9_]+)/i', $item->link, $matches)) { // Set the uid of the node to the component uid after print it // so its children dont use a wrong uid # echo $node->uid = $matches[1]; } $this->printMenuTree($node, $cache, $extensions); XmapPlugins::printTree($this, $item, $cache, $extensions); // Determine the menu entry's type and call it's handler } } $this->changeLevel(-1); }
function &expandLink(&$parent,&$extensions) { $items = &JSite::getMenu(); $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', $parent->id); } if ( $rows ) { $router = JSite::getRouter(); foreach ($rows as $item) { if ($item->parent == $parent->id) { $item->mid = $item->id; if ($item->type == 'menulink') { $menu = &JSite::getMenu(); $params = new JParameter($item->params); if ($newItem = $menu->getItem($params->get('menu_item'))) { $item->type = $newItem->type; $item->mid = $newItem->id; $item->parent = $newItem->parent; $item->link = $newItem->link; } } $node = new stdclass; $node->name = $item->name; $node->id = $item->id; $node->uid = 'itemid'.$item->id; $node->link = $item->link; $node->expandible = true; $node->selectable=true; // Prepare the node link XmapPlugins::prepareMenuItem($node,$extensions); if ( $item->home ) { $node->link = JURI::root(); } elseif (substr($item->link,0,9) == 'index.php' && $item->type != 'url' && $item->type != 'separator') { if ( strpos($node->link,'Itemid=') === FALSE ){ $node->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$node->id : $node->link.'&Itemid='.$node->id; } } $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); if ( preg_match('#^/?index.php.*option=(com_[^&]+)#',$item->link,$matches) ) { $option = $matches[1]; $parent->link = $item->link; } } if ( $option ) { if ( !empty($extensions[$option]) ) { $parent->uid = $option; $className = 'xmap_'.$option; $result = call_user_func_array(array($className, 'getTree'),array(&$this,&$parent,$extensions[$option]->getParams())); } } } return $this->_list;; }