function FGetLink($menu_id = NULL, $anchor = NULL) { // Avoid a static call // $wholemenu =& JSite::getMenu(); global $app; $wholemenu = $app->getMenu(); if ($menu_id) { $targetmenu = $wholemenu->getItem($menu_id); } else { $targetmenu = $wholemenu->getActive(); } // It can happen when $menu_id is a deleted, unpublished or trashed menu item if (!is_object($targetmenu)) { return NULL; } // Get target link $link = $targetmenu->link; // Build it with the correct id $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $link = 'index.php?Itemid=' . $targetmenu->id; } else { $link .= '&Itemid=' . $targetmenu->id; } $link .= $anchor; // Finally translate it in a SEF one if needed return JRoute::_($link); }
/** * Build a menu link * * @param object $item */ public static function buildLink($item) { $item->flink = $item->link; switch ($item->type) { case 'separator': // No further action needed. continue; 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. $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } }
public static function getMenu($params) { $items = array(); $children = array(); if ($params->get('menu')) { $menu = JSite::getMenu(); $items = $menu->getItems('menutype', $params->get('menu')); } foreach ($items as $item) { $item->name = $item->title; $item->parent = $item->parent_id; $index = $item->parent; $list = @$children[$index] ? $children[$index] : array(); array_push($list, $item); $children[$index] = $list; } $items = JHTML::_('menu.treerecurse', 1, '', array(), $children, 9999, 0, 0); $links = array(); foreach ($items as $item) { $item->flink = $item->link; switch ($item->type) { case 'separator': continue; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } $item->route = $item->flink; $links[] = $item; } return $links; }
public function render($startLevel = 0, $endLevel = 14) { $my = JFactory::getUser(); $nav = array(); $app = JFactory::getApplication(); $menu = $app->getMenu(); $options = $menu->getItems('menutype', $this->_type); $output = array(); $string = ''; foreach ($options as $i => $item) { $item->url = $item->link; switch ($item->type) { case 'separator': $item->_index = count($list_menu); $list_menu[] = $item; $nav[$parent] = $list_menu; continue; case 'url': // If this is an internal Joomla link, ensure the Itemid is set. if (strpos($item->link, 'index.php?') !== false && strpos($item->link, 'Itemid=') === false) { $item->url = $item->link . '&Itemid=' . $item->id; } else { $item->url = $item->link; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->url = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->url = 'index.php?Itemid=' . $item->id; } else { $item->url .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->url, 0, 4), 'http') && strpos($item->url, 'index.php?') !== false) { $item->url = JRoute::_($item->url, true, $item->params->get('secure')); } else { $item->url = JRoute::_($item->url); } $options[$i]->title = str_repeat('- ', $options[$i]->level) . $options[$i]->title; $selected = $item->id == $this->Itemid ? 'selected="selected"' : ""; $string .= '<option value="' . $item->url . '" id="combom' . $item->id . '" ' . $selected . ' >' . $options[$i]->title . "</option>"; } echo '<select id="comboxrpmenu" name="comboxrpmenu" class="inputbox" onchange="window.location.href=this.value">' . $string . '</select>'; }
/** * Class constructor. * * @param array * * @return JPathwaySite * @since 1.5 */ public function __construct($options = array()) { //Initialise the array. $this->_pathway = array(); $app = JApplication::getInstance('site'); $menu = $app->getMenu(); if ($item = $menu->getActive()) { $menus = $menu->getMenu(); $home = $menu->getDefault(); if (is_object($home) && $item->id != $home->id) { foreach ($item->tree as $menupath) { $url = ''; $link = $menu->getItem($menupath); switch ($link->type) { case 'separator': $url = null; break; case 'url': if (strpos($link->link, 'index.php?') === 0 && strpos($link->link, 'Itemid=') === false) { // If this is an internal Joomla link, ensure the Itemid is set. $url = $link->link . '&Itemid=' . $link->id; } else { $url = $link->link; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $url = 'index.php?Itemid=' . $link->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $url = 'index.php?Itemid=' . $link->id; } else { $url .= $link->link . '&Itemid=' . $link->id; } break; } $this->addItem($menus[$menupath]->title, $url); } } } }
function B2JGetLink($menu_id = NULL, $anchor = NULL) { global $app; $wholemenu = $app->getMenu(); if ($menu_id) { $targetmenu = $wholemenu->getItem($menu_id); } else { $targetmenu = $wholemenu->getActive(); } if (!is_object($targetmenu)) { return NULL; } $link = $targetmenu->link; $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $link = 'index.php?Itemid=' . $targetmenu->id; } else { $link .= '&Itemid=' . $targetmenu->id; } $link .= $anchor; return JRoute::_($link); }
function _getItemData(&$params, $item) { $data = null; $active_class = ""; if ($item->id == $this->_currentItemId) { $active_class = "icemega_active"; } // 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 = '<span><![CDATA[' . $item->title . ']]></span>'; $tmp->mid = $item->id; $tmp->parent = $item->parent_id; } else { return false; } } else { $tmp = clone $item; $iParams = new JRegistry(); $iParams->loadString($tmp->params); $tmp->name = '<span class="icemega_title' . ($iParams->get("icemega_subtitle", "") == "" ? ' icemega_nosubtitle' : '') . '"><![CDATA[' . $item->title . ']]></span>'; } $iParams = new JRegistry(); $iParams->loadString($tmp->params); if ($iParams->get('menu-anchor_css', "")) { JHTML::stylesheet('', $iParams->get('menu-anchor_css', "")); } if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) { switch ($params->get('menu_images_align', 0)) { case 0: $imgalign = 'align="left"'; break; case 1: $imgalign = 'align="right"'; break; default: $imgalign = ''; break; } if ($iParams->get('menu_anchor_css')) { $document->addStyleSheet($iParams->get('menu_anchor_css')); } $image = ""; if ($iParams->get('menu_image')) { $image = '<img src="' . JURI::base(true) . "/" . $iParams->get('menu_image') . '" ' . $imgalign . ' alt="' . $item->alias . '" />'; } } else { $image = null; } if ($iParams->get("icemega_subtitle", "") != "") { $tmp->name .= '<span class="icemega_desc">' . $iParams->get("icemega_subtitle", "") . '</span>'; } switch ($tmp->type) { case 'separator': //return '<span class="separator">'.$image.$tmp->name.'</span>'; if ($iParams->get("icemega_subtype") == 'mod' || $iParams->get("icemega_subtype") == 'pos') { //$text = 'window.addEvent("load", function(){if($(\'item-'.$tmp->id.'\') != null)$(\'item-'.$tmp->id.'\').setStyle(\'display\', \'none\')});'; //$document = &JFactory::getDocument(); //$document->addScriptDeclaration($text); } $tmp->url = ""; 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; } break; case 'alias': $tmp->url = 'index.php?Itemid=' . $tmp->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id; break; } $myClass = "iceMenuTitle"; if ($item->level == 1) { $myClass = "iceMenuTitle"; } // Print a link if it exists if ($tmp->url != null && $iParams->get("icemega_showlink", 1)) { // Handle SSL links $iSecure = $iParams->def('secure', 0); if ($tmp->home == 1) { $tmp->url = JURI::base(); } elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->link, 'index.php?') !== false) { $tmp->url = JRoute::_($tmp->url, true, $iSecure); } else { $tmp->url = str_replace('&', '&', $tmp->url); } switch ($tmp->browserNav) { default: case 0: // _top $data = '<a href="' . $tmp->url . '" class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>'; break; case 1: // _blank $data = '<a href="' . $tmp->url . '" target="_blank" class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>'; break; case 2: // window.open $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->_params->get('window_open'); // hrm...this is a bit dickey $link = str_replace('index.php', 'index2.php', $tmp->url); $data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;" class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>'; break; } } else { $data = '<a class="' . $active_class . ' ' . $myClass . '">' . $image . $tmp->name . '</a>'; } return $data; }
/** * Builds internal URL - indepedent of SEF function * * @param object $uri * * @return string */ private function buildInternalUrl($uri) { // Clone JUri object to avoid an error because of the method -parse- in the next step $uri_clone = clone $uri; // Reference to JRouter object $route = JSite::getRouter(); // Get the internal route $url_internal_array = $route->parse($uri_clone); // Move Itemid at the end if (array_key_exists('Itemid', $url_internal_array)) { $itemid = $url_internal_array['Itemid']; unset($url_internal_array['Itemid']); $url_internal_array['Itemid'] = $itemid; } // Move lang at the end if (array_key_exists('lang', $url_internal_array)) { $lang = $url_internal_array['lang']; unset($url_internal_array['lang']); $url_internal_array['lang'] = $lang; } $url_internal = JUri::base() . 'index.php?' . JUri::buildQuery($url_internal_array); return $url_internal; }
public static function getList(&$params) { $app = JFactory::getApplication(); $menu = $app->getMenu(); // Get active menu item $active = self::getActive($params); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); asort($levels); $key = 'menu_items' . $params . implode(',', $levels) . '.' . $active->id; $cache = JFactory::getCache('mod_sj_megamenu_res', ''); if (!($items = $cache->get($key))) { $path = $active->tree; $start = (int) $params->get('startLevel'); $end = (int) $params->get('endLevel'); $showAll = $params->get('showAllChildren'); $items = $menu->getItems('menutype', $params->get('menutype')); $lastitem = 0; if ($items) { foreach ($items as $i => $item) { if ($start && $start > $item->level || $end && $item->level > $end || !$showAll && $item->level > 1 && !in_array($item->parent_id, $path) || $start > 1 && !in_array($item->tree[$start - 2], $path) || self::noPrint($item)) { unset($items[$i]); continue; } $item->deeper = false; $item->shallower = false; $item->level_diff = 0; if (isset($items[$lastitem])) { $items[$lastitem]->deeper = $item->level > $items[$lastitem]->level; $items[$lastitem]->shallower = $item->level < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - $item->level; } $item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true); $lastitem = $i; $item->active = false; $item->flink = $item->link; // Reverted back for CMS version 2.5.6 switch ($item->type) { case 'separator': // No further action needed. continue; 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. $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } // We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding // when the cause of that is found the argument should be removed $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : ''; } if (isset($items[$lastitem])) { $items[$lastitem]->deeper = ($start ? $start : 1) > $items[$lastitem]->level; $items[$lastitem]->shallower = ($start ? $start : 1) < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - ($start ? $start : 1); } } $cache->store($items, $key); } return $items; }
public function getFullMenuItems($args) { $app = JFactory::getApplication(); $menu = $app->getMenu(); // Get Menu Items $rows = $menu->getItems('menutype', $args['menutype']); $outputNodes = array(); if (is_array($rows) && count($rows) > 0) { foreach ($rows as $item) { //Create the new Node $node = new JoomlaRokMenuNode(); $node->setId($item->id); $node->setParent($item->parent_id); $node->setTitle(addslashes(htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'))); $node->setParams($item->params); $node->setLink($item->link); // Menu Link is a special type that is a link to another item if ($item->type == 'alias' && ($newItem = $menu->getItem($item->params->get('aliasoptions')))) { $node->setAlias(true); $node->setLink($newItem->link); } // Get the icon image associated with the item $iParams = is_object($item->params) ? $item->params : new JRegisry($item->params); if ($args['menu_images'] && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) { $node->setImage(JURI::base(true) . '/images/stories/' . $iParams->get('menu_image')); if ($args['menu_images_link']) { $node->setLink(null); } } switch ($item->type) { case 'separator': $node->setType('separator'); break; case 'url': if (strpos($node->getLink(), 'index.php?') === 0 && strpos($node->getLink(), 'Itemid=') === false) { $node->setLink($node->getLink() . '&Itemid=' . $node->getId()); } elseif (!empty($item->link) && $item->link != null) { $node->setLink($item->link); } $node->setType('menuitem'); break; default: $router = JSite::getRouter(); if ($node->isAlias() && $newItem) { $menu_id = $item->params->get('aliasoptions'); $node->setMenuId($menu_id); //for aliased items formatter.php doesn't cover if ($node->getMenuId() == $this->current_node) { //taken back out because it caused all the aliased menu items on RT demos to highlight //$node->addListItemClass('active'); //$node->setCssId('current'); } } else { $menu_id = $node->getId(); $node->setMenuId($menu_id); } $link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $menu_id : $node->getLink() . '&Itemid=' . $menu_id; $node->setLink($link); $node->setType('menuitem'); break; } if ($node->getLink() != null) { // set the target based on menu item options switch ($item->browserNav) { case 1: $node->setTarget('_blank'); break; case 2: //$node->setLink(str_replace('index.php', 'index2.php', $node->getLink())); //$node->setTarget('newnotool'); $value = addslashes(htmlspecialchars("window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');return false;", ENT_QUOTES, 'UTF-8')); $node->addLinkAttrib('onclick', $value); break; default: //$node->setTarget('current'); break; } // Get the final URL if ($item->home == 1) { // Set Home Links to the Base //removed because it breaks SEF extensions //$node->setLink(JRoute::_(JURI::base())); } if ($item->type != 'separator' && $item->type != 'url') { $iSecure = $iParams->get('secure', 0); if (array_key_exists('url_type', $args) && $args['url_type'] == 'full') { $url = JRoute::_($node->getLink(), true, $iSecure); $base = !preg_match("/^http/", $node->getLink()) ? rtrim(JURI::base(false) . '/') : ''; $routed = $base . $url; $secure = RokNavMenuTree::_getSecureUrl($routed, $iSecure); $node->setLink($secure); } else { $node->setLink(JRoute::_($node->getLink(), true, $iSecure)); } } else { if ($item->type == 'url') { $node->setLink(str_replace('&', '&', $node->getLink())); } } } $node->addListItemClass("item" . $node->getId()); $node->setAccess($item->access); $node->addSpanClass($node->getType()); $outputNodes[$node->getId()] = $node; } } return $outputNodes; }
public function initMenu() { $app = JFactory::getApplication(); $menu = $app->getMenu('site'); $attributes = array('menutype'); $menu_name = array($this->menuname); $items = $menu->getItems($attributes, $menu_name); $active_item = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); $this->active = $active_item ? $active_item->id : 0; $this->active_tree = $active_item->tree; foreach ($items as &$item) { if ($item->level >= 2 && !isset($this->_items[$item->parent_id])) { continue; } $parent = isset($this->children[$item->parent_id]) ? $this->children[$item->parent_id] : array(); $parent[] = $item; $this->children[$item->parent_id] = $parent; $this->_items[$item->id] = $item; } foreach ($items as &$item) { $class = ''; if ($item->id == $this->active) { $class .= ' current-item'; } if (in_array($item->id, $this->active_tree)) { $class .= ' active'; } elseif ($item->type == 'alias') { $aliasToId = $item->params->get('aliasoptions'); if (count($this->active_tree) > 0 && $aliasToId == $this->active_tree[count($this->active_tree) - 1]) { $class .= ' active'; } elseif (in_array($aliasToId, $this->active_tree)) { $class .= ' alias-parent-active'; } } $item->class = $class; $item->dropdown = 0; if (isset($this->children[$item->id])) { $item->dropdown = 1; } $item->megamenu = $item->params->get('megamenu') ? $item->params->get('megamenu') : 0; $item->flink = $item->link; switch ($item->type) { case 'separator': case 'heading': // No further action needed. continue; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } // We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding // when the cause of that is found the argument should be removed $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : ''; } }
function loadMenu($menuname = 'mainmenu') { $list = array(); $db = JFactory::getDbo(); $acl = JFactory::getACL(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $menu = $app->getMenu(); $aid = $user->get('aid'); //find active element or set default $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); $this->open = $active->tree; $this->open = $this->open[count($this->open) - 1]; $rows = $menu->getItems('menutype', $menuname); if (!count($rows)) { return; } $children = array(); $this->items = array(); foreach ($rows as $index => $v) { if (isset($v->title)) { $v->name = $v->title; } if (isset($v->parent_id)) { $v->parent = $v->parent_id; } $v->name = str_replace('&', '&', str_replace('&', '&', $v->name)); if ($v->access >= $aid) { $ptr = $v->parent; $list = @$children[$ptr] ? $children[$ptr] : array(); // friendly links $v->flink = $v->link; switch ($v->type) { case 'separator': continue; case 'url': if (strpos($v->link, 'index.php?') === 0 && strpos($v->link, 'Itemid=') === false) { $v->flink = $v->link . '&Itemid=' . $v->id; } break; case 'alias': $v->flink = 'index.php?Itemid=' . $v->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $v->flink = 'index.php?Itemid=' . $v->id; } else { $v->flink .= '&Itemid=' . $v->id; } break; } $v->url = $v->flink = JRoute::_($v->flink); if ($v->home == 1) { $v->url = JURI::base(); } $v->_idx = count($list); array_push($list, $v); $children[$ptr] = $list; $this->items[$v->id] = $v; } } $this->children = $children; }
function mosGetLink($mitem, $level, $class_sfx = '') { global $Itemid; $txt = ''; $menuclass = ''; $main = 'top'; $router = JSite::getRouter(); $mitem->url2 = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id; JRoute::_('$mitem->link'); $menui = 'true'; if ($menui == 'true') { $menu_params = new stdClass(); $menu_params = new JParameter($mitem->params); $menu_image = $menu_params->def('menu_image', -1); } if ($mitem->url2[10] == "I") { if ($mitem->type != "url" && $mitem->type != "separator") { $sef_suf =& JFactory::getApplication(); $sef_value = $sef_suf->getCfg('sef_suffix'); $mitem->link = JRoute::_($mitem->alias); if ($sef_value == "1") { $mitem->link = "{$mitem->link}.html"; $router = JSite::getRouter(); $mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id; } else { if ($sef_value == "0") { $router = JSite::getRouter(); $mitem->link = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $mitem->id : $mitem->link . '&Itemid=' . $mitem->id; } else { $mitem->link = $mitem->link; } } } } if ($mitem->id == 1) { $mitem->link = ""; } switch ($mitem->browserNav) { case 1: if ($mitem->cnt > 0) { if ($level == 0) { $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a class=\"main\" target=\"_window\" href=\"{$mitem->link}\">{$mitem->name}</a></span></span>"; $main = "main"; } else { $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a class=\"sub\" target=\"_window\" href=\"{$mitem->link}\">{$mitem->name}</a></span></span>"; } } else { $txt = "<span><span><a href=\"{$mitem->link}\" class=\"sub\" target=\"_window\" >{$mitem->name}</a></span></span>\n"; } break; case 2: if ($mitem->cnt > 0) { if ($level == 0) { $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" class=\"main\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n"; $main = "main"; } else { $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" class=\"sub\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n"; } } else { $txt = "<span class=\"s5_outer_active\"><span class=\"s5_outer\"><a href=\"#\" onClick=\"javascript: window.open('{$mitem->link}', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');\" class=\"{$menuclass}\">{$mitem->name}</a></span></span>\n"; } break; case 3: if ($mitem->cnt > 0) { if ($level == 0) { $txt = "<span><span><a class=\"main\">{$mitem->name}</a></span></span>"; $main = "main"; } else { $txt = "<span><span><a class=\"sub\">{$mitem->name}</a></span></span>"; } } else { $txt = "<span><span><a>{$mitem->name}</a></span></span>\n"; } break; default: if (isset($mitem->cnt) && $mitem->cnt > 0) { $random = rand() % 30000000000000; if ($level == 0) { $LiveSite = JURI::base(); $txt = "<span class=\"s5_outer_active\"><span><a class=\"active\" href=\"{$mitem->link}\">{$mitem->name}<span class=\"s5_bottom_text\"></span></a><span class=\"s5_outerr\"></span></span></span>"; $main = "main"; } else { $txt = "<span class=\"parent\"><a class=\"parent\" href=\"{$mitem->link}\"> {$mitem->name}</a></span>"; } } else { if ($level == 0) { $LiveSite = JURI::base(); $txt = "<span class=\"s5_outer_active\"><span><a class=\"active\" href=\"{$mitem->link}\">{$mitem->name}<span class=\"s5_bottom_text\"></span></a><span class=\"s5_outerr\"></span></span></span>"; } else { if ($level > 0) { $LiveSite = JURI::base(); $txt = "<span><span class=\"span_nonactive\"><a class=\"sub\" href=\"{$mitem->link}\">{$mitem->name}</a></span></span>"; } } } break; } return $txt; }
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; }
function GetMenu(&$params) { jimport('joomla.application.module.helper'); $mooduree = $params->get('mooduration', 500); $mootransition = $params->get('mootransition', 'Bounce'); $mooease = $params->get('mooease', 'easeOut'); $usemootools = $params->get('usemootools', '1'); $usecss = $params->get('usecss', '1'); $menuID = $params->get('menuid', 'vt_menu'); $document =& JFactory::getDocument(); if ($usecss == 1) { $document->addStyleSheet(JURI::base() . 'modules/mod_vtemmenu/style.css'); } if ($usemootools == 1) { JHTML::_("behavior.mootools"); $document->addScript(JURI::base() . 'modules/mod_vtemmenu/moo_vtemmenu.js'); $js = "window.addEvent('domready', function() {new DropdownVtemmenu(\$E('div#" . $menuID . "'),{" . "mooTransition : '" . $mootransition . "'," . "mooEase : '" . $mooease . "'," . "mooDuree : " . $mooduree . "});" . "});"; $document->addScriptDeclaration($js); } else { $script = 'window.addEvent(\'domready\', function() { var sfEls = document.getElementById("' . $menuID . '").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\\\b"), ""); } } });'; $document->addScriptDeclaration($script); } $menutype = $params->get('menutype', 'mainmenu'); $db =& JFactory::getDBO(); $query = "\n\t\t\tSELECT *\n\t\t\tFROM #__menu\n\t\t\tWHERE menutype='" . $menutype . "' AND published=1\n\t\t\tORDER BY sublevel DESC,ordering\n\t\t\t;"; $db->setQuery($query); $rows = $db->loadObjectList('id'); $user =& JFactory::getUser(); $urights = $user->get('aid', 0); $menu =& JSite::getMenu(); $active = $menu->getActive(); $modulesList = modvtemmenuHelper::CreateModulesList(); $level = 0; $items = array(); $i = 0; foreach ($rows as $item) { if ($item->sublevel > 0) { $rows[$item->parent]->haschild = 'yes'; if (isset($item->haschild)) { $rows[$item->parent]->enfants .= $item->id . '|' . $item->enfants; } else { $rows[$item->parent]->enfants .= $item->id . '|'; } if (isset($active) && $active->id == $item->id) { $j = $item->sublevel; $tempitemID = $item->parent; while ($j != 0) { $rows[$tempitemID]->classe .= " active"; $tempitemID = $rows[$tempitemID]->parent; $j--; } } if (isset($item->haschild)) { $item->classe .= " parent"; } } if ($item->sublevel == 0 && $urights >= $item->access) { $items[$i] = $item; if (isset($item->haschild)) { $item->classe .= " parent"; $childs = explode("|", $item->enfants); foreach ($childs as $c) { if ($c) { $i++; if ($urights >= $rows[$rows[$c]->parent]->access && $urights >= $rows[$c]->access) { $items[$i] = $rows[$c]; } else { $i--; } } } } } else { $i--; } $i++; } foreach ($items as $i => &$item) { $item->deeper = isset($items[$i + 1]) && $item->sublevel < $items[$i + 1]->sublevel; $item->shallower = isset($items[$i + 1]) && $item->sublevel > $items[$i + 1]->sublevel; $item->level_diff = isset($items[$i + 1]) ? $item->sublevel - $items[$i + 1]->sublevel : $item->sublevel; $item->is_end = !isset($items[$i + 1]); $menu_params = new stdClass(); $menu_params = new JParameter($item->params); $menu_secure = $menu_params->def('secure', 0); switch ($item->type) { case 'separator': continue; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { $item->link = $tmp->link . '&Itemid=' . $item->id; } break; case 'alias': $item->link = 'index.php?Itemid=' . $item->params->aliasoptions; break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->link = 'index.php?Itemid=' . $item->id; } else { $item->link .= '&Itemid=' . $item->id; } break; } if ($item->home == 1) { $item->link = JURI::base(); } elseif (strcasecmp(substr($item->link, 0, 4), 'http') && strpos($item->link, 'index.php?') !== false) { $item->link = JRoute::_($item->link, true, $menu_secure); } else { $item->link = str_replace('&', '&', $item->link); } $item->classe .= " item" . $item->id; if (isset($active) && $active->id == $item->id) { $item->classe .= " current active"; } if (preg_match('/\\[col\\]/', $item->name)) { $item->colonne = true; $item->name = ''; } $item->divclasse = ""; if (preg_match('/\\[cols(.+)\\]/', $item->name, $resultat)) { $item->name = preg_replace('/\\[cols(.+)\\]/', '', $item->name); $divclasse = " cols" . $resultat[1]; $item->divclasse = strval($divclasse); } $paramsVT = ""; $masque = "#\\[(.+)\\]#"; if (preg_match($masque, $item->name, $resultat)) { $paramsVT = $resultat[1]; $titleVT = preg_replace('/\\[' . $resultat[1] . '\\]/', '', $item->name); } else { $titleVT = $item->name; } if (preg_match('/modname/', $paramsVT)) { $item->content = '<div class="vtemmenu_mod">' . modvtemmenuHelper::GenModuleByName($paramsVT, $params) . '<div class="clr"></div></div>'; } elseif (preg_match('/modid/', $paramsVT)) { $item->content = '<div class="vtemmenu_mod">' . modvtemmenuHelper::GenModuleById($paramsVT, $params, $modulesList) . '<div class="clr"></div></div>'; } else { $item->content = ""; } $titleVT = explode("||", $titleVT); if (isset($titleVT[1])) { $titleVT = $titleVT[0] . '<br/><span class="vt_desc">' . $titleVT[1] . '</span>'; } else { $titleVT = $titleVT[0]; } $menu_image = $menu_params->def('menu_image', -1); $item->image_lft = ""; $item->image_rgt = ""; if ($menu_image != '-1' && $menu_image) { $image = '<img src="' . JURI::base(true) . '/images/stories/' . $menu_image . '" border="0" alt="' . $item->name . '"/>'; if ($params->get('menu_images_align')) { $item->image_rgt = $image; } else { $item->image_lft = $image; } } $item->name = $titleVT; } return $items; }
/** * @param string $menutype menu type to render * @param array $settings settings information * @param null $params other parameters */ function __construct($menutype = 'mainmenu', $settings = array(), $params = null) { $app = JFactory::getApplication(); $menu = $app->getMenu('site'); $attributes = array('menutype'); $values = array($menutype); if (isset($settings['access'])) { $attributes[] = 'access'; $values[] = $settings['access']; } else { $settings['access'] = array(1); } if (isset($settings['language'])) { $attributes[] = 'language'; $values[] = $settings['language']; } $items = $menu->getItems($attributes, $values); $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); $this->active_id = $active ? $active->id : 0; $this->active_tree = $active->tree; $this->settings = $settings; $this->params = $params; $this->editmode = isset($settings['editmode']); foreach ($items as &$item) { //remove all non-parent item (the parent has access higher access level) if ($item->level >= 2 && !isset($this->_items[$item->parent_id])) { continue; } $parent = isset($this->children[$item->parent_id]) ? $this->children[$item->parent_id] : array(); $parent[] = $item; $this->children[$item->parent_id] = $parent; $this->_items[$item->id] = $item; } foreach ($items as &$item) { // bind setting for this item $key = 'item-' . $item->id; $setting = isset($this->settings[$key]) ? $this->settings[$key] : array(); // decode html tag if (isset($setting['caption']) && $setting['caption']) { $setting['caption'] = str_replace(array('[lt]', '[gt]'), array('<', '>'), $setting['caption']); } if ($item->level == 1 && isset($setting['caption']) && $setting['caption']) { $this->top_level_caption = true; } // active - current $class = ''; if ($item->id == $this->active_id) { $class .= ' current'; } if (in_array($item->id, $this->active_tree)) { $class .= ' active'; } elseif ($item->type == 'alias') { $aliasToId = $item->params->get('aliasoptions'); if (count($this->active_tree) > 0 && $aliasToId == $this->active_tree[count($this->active_tree) - 1]) { $class .= ' active'; } elseif (in_array($aliasToId, $this->active_tree)) { $class .= ' alias-parent-active'; } } $item->class = $class; $item->mega = 0; $item->group = 0; $item->dropdown = 0; if (isset($setting['group']) && $item->level > 1) { $item->group = 1; } else { if (isset($this->children[$item->id]) && ($this->editmode || !isset($setting['hidesub'])) || isset($setting['sub'])) { $item->dropdown = 1; } } $item->mega = $item->group || $item->dropdown; // set default sub if not exists if ($item->mega) { if (!isset($setting['sub'])) { $setting['sub'] = array(); } if (isset($this->children[$item->id]) && (!isset($setting['sub']['rows']) || !count($setting['sub']['rows']))) { $c = $this->children[$item->id][0]->id; $setting['sub'] = array('rows' => array(array(array('width' => 12, 'item' => $c)))); } } $item->setting = $setting; $item->flink = $item->link; // Reverted back for CMS version 2.5.6 switch ($item->type) { case 'separator': case 'heading': // No further action needed. continue; 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. $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } // We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding // when the cause of that is found the argument should be removed $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : ''; } }
function getMenu($params) { $items = array(); if ($params->get('menu')) { $menu =& JSite::getMenu(); $items = $menu->getItems('menutype', $params->get('menu')); } foreach ($items as $item) { if (K2_JVERSION == '16') { $item->name = $item->title; $item->parent = $item->parent_id; } $index = $item->parent; $list = @$children[$index] ? $children[$index] : array(); array_push($list, $item); $children[$index] = $list; } if (K2_JVERSION == '16') { $items = JHTML::_('menu.treerecurse', 1, '', array(), $children, 9999, 0, 0); } else { $items = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0); } $links = array(); foreach ($items as $item) { if (K2_JVERSION == '15') { $item->level = $item->sublevel; switch ($item->type) { case 'separator': continue; break; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { $item->url = $item->link . '&Itemid=' . $item->id; } else { $item->url = $item->link; } break; default: $router = JSite::getRouter(); $item->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $item->id : $item->link . '&Itemid=' . $item->id; break; } $iParams = new JParameter($item->params); $iSecure = $iParams->def('secure', 0); if ($item->home == 1) { $item->url = JURI::base(); } elseif (strcasecmp(substr($item->url, 0, 4), 'http') && strpos($item->link, 'index.php?') !== false) { $item->url = JRoute::_($item->url, true, $iSecure); } else { $item->url = str_replace('&', '&', $item->url); } $item->route = $item->url; } else { $item->flink = $item->link; switch ($item->type) { case 'separator': continue; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid=') === false) { $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } $item->route = $item->flink; } $links[] = $item; } return $links; }
/** 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); }
/** * Utility function for writing a menu link */ function mosGetMenuLink($item, $level = 0, &$params, $havechild = null) { $app = JFactory::getApplication(); $menu = $app->getMenu(); if (!isset($item->flink)) { $item->flink = $item->link; switch ($item->type) { case 'separator': $item->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. $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } // get image if selected $item->title = htmlspecialchars($item->title); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', '')); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', '')); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', '')) : ''; } // Note. It is important to remove spaces between elements. $anchor_title = $item->anchor_title ? 'title="' . $item->anchor_title . '" ' : ''; if ($item->menu_image) { $item->params->get('menu_text', 1) ? $linktype = '<img src="' . $item->menu_image . '" alt="' . $item->title . '" /><span class="image-title">' . $item->title . '</span> ' : ($linktype = ' <img src="' . $item->menu_image . '" alt="' . $item->title . '" /> '); } else { $linktype = $item->title; } // Add classes $classplus = ''; if ($item->type == 'alias' && in_array($item->params->get('aliasoptions'), $this->path) || in_array($item->id, $this->path)) { $classplus = 'active '; } $classplus .= $item->anchor_css; $class = 'class="' . $classplus . '"'; if ($level == 0) { $class = 'class="dj-up_a' . (trim($classplus) ? ' ' . trim($classplus) : '') . '"'; } if ($havechild && $level != 0) { if (empty($classplus)) { $class = 'class="dj-more"'; } else { $class = 'class="dj-more-' . $classplus . '"'; } } $spanclass = ''; if ($havechild && $level == 0) { $spanclass = 'class="dj-drop" '; } if ($level == 0) { $linktype = '<span ' . $spanclass . '>' . $linktype . '</span>'; } $link = ''; switch ($item->browserNav) { // cases are slightly different default: case 0: // same window $link = '<a href="' . $item->flink . '" ' . $class . ' ' . $anchor_title . '>' . $linktype . '</a>'; break; case 1: // _blank $link = '<a href="' . $item->flink . '" ' . $class . ' ' . $anchor_title . ' target="_blank">' . $linktype . '</a>'; break; case 2: // open in a popup window $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'; $link = '<a href="' . $item->flink . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;" ' . $class . ' ' . $anchor_title . '>' . $linktype . '</a>'; break; case 3: // don't link it $link = '<a ' . $class . ' ' . $anchor_title . '>' . $linktype . '</a>'; break; } return $link; }
public static function getItems($params) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $menu = $app->getMenu(); /** if no active menu, use default */ $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); $levels = $user->getAuthorisedViewLevels(); asort($levels); $key = 'menu_items' . $params . implode(',', $levels) . '.' . $active->id; $cache = JFactory::getCache('mod_hrmenu', ''); if (!($items = $cache->get($key))) { /** initialise variables */ //$list = array(); $modules = array(); //$db = JFactory::getDBO(); $document = JFactory::getDocument(); /** load libraries */ jimport('joomla.application.module.helper'); $path = isset($active) ? $active->tree : array(); $start = (int) $params->get('hrmenu_start_level', 1); $end = (int) $params->get('hrmenu_end_level', 6); $items = $menu->getItems('menutype', $params->get('hrmenu_type', 'mainmenu')); /** return if no items */ if (!$items) { return false; } $lastItem = 0; /** list all modules */ $modulesList = modHrMenuHelper::createModuleList(); foreach ($items as $i => $item) { $isDependant = $params->get('hrmenu_dependant_items', 0) ? $start > 1 && !in_array($item->tree[$start - 2], $path) : false; if ($start && $start > $item->level || $end && $item->level > $end || $isDependant) { unset($items[$i]); continue; } $item->deeper = false; $item->shallower = false; $item->level_diff = 0; if (isset($items[$lastItem])) { $items[$lastItem]->deeper = $item->level > $items[$lastItem]->level; $items[$lastItem]->shallower = $item->level < $items[$lastItem]->level; $items[$lastItem]->level_diff = $items[$lastItem]->level - $item->level; } /** Test if this is the last item */ $item->is_end = !isset($items[$i + 1]); $item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true); $item->active = false; $item->flink = $item->link; switch ($item->type) { case 'separator': continue; case 'url': if (strpos($item->link, 'index.php?') === 0 && strpos($item->link, 'Itemid') == faslse) { $item->flink = $item->link . '&Itemid=' . $item->id; } $item->flink = JFilterOutput::ampReplace(htmlspecialchars($item->flink)); break; case 'alias': $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', '')); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', '')); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', '')) : ''; $item->ftitle = htmlspecialchars($item->title); $item->ftitle = JFilterOutput::ampReplace($item->ftitle); $parentItem = modHrMenuHelper::getParentItem($item->parent_id, $items); $item->class = ''; //$item->class = '_item' . $item->id; if (isset($active) && $active->id == $item->id) { $item->class .= ' current'; } /** add active class */ if (is_array($path) && ($item->type == 'alias' && in_array($item->params->get('aliasoptions'), $path) || in_array($item->id, $path))) { $item->class .= ' active'; $item->active = true; } // add the parent class if ($item->deeper) { $item->class .= ' deeper'; } if ($item->parent) { if ($params->get('hrmenu_layout', 'horizontal') != '_:flatlist') { $item->class .= ' parent'; } } // add last and first class $item->class .= $item->is_end ? ' last' : ''; $item->class .= !isset($items[$i - 1]) ? ' first' : ''; if (isset($items[$lastItem])) { $items[$lastItem]->class .= $items[$lastItem]->shallower ? ' last' : ''; $item->class .= $items[$lastItem]->deeper ? ' first' : ''; if (isset($items[$i + 1]) and $item->level - $items[$i + 1]->level > 1) { $parentItem->class .= ' last'; } } /** manage column */ $item->colwidth = $item->params->get('column_width', '160'); $item->createnewrow = $item->params->get('create_new_row', 0); $subWidthValues = NULL; preg_match('/\\[subwidth=([0-9]+)\\]/', $item->ftitle, $subWidthValues); $subWidth = isset($subWidthValues[1]) ? $subWidthValues[1] : ''; if ($subWidth) { $item->ftitle = preg_replace('/\\[subwidth=[0-9]+\\]/', '', $item->ftitle); } $item->submenucontainerwidth = $item->params->get('submenucontainerwidth', '') + $subWidth; $result = NULL; if ($item->params->get('createcolumn', 0)) { //TODO: clean if test work $item->column = true; if (isset($parentItem->submenuswidth)) { $parentItem->submenuswidth = strval($parentItem->submenuswidth) + strval($item->colwidth); } else { $parentItem->submenuswidth = strval($item->colwidth); } if (isset($items[$lastItem]) && $items[$lastItem]->deeper) { $items[$lastItem]->nextcolumnwidth = $item->colwidth; } } elseif (preg_match('/\\[col=([0-9]+)\\]/', $item->ftitle, $result)) { $item->ftitle = str_replace('[newrow]', '', $item->ftitle); $item->ftitle = preg_replace('/\\[col=[0-9]+)\\]/', '', $item->ftitle); $item->column = true; if (isset($parentItem->submenuswidth)) { $parentItem->submenuswidth = strval($parentItem->submenuswith) + strval($result[1]); } else { $parentItem->submenuswidth = strval($result[1]); } if (isset($items[$lastItem]) && $items[$lastItem]->deeper) { $items[$lastItem]->nextcolumnwidth = $result[1]; } $item->colwidth = $result[1]; } if (isset($parentItem->submenucontainerwidth) && $parentItem->submenucontainerwidth) { $parentItem->submenuswidth = $parentItem->submenucontainerwidth; } /** manage module */ $moduleId = $item->params->get('hrmenu_module', ''); $style = $item->params->get('force_module_title', 0) ? 'xhtml' : ''; if ($item->params->get('insert_module', 0)) { if (!isset($modules[$moduleId])) { $modules[$moduleId] = modHrMenuHelper::genModuleById($moduleId, $modulesList, $style); } $item->content = '<div class="hrmenu_mod">' . $modules[$moduleId] . '<div class="clr"></div></div>'; } elseif (preg_match('/\\[modid=([0-9]+)\\]/', $item->ftitle, $result)) { $item->ftitle = preg_match('/\\[modid=[0-9]+\\]/', '', $item->ftitle); $item->content = '<div class="hrmenu_mod"' . modHrMenuHelper::genModuleById($result[1], $modulesList, $style) . '<div class="clr"></div></div>'; } /** manage rel attribute */ $item->rel = ''; $rel = $item->params->get('hrmenu_relattr', ''); if ($rel) { $item->rel = ' rel="' . $rel . '"'; } elseif (preg_match('/\\[rel=[a-z]+\\]/i', '', $result)) { $item->ftitle = preg_replace('/\\[rel=[a-z]+\\]/i', '', $item->ftitle); $item->rel = ' rel="' . $result[1] . '"'; } /** manage link description */ $item->description = $item->params->get('hrmenu_des', ''); if ($item->description) { $item->desc = $item->description; } else { $result = explode("||", $item->ftitle); if (isset($result[1])) { $item->desc = $result[1]; } else { $item->desc = ''; } $item->ftitle = $result[0]; } /* add styles to the page for customization */ $menuID = $params->get('hrmenu_id', 'hrmenu'); $itemStyles = ""; $item->titleColor = $item->params->get('hrmenu_title_color', ''); if ($item->titleColor) { $itemStyles .= "div#" . $menuID . " ul.nav_hrmenu li.item" . $item->id . " > a div.hrmenu_title{ color:" . $item->titlecolor . " !important; } div#" . $menuID . " ul.nav_hrmenu li.item" . $item->id . " > span.separator div.hrmenu_title {color:" . $item->titlecolor . " !important; }"; } $item->desccolor = $item->params->get('hrmenu_desccolor', ''); if ($item->desccolor) { $itemStyles .= "div#" . $menuID . " ul.nav_hrmenu li.item" . $item->id . " > a span.hrmenu_desc{color:" . $item->desccolor . " !important; } div#" . $menuID . " ul.nav_hrmenu li.item" . $item->id . " > span.separator span.hrmenu_desc {color:" . $item->desccolor . " !important; }"; } if ($itemStyles) { $document->addStyleDeclaration($itemStyles); } // get plugin parameters that are used directly in the layout $item->leftmargin = $item->params->get('hrmenu_left_margin', ''); $item->topmargin = $item->params->get('hrmenu_top_margin', ''); $item->liclass = $item->params->get('hrmenu_li_class', ''); $item->colbgcolor = $item->params->get('hrmenu_col_bg_color', ''); $item->tagcoltitle = $item->params->get('hrmenu_tag_col_title', 'none'); $item->submenucontainerheight = $item->params->get('hrmenu_sub_menu_container_height', ''); $lastItem = $i; } if (isset($items[$lastItem])) { $items[$lastItem]->deeper = ($start ? $start : 1) > $items[$lastItem]->level; $items[$lastItem]->shallower = ($start ? $start : 1) < $items[$lastItem]->level; $items[$lastItem]->level_diff = $items[$lastItem]->level - ($start ? $start : 1); } $cache->store($items, $key); } return $items; }
public function getFullMenuItems($args){ $menu = JSite::getMenu(); // Get Menu Items $rows = $menu->getItems('menutype', $args['menutype']); $outputNodes = array(); foreach ($rows as $item) { //Create the new Node $node = new JoomlaRokMenuNode(); $node->setId($item->id); $node->setParent($item->parent); $node->setTitle(addslashes(htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8'))); $node->setParams($item->params); $node->setLink($item->link); // Menu Link is a special type that is a link to another item if ($item->type == 'menulink' && $newItem = $menu->getItem($item->query['Itemid'])) { $node->setAlias(true); $node->setLink($newItem->link); } // Get the icon image associated with the item $iParams = new JParameter($item->params); if ($args['menu_images'] && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) { $node->setImage(JURI::base(true) . '/images/stories/' . $iParams->get('menu_image')); if ($args['menu_images_link']) { $node->setLink(null); } } switch ($item->type) { case 'separator': $node->setType('separator'); break; case 'url': if ((strpos($node->getLink(), 'index.php?') === 0) && (strpos($node->getLink(), 'Itemid=') === false)) { $node->setLink($node->getLink() . '&Itemid=' . $node->getId()); } $node->setType('menuitem'); break; default : $router = JSite::getRouter(); if ($node->isAlias() && $newItem){ $menu_id = $item->query['Itemid']; } else { $menu_id = $node->getId(); } $link = ($router->getMode() == JROUTER_MODE_SEF)? 'index.php?Itemid=' . $menu_id : $node->getLink() . '&Itemid=' . $menu_id; $node->setLink($link); $node->setType('menuitem'); break; } if ($node->getLink() != null) { // set the target based on menu item options switch ($item->browserNav) { case 1: $node->setTarget('new'); break; case 2: $node->setLink(str_replace('index.php', 'index2.php', $node->getLink())); $node->setTarget('newnotool'); break; default: //$node->setTarget('current'); break; } // Get the final URL if ($item->home == 1) { // Set Home Links to the Base $node->setLink(JURI::base()); } if ($item->type != 'separator' && $item->type != 'url') { $iSecure = $iParams->get('secure', 0); if (array_key_exists('url_type',$args) && $args['url_type'] == 'full') { $url = JRoute::_($node->getLink(), true, $iSecure); $base = (!preg_match("/^http/", $node->getLink())) ? preg_replace("#/$#", "", JURI::base(false)) : ''; $routed = $base . $url; $secure = RokNavMenuTree::_getSecureUrl($routed, $iSecure); $node->setLink($secure); } else { $node->setLink(JRoute::_($node->getLink(), true, $iSecure)); } } else if ($item->type == 'url') { $node->setLink(str_replace('&', '&', $node->getLink())); } } $node->addListItemClass("item" . $node->getId()); $node->setAccess($item->access); $node->addSpanClass($node->getType()); $user =& JFactory::getUser(); if ($node->getAccess() <= $user->get('aid', 0)){ // Add node to output list $outputNodes[$node->getId()] = $node; } } return $outputNodes; }
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 ( preg_match('#^/?index.php.*option=(com_[^&]+)#',$node->link,$matches) ) { if ($node->option) { if (!empty($this->jview->extensions[$node->option])) { $node->uid = $node->option; $className = 'xmap_' . $node->option; $result = call_user_func_array(array($className, 'getTree'), array(&$this, &$node, &$this->jview->extensions[$node->option]->params)); } } //OSMapPlugins::printTree( $this, $node, $this->jview->extensions ); // Determine the menu entry's type and call it's handler } } $this->changeLevel(-1); }
public function getLink() { $itemtype = $this->get('type', 'url'); if ($itemtype == 'menulink' && false != $this->_aliasitem) { $tmp =& $this->_aliasitem; $tmp->parent = $this->parent; $itemtype = $tmp->get('type', 'url'); } else { if ($itemtype == 'alias') { $tmp =& $this; $tmp->id = $this->params->get('aliasoptions'); } else { $tmp =& $this; } } $menu_image = $tmp->params->get('menu_image'); if (isset($menu_image) && $menu_image != '-1' && !empty($menu_image)) { $this->addClass('showicon'); if (!$this->j15) { $menu_image_url = $menu_image; } else { $menu_image_url = JURI::base(true) . "/images/stories/{$menu_image}"; } $menu_image_open = "<span class=\"menu-icon\" style=\"background-image:url({$menu_image_url});\">"; $menu_image_close = "</span>"; } else { $menu_image_open = ""; $menu_image_close = ""; } $menu_title = "<span class=\"menu-title\">" . htmlspecialchars($this->title) . "</span>"; $menu_desc = $this->params->get('ytext_desc', null); $menu_desc = isset($menu_desc) && !empty($menu_desc) ? "<span class=\"menu-desc\">" . htmlspecialchars($menu_desc) . "</span>" : ""; $show_desc = empty($menu_desc) ? "" : " showdesc"; if (!empty($show_desc)) { $this->addClass('showdesc'); } $anchor_innerHTML = $menu_image_open . $menu_title . $menu_desc . $menu_image_close; $anchor_html = ""; $anchor_href = ""; $anchor_class = $this->getClass(); switch ($itemtype) { case 'separator': $anchor_html = "<div class=\"{$anchor_class} separator\">{$anchor_innerHTML}</div>"; break; case 'url': if (strpos($tmp->link, "index.php?") === 0 && strpos($tmp->link, "Itemid=") === false) { $anchor_href = $tmp->link . "&Itemid=" . $tmp->id; } else { $anchor_href = empty($tmp->link) ? '#' : $tmp->link; } break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $anchor_href = "index.php?Itemid=" . $tmp->id; } else { $anchor_href = $tmp->link . "&Itemid=" . $tmp->id; } } if (!empty($anchor_href)) { // Handle SSL links $iSecure = $tmp->params->get('secure', 0); if ($tmp->home == 1) { $anchor_href = JURI::base(); } elseif (strcasecmp(substr($anchor_href, 0, 4), 'http') && strpos($tmp->link, "index.php?") !== false) { $anchor_href = JRoute::_($anchor_href, true, $iSecure); } else { $anchor_href = str_replace('&', '&', $anchor_href); } //echo "<pre>$anchor_href</pre>";die(); switch ($tmp->browserNav) { default: case 0: // _top $anchor_html = "<a class=\"{$anchor_class}\" href=\"{$anchor_href}\">{$anchor_innerHTML}</a>"; break; case 1: // _blank $anchor_html = "<a class=\"{$anchor_class}\" href=\"{$anchor_href}\" target=\"_blank\">{$anchor_innerHTML}</a>"; break; case 2: // window.open $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->params->get('window_open'); // hrm...this is a bit dickey $link = str_replace('index.php', 'index2.php', $anchor_href); $anchor_html = "<a class=\"{$anchor_class}\" href=\"{$link}\" onclick=\"window.open(this.href,'targetWindow','{$attribs}');return false;\">{$anchor_innerHTML}</a>"; break; } } else { if ($itemtype != 'separator') { $anchor_html = "<a>{$anchor_innerHTML}</a>"; } } return $anchor_html; }
/** * * Return the routed (relative) URL * * @param string $url Visited full URL * @param array $vars List of variables to use (if empty use all current variables) * * @return string The routed (relative) URL * */ private static function route_url($url, $vars) { $uri_visited_full_url = JURI::getInstance($url); $router = JSite::getRouter(); $parsed = $router->parse($uri_visited_full_url); $suffix = isset($parsed['format']) ? $parsed['format'] : ''; if (@count($vars)) { // First drop unwanted vars foreach ($vars as $k => $v) { if (preg_match('/^!(.*)/', $k, $m) === 1) { if (isset($parsed[$m[1]])) { unset($parsed[$m[1]]); } unset($vars[$k]); } } if (@count($vars)) { foreach ($vars as $k => $v) { if ($v === null) { if (isset($parsed[$k])) { $vars[$k] = $parsed[$k]; } else { unset($vars[$k]); } } } $p =& $vars; } else { $p =& $parsed; } } else { // Variables to use/not use are not specified foreach ($parsed as $k => $v) { if ($v === null) { unset($parsed[$k]); } } $p =& $parsed; } if (isset($p['option'])) { // For components search for a menu item $q = $p; unset($q['Itemid']); unset($q['format']); foreach ($q as $k => $v) { // Remove the slug part if present $parts = explode(":", $v); $q[$k] = $parts[0]; } // Build the URL to route $link = 'index.php'; foreach ($q as $k => $v) { $link .= ($link === 'index.php' ? '?' : '&') . $k . '=' . $v; } $routed_link = JRoute::_($link, false); $app = JFactory::getApplication(); $menu = $app->getMenu(); $items = $menu->getItems('component', $q['option']); $found = false; $menu_route = ''; foreach ($items as $k => $v) { $current_link = JRoute::_($v->link, false); if ($current_link == $routed_link) { $found = true; $menu_route = $v->route; break; } } if ($found) { $sef_prefix = $app->getCfg('sef_rewrite') ? '' : 'index.php/'; $routed = '/' . $sef_prefix . trim($menu_route, '/') . (strlen($suffix) > 0 ? '.' . $suffix : ''); return $routed; } } // Build the URL to route $build = 'index.php'; foreach ($p as $pk => $pv) { $build .= ($build === 'index.php' ? '?' : '&') . $pk . '=' . $pv; } $routed = JRoute::_($build, false); return $routed; }
public function getLink() { $itemtype = $this->get('type', 'url'); if ($itemtype == 'menulink' && false != $this->_aliasitem) { $tmp =& $this->_aliasitem; $tmp->parent = $this->parent; $itemtype = $tmp->get('type', 'url'); } else { if ($itemtype == 'alias') { $tmp =& $this; $tmp->id = $this->params->get('aliasoptions'); } else { $tmp =& $this; } } $menu_image = $tmp->params->get('menu_image'); if (isset($menu_image) && $menu_image != '-1' && !empty($menu_image)) { $this->addClass('showicon'); $menu_image_url = JURI::base(true) . "/{$menu_image}"; $menu_image_open = "<span class=\"menu-icon\">"; $menu_image_child = $this->level == 1 && (count($this->_child) > 1 || count($this->loadModules())) ? " <img src=\"{$menu_image_url}\" alt=\"\" />" : ""; $menu_image_close = "</span>"; } else { $menu_arrow = ""; if (count($this->_child) > 1 || count($this->loadModules())) { //if($this->level==1) $menu_arrow = "<i class=\"fa fa-caret-down\"></i>"; //else if ($this->level > 1) $menu_arrow = "<i class=\"fa fa-caret-right\"></i>"; } $menu_image_open = ""; //$menu_image_child = ((count($this->_child) > 1 || count($this->loadModules() ) ))? " <i class=\"fa fa-caret-down\"></i>" : ""; $menu_image_child = $menu_arrow; $menu_image_close = ""; } $icon_menu = trim($tmp->params->get('menu-anchor_css')) != '' ? trim($tmp->params->get('menu-anchor_css')) : ''; $icon_menu = $icon_menu != '' ? '<i class="' . $icon_menu . '"></i>' : ''; $title_attr = trim($tmp->params->get('menu-anchor_title')) != '' ? trim($tmp->params->get('menu-anchor_title')) : htmlspecialchars($this->title); $title_attr = $title_attr != '' ? ' title="' . $title_attr . '"' : ''; $menu_title = "<span class=\"menu-title\">" . $icon_menu . htmlspecialchars($this->title) . "</span>"; $menu_desc = $this->params->get('ytext_desc', null); $menu_desc = isset($menu_desc) && !empty($menu_desc) ? "<span class=\"menu-desc\">" . htmlspecialchars($menu_desc) . "</span>" : ""; $show_desc = empty($menu_desc) ? "" : " showdesc"; if (!empty($show_desc)) { $this->addClass('showdesc'); } $anchor_innerHTML = $menu_image_open . $menu_title . $menu_desc . $menu_image_child . $menu_image_close; $anchor_html = ""; $anchor_href = ""; $anchor_class = $this->getClass() . ' item-link'; switch ($itemtype) { case 'separator': $anchor_html = "<div" . $title_attr . " class=\"{$anchor_class} separator\">{$anchor_innerHTML}</div>"; break; case 'url': if (strpos($tmp->link, "index.php?") === 0 && strpos($tmp->link, "Itemid=") === false) { $anchor_href = $tmp->link . "&Itemid=" . $tmp->id; } else { $anchor_href = empty($tmp->link) ? '#' : $tmp->link; } break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $anchor_href = "index.php?Itemid=" . $tmp->id; } else { $anchor_href = $tmp->link . "&Itemid=" . $tmp->id; } } if (!empty($anchor_href)) { // Handle SSL links $iSecure = $tmp->params->get('secure', 0); if ($tmp->home == 1) { $anchor_href = JURI::base(); } elseif (strcasecmp(substr($anchor_href, 0, 4), 'http') && strpos($tmp->link, "index.php?") !== false) { $anchor_href = JRoute::_($anchor_href, true, $iSecure); } else { $anchor_href = str_replace('&', '&', $anchor_href); } //echo "<pre>$anchor_href</pre>";die(); switch ($tmp->browserNav) { default: case 0: // _top $anchor_html = "<a" . $title_attr . " class=\"{$anchor_class}\" href=\"{$anchor_href}\">{$anchor_innerHTML}</a>"; break; case 1: // _blank $anchor_html = "<a" . $title_attr . " class=\"{$anchor_class}\" href=\"{$anchor_href}\" target=\"_blank\">{$anchor_innerHTML}</a>"; break; case 2: // window.open $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->params->get('window_open'); // hrm...this is a bit dickey $link = str_replace('index.php', 'index2.php', $anchor_href); $anchor_html = "<a" . $title_attr . " class=\"{$anchor_class}\" href=\"{$link}\" onclick=\"window.open(this.href,'targetWindow','{$attribs}');return false;\">{$anchor_innerHTML}</a>"; break; } } else { if ($itemtype != 'separator') { $anchor_html = "<a>{$anchor_innerHTML}</a>"; } } return $anchor_html; }
/** * Load menu * * @return void */ function loadMenu() { $list = array(); $db = JFactory::getDbo(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $menu = $app->getMenu(); //get user access level - used to check the access level setting for menu items $aid = $user->getAuthorisedViewLevels(); // If no active menu, use default $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); //start - end for fetching menu items $start = (int) $this->getParam('startlevel'); if ($start < 1) { $start = 1; } //first level $this->_start = $start; $end = (int) $this->getParam('endlevel'); $this->open = isset($active) ? $active->tree : array(); $rows = $menu->getItems('menutype', $this->getParam('menutype')); if (!count($rows)) { return; } // first pass - collect children $children = array(); $cacheIndex = array(); $this->items = array(); foreach ($rows as $index => $v) { //bypass items not in range if ($start > 0 && $start > $v->level || $end > 0 && $v->level > $end || $start > 1 && !in_array($v->tree[0], $active->tree)) { continue; } //1.6 compatible if (isset($v->title)) { $v->name = $v->title; } if (isset($v->parent_id)) { $v->parent = $v->parent_id; } $v->name = str_replace('&', '&', str_replace('&', '&', $v->name)); if (in_array($v->access, $aid)) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); $v->megaparams = new JObject(); $v->jparams = $megaparams = new JObject(json_decode($v->params)); if ($megaparams) { foreach (get_object_vars($megaparams) as $mega_name => $mega_value) { if (preg_match('/mega_(.+)/', $mega_name, $matches)) { if ($matches[1] == 'colxw') { if (preg_match_all('/([^\\s]+)=([^\\s]+)/', $mega_value, $colwmatches)) { for ($i = 0; $i < count($colwmatches[0]); $i++) { $v->megaparams->set($colwmatches[1][$i], $colwmatches[2][$i]); } } } else { if (is_array($mega_value)) { $mega_value = implode(',', $mega_value); } $v->megaparams->set($matches[1], $mega_value); } } } } //reset cols for group item //if ($v->megaparams->get('group')) $v->megaparams->set('cols', 1); if ($this->getParam('megamenu')) { $modules = $this->loadModules($v->megaparams); //Update title: clear title if not show - Not clear title => causing none title when showing menu in other module //if (!$v->megaparams->get ('showtitle', 1)) $v->name = ''; if ($modules && count($modules) > 0) { $v->content = ""; $total = count($modules); $cols = min($v->megaparams->get('cols'), $total); for ($col = 0; $col < $cols; $col++) { $pos = $col == 0 ? 'first' : ($col == $cols - 1 ? 'last' : ''); if ($cols > 1) { $v->content .= $this->beginSubMenuModules($v->id, 1, $pos, $col, true); } $i = $col; while ($i < $total) { $mod = $modules[$i]; if (!isset($mod->name)) { $mod->name = $mod->module; } $i += $cols; $mod_params = new JObject(json_decode($mod->params)); $v->content .= $this->beginSubMenuModules($v, 1, $pos, $col, true); $v->content .= $this->loadModule($mod->id); $v->content .= $this->endSubMenuModules($v, 1, true); } if ($cols > 1) { $v->content .= $this->endSubMenuModules($v->id, 1, true); } } $v->cols = $cols; $v->content = trim($v->content); $this->items[$v->id] = $v; } } $v->flink = $v->link; switch ($v->type) { case 'separator': // No further action needed. continue; case 'url': if (strpos($v->link, 'index.php?') === 0 && strpos($v->link, 'Itemid=') === false) { // If this is an internal Joomla link, ensure the Itemid is set. $v->flink = $v->link . '&Itemid=' . $v->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $v->flink = 'index.php?Itemid=' . $v->jparams->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $v->flink = 'index.php?Itemid=' . $v->id; } else { $v->flink .= '&Itemid=' . $v->id; } break; } $v->url = $v->flink = JRoute::_($v->flink); // Handle SSL links //$iParams = $this->createParameterObject($v->jparams); //$iSecure = $iParams->def('secure', 0); /*if ($v->home == 1) { $v->url = JURI::base(); } elseif (strcasecmp(substr($v->url, 0, 4), 'http') && (strpos($v->link, 'index.php?') !== false)) { $v->url = JRoute::_($v->url, true, $iSecure); } else { $v->url = str_replace('&', '&', $v->url); }*/ if ($v->home == 1) { $v->url = JURI::base(); } //calculate menu column if (!isset($v->clssfx)) { $v->clssfx = $megaparams->get('pageclass_sfx', ''); if ($v->megaparams->get('cols')) { $v->cols = $v->megaparams->get('cols'); $v->col = array(); for ($i = 0; $i < $v->cols; $i++) { if ($v->megaparams->get("col{$i}")) { $v->col[$i] = $v->megaparams->get("col{$i}"); } } } } $v->_idx = count($list); array_push($list, $v); $children[$pt] = $list; $cacheIndex[$v->id] = $index; $this->items[$v->id] = $v; } } $this->children = $children; //unset item load module but no content foreach ($this->items as $v) { if (($v->megaparams->get('subcontent') || $v->megaparams->get('modid') || $v->megaparams->get('modname') || $v->megaparams->get('modpos')) && !isset($this->children[$v->id]) && (!isset($v->content) || !$v->content)) { $this->remove_item($this->items[$v->id]); unset($this->items[$v->id]); } } //echo "<pre>";print_r($this->items);echo "</pre>"; }
/** * Render menu instance(s) by ID. * * @param mixed $id Menu instance ID or array of Menu instance ID to be rendered. * * @return string */ public static function renderMenu($id) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $active_id = isset($active) ? $active->id : $menu->getDefault()->id; $path = isset($active) ? $active->tree : array(); $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('menutype')->from('#__menu_types')->where('id = ' . $db->Quote($id)); $db->setQuery($query); $menuType = $db->loadResult(); $items = $menu->getItems('menutype', $menuType); $lastitem = 0; $start = 1; $end = 0; $showAll = 1; if ($items) { foreach ($items as $i => $item) { if ($start && $start > $item->level || $end && $item->level > $end || !$showAll && $item->level > 1 && !in_array($item->parent_id, $path) || $start > 1 && !in_array($item->tree[$start - 2], $path)) { unset($items[$i]); continue; } $item->deeper = false; $item->shallower = false; $item->level_diff = 0; if (isset($items[$lastitem])) { $items[$lastitem]->deeper = $item->level > $items[$lastitem]->level; $items[$lastitem]->shallower = $item->level < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - $item->level; } $item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true); $lastitem = $i; $item->active = false; $item->flink = $item->link; // Reverted back for CMS version 2.5.6 switch ($item->type) { case 'separator': // No further action needed. continue; 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. $item->flink = $item->link . '&Itemid=' . $item->id; } break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } $item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : ''; } if (isset($items[$lastitem])) { $items[$lastitem]->deeper = ($start ? $start : 1) > $items[$lastitem]->level; $items[$lastitem]->shallower = ($start ? $start : 1) < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - ($start ? $start : 1); } } echo "<ul class=\"menu jsn-menu jsn-menu-mobile jsn-toggle menu-stickymenu\">"; foreach ($items as $i => &$item) { $class = 'item-' . $item->id; if ($item->id == $active_id) { $class .= ' current'; } if (in_array($item->id, $path)) { $class .= ' active'; } elseif ($item->type == 'alias') { $aliasToId = $item->params->get('aliasoptions'); if (count($path) > 0 && $aliasToId == $path[count($path) - 1]) { $class .= ' active'; } elseif (in_array($aliasToId, $path)) { $class .= ' alias-parent-active'; } } if (!empty($item->deeper)) { $class .= ' deeper'; } if (!empty($item->parent)) { $class .= ' parent'; } if (!empty($class)) { $class = ' class="' . trim($class) . '"'; } echo '<li' . $class . '>'; // Render the menu item. // Note. It is important to remove spaces between elements. $class = !empty($item->anchor_css) ? 'class="' . $item->anchor_css . '" ' : ''; $title = !empty($item->anchor_title) ? 'title="' . $item->anchor_title . '" ' : ''; if (!empty($item->menu_image)) { $item->params->get('menu_text', 1) ? $linktype = '<img src="' . $item->menu_image . '" alt="' . $item->title . '" /><span class="image-title">' . $item->title . '</span> ' : ($linktype = '<img src="' . $item->menu_image . '" alt="' . $item->title . '" />'); } else { $linktype = $item->title; } $flink = !empty($item->flink) ? $item->flink : ""; $flink = JFilterOutput::ampReplace(htmlspecialchars($flink)); switch ($item->browserNav) { default: case 0: ?> <a <?php echo $class; ?> href="<?php echo $flink; ?> " <?php echo $title; ?> ><?php echo $linktype; ?> </a><?php break; case 1: // _blank ?> <a <?php echo $class; ?> href="<?php echo $flink; ?> " target="_blank" <?php echo $title; ?> ><?php echo $linktype; ?> </a><?php break; } // The next item is deeper. if (!empty($item->deeper)) { echo '<ul>'; } elseif (!empty($item->shallower)) { echo '</li>'; echo str_repeat('</ul></li>', $item->level_diff); } else { echo '</li>'; } } echo "</ul>"; }
/** * Get a list of the menu items. * * @param JRegistry $params The module options. * * @return array */ static function getItems(&$params) { $app = JFactory::getApplication(); $menu = $app->getMenu(); // If no active menu, use default $active = $menu->getActive() ? $menu->getActive() : $menu->getDefault(); // $user = JFactory::getUser(); // $levels = $user->getAuthorisedViewLevels(); // asort($levels); // $key = 'menu_items' . $params . implode(',', $levels) . '.' . $active->id; // $cache = JFactory::getCache('mod_maximenuck', ''); // if (!($items = $cache->get($key)) || (int) $params->get('cache') == '0') { // Initialise variables. $list = array(); $modules = array(); $db = JFactory::getDbo(); $document = JFactory::getDocument(); // load the libraries jimport('joomla.application.module.helper'); $path = isset($active) ? $active->tree : array(); $start = (int) $params->get('startLevel'); $end = (int) $params->get('endLevel'); $items = $menu->getItems('menutype', $params->get('menutype')); // if no items in the menu then exit if (!$items) { return false; } $lastitem = 0; // list all modules $modulesList = modmaximenuckHelper::CreateModulesList(); foreach ($items as $i => $item) { $isdependant = $params->get('dependantitems', false) ? $start > 1 && !in_array($item->tree[$start - 2], $path) : false; if ($start && $start > $item->level || $end && $item->level > $end || $isdependant) { unset($items[$i]); continue; } $item->deeper = false; $item->shallower = false; $item->level_diff = 0; if (isset($items[$lastitem])) { $items[$lastitem]->deeper = $item->level > $items[$lastitem]->level; $items[$lastitem]->shallower = $item->level < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - $item->level; } // Test if this is the last item $item->is_end = !isset($items[$i + 1]); $item->parent = (bool) $menu->getItems('parent_id', (int) $item->id, true); $item->active = false; $item->current = false; $item->flink = $item->link; switch ($item->type) { case 'separator': // No further action needed. continue; 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. $item->flink = $item->link . '&Itemid=' . $item->id; } $item->flink = JFilterOutput::ampReplace(htmlspecialchars($item->flink)); break; case 'alias': // If this is an alias use the item id stored in the parameters to make the link. $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions'); break; default: $router = JSite::getRouter(); if ($router->getMode() == JROUTER_MODE_SEF) { $item->flink = 'index.php?Itemid=' . $item->id; } else { $item->flink .= '&Itemid=' . $item->id; } break; } if (strcasecmp(substr($item->flink, 0, 4), 'http') && strpos($item->flink, 'index.php?') !== false) { $item->flink = JRoute::_($item->flink, true, $item->params->get('secure')); } else { $item->flink = JRoute::_($item->flink); } //$item->title = htmlspecialchars($item->title); $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', '')); $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', '')); $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', '')) : ''; // ---------------- begin the maximenu work on items -------------------- $item->ftitle = htmlspecialchars($item->title); $item->ftitle = JFilterOutput::ampReplace($item->ftitle); $parentItem = modMaximenuckHelper::getParentItem($item->parent_id, $items); // ---- add some classes ---- // add itemid class $item->classe = ' item' . $item->id; // add current class if (isset($active) && $active->id == $item->id) { $item->classe .= ' current'; $item->current = true; } // add active class if (is_array($path) && ($item->type == 'alias' && in_array($item->params->get('aliasoptions'), $path) || in_array($item->id, $path))) { $item->classe .= ' active'; $item->active = true; } // add the parent class if ($item->deeper) { $item->classe .= ' deeper'; } if ($item->parent) { if ($params->get('layout', 'default') != '_:flatlist') { $item->classe .= ' parent'; } } // add last and first class $item->classe .= $item->is_end ? ' last' : ''; $item->classe .= !isset($items[$i - 1]) ? ' first' : ''; if (isset($items[$lastitem])) { $items[$lastitem]->classe .= $items[$lastitem]->shallower ? ' last' : ''; $item->classe .= $items[$lastitem]->deeper ? ' first' : ''; if (isset($items[$i + 1]) and $item->level - $items[$i + 1]->level > 1 and $parentItem) { $parentItem->classe .= ' last'; } } // ---- manage params ---- // -- manage column -- $item->colwidth = $item->params->get('maximenu_colwidth', '180'); $item->createnewrow = $item->params->get('maximenu_createnewrow', 0) || stristr($item->ftitle, '[newrow]'); // check if there is a width for the subcontainer preg_match('/\\[subwidth=([0-9]+)\\]/', $item->ftitle, $subwidth); $subwidth = isset($subwidth[1]) ? $subwidth[1] : ''; if ($subwidth) { $item->ftitle = preg_replace('/\\[subwidth=[0-9]+\\]/', '', $item->ftitle); } $item->submenucontainerwidth = $item->params->get('maximenu_submenucontainerwidth', '') ? $item->params->get('maximenu_submenucontainerwidth', '') : $subwidth; if ($item->params->get('maximenu_createcolumn', 0)) { $item->colonne = true; //$parentItem = modMaximenuckHelper::getParentItem($item->parent_id, $items); // add the value to give the total parent container width if (isset($parentItem->submenuswidth)) { $parentItem->submenuswidth = strval($parentItem->submenuswidth) + strval($item->colwidth); } else { $parentItem->submenuswidth = strval($item->colwidth); } // if specified by user with the plugin, then give the width to the parent container //if (isset($parentItem->submenucontainerwidth)) $parentItem->submenuswidth = $parentItem->submenucontainerwidth; if (isset($items[$lastitem]) && $items[$lastitem]->deeper) { $items[$lastitem]->nextcolumnwidth = $item->colwidth; } //else { $item->columnwidth = $item->colwidth; //} } elseif (preg_match('/\\[col=([0-9]+)\\]/', $item->ftitle, $resultat)) { $item->ftitle = str_replace('[newrow]', '', $item->ftitle); $item->ftitle = preg_replace('/\\[col=[0-9]+\\]/', '', $item->ftitle); $item->colonne = true; //$parentItem = modMaximenuckHelper::getParentItem($item->parent_id, $items); if (isset($parentItem->submenuswidth)) { $parentItem->submenuswidth = strval($parentItem->submenuswidth) + strval($resultat[1]); } else { if (isset($parentItem)) { $parentItem->submenuswidth = strval($resultat[1]); } } if (isset($items[$lastitem]) && $items[$lastitem]->deeper) { $items[$lastitem]->nextcolumnwidth = $resultat[1]; } //else { $item->columnwidth = $resultat[1]; //} } if (isset($parentItem->submenucontainerwidth) and $parentItem->submenucontainerwidth) { $parentItem->submenuswidth = $parentItem->submenucontainerwidth; } // -- manage module -- $moduleid = $item->params->get('maximenu_module', ''); $style = $item->params->get('maximenu_forcemoduletitle', 0) ? 'xhtml' : ''; if ($item->params->get('maximenu_insertmodule', 0)) { if (!isset($modules[$moduleid])) { $modules[$moduleid] = modmaximenuckHelper::GenModuleById($moduleid, $params, $modulesList, $style); } $item->content = '<div class="maximenuck_mod">' . $modules[$moduleid] . '<div class="clr"></div></div>'; } elseif (preg_match('/\\[modid=([0-9]+)\\]/', $item->ftitle, $resultat)) { $item->ftitle = preg_replace('/\\[modid=[0-9]+\\]/', '', $item->ftitle); $item->content = '<div class="maximenuck_mod">' . modmaximenuckHelper::GenModuleById($resultat[1], $params, $modulesList, $style) . '<div class="clr"></div></div>'; } // -- manage rel attribute -- $item->rel = ''; if ($rel = $item->params->get('maximenu_relattr', '')) { $item->rel = ' rel="' . $rel . '"'; } elseif (preg_match('/\\[rel=([a-z]+)\\]/i', $item->ftitle, $resultat)) { $item->ftitle = preg_replace('/\\[rel=[a-z]+\\]/i', '', $item->ftitle); $item->rel = ' rel="' . $resultat[1] . '"'; } // -- manage link description -- $item->description = $item->params->get('maximenu_desc', ''); if ($item->description) { $item->desc = $item->description; } else { $resultat = explode("||", $item->ftitle); if (isset($resultat[1])) { $item->desc = $resultat[1]; } else { $item->desc = ''; } $item->ftitle = $resultat[0]; } // add the anchor tag $item->flink .= $item->params->get('maximenu_anchor', '') ? '#' . $item->params->get('maximenu_anchor', '') : ''; // add styles to the page for customization $menuID = $params->get('menuid', 'maximenuck'); $itemstyles = ""; if ($item->titlecolor = $item->params->get('maximenu_titlecolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > a span.titreck {color:" . $item->titlecolor . " !important;} div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > span.separator span.titreck {color:" . $item->titlecolor . " !important;}"; } if ($item->desccolor = $item->params->get('maximenu_desccolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > a span.descck {color:" . $item->desccolor . " !important;} div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > span.separator span.descck {color:" . $item->desccolor . " !important;}"; } if ($item->titlehovercolor = $item->params->get('maximenu_titlehovercolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > a:hover span.titreck {color:" . $item->titlehovercolor . " !important;} div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > span.separator:hover span.titreck {color:" . $item->titlehovercolor . " !important;}"; } if ($item->deschovercolor = $item->params->get('maximenu_deschovercolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > a:hover span.descck {color:" . $item->deschovercolor . " !important;} div#" . $menuID . " ul.maximenuck li.item" . $item->id . " > span.separator:hover span.descck {color:" . $item->deschovercolor . " !important;}"; } if ($item->titleactivecolor = $item->params->get('maximenu_titleactivecolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.active.item" . $item->id . " > a span.titreck {color:" . $item->titleactivecolor . " !important;} div#" . $menuID . " ul.maximenuck li.active.item" . $item->id . " > span.separator span.titreck {color:" . $item->titleactivecolor . " !important;}"; } if ($item->descactivecolor = $item->params->get('maximenu_descactivecolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.active.item" . $item->id . " > a span.descck {color:" . $item->descactivecolor . " !important;} div#" . $menuID . " ul.maximenuck li.active.item" . $item->id . " > span.separator span.descck {color:" . $item->descactivecolor . " !important;}"; } if ($item->libgcolor = $item->params->get('maximenu_libgcolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . " {background:" . $item->libgcolor . " !important;}"; } if ($item->lihoverbgcolor = $item->params->get('maximenu_lihoverbgcolor', '')) { $itemstyles .= "div#" . $menuID . " ul.maximenuck li.item" . $item->id . ":hover {background:" . $item->lihoverbgcolor . " !important;}"; } if ($itemstyles) { $document->addStyleDeclaration($itemstyles); } // get plugin parameters that are used directly in the layout $item->leftmargin = $item->params->get('maximenu_leftmargin', ''); $item->topmargin = $item->params->get('maximenu_topmargin', ''); $item->liclass = $item->params->get('maximenu_liclass', ''); $item->colbgcolor = $item->params->get('maximenu_colbgcolor', ''); $item->tagcoltitle = $item->params->get('maximenu_tagcoltitle', 'none'); $item->submenucontainerheight = $item->params->get('maximenu_submenucontainerheight', ''); // set the item styles if the plugin is enabled if (JPluginHelper::isEnabled('system', 'maximenuckparams')) { $itemcss = self::injectItemCss($item, $menuID, $params); if ($itemcss) { $document->addStyleDeclaration($itemcss); } } $lastitem = $i; } // end of boucle for each items // give the correct deep infos for the last item if (isset($items[$lastitem])) { $items[$lastitem]->deeper = ($start ? $start : 1) > $items[$lastitem]->level; $items[$lastitem]->shallower = ($start ? $start : 1) < $items[$lastitem]->level; $items[$lastitem]->level_diff = $items[$lastitem]->level - ($start ? $start : 1); } // $cache->store($items, $key); // } return $items; }
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; }
function _getItemData(&$params, $item) { $data = 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 = '<span><![CDATA[' . $item->name . ']]></span>'; $tmp->mid = $item->id; $tmp->parent = $item->parent; } else { return false; } } else { $tmp = clone $item; $tmp->name = '<span><![CDATA[' . $item->name . ']]></span>'; } $iParams = new JParameter($tmp->params); if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1) { switch ($params->get('menu_images_align', 0)) { case 0: $imgalign = 'align="left"'; break; case 1: $imgalign = 'align="right"'; break; default: $imgalign = ''; break; } $image = '<img src="' . JURI::base(true) . '/images/stories/' . $iParams->get('menu_image') . '" ' . $imgalign . ' alt="' . $item->alias . '" />'; if ($tmp->ionly) { $tmp->name = null; } } else { $image = null; } switch ($tmp->type) { case 'separator': return '<span class="separator">' . $image . $tmp->name . '</span>'; 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; } break; default: $router = JSite::getRouter(); $tmp->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid=' . $tmp->id : $tmp->link . '&Itemid=' . $tmp->id; break; } // Print a link if it exists if ($tmp->url != null) { // Handle SSL links $iSecure = $iParams->def('secure', 0); if ($tmp->home == 1) { $tmp->url = JURI::base(); } elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && strpos($tmp->link, 'index.php?') !== false) { $tmp->url = JRoute::_($tmp->url, true, $iSecure); } else { $tmp->url = str_replace('&', '&', $tmp->url); } switch ($tmp->browserNav) { default: case 0: // _top $data = '<a href="' . $tmp->url . '">' . $image . $tmp->name . '</a>'; break; case 1: // _blank $data = '<a href="' . $tmp->url . '" target="_blank">' . $image . $tmp->name . '</a>'; break; case 2: // window.open $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,' . $this->_params->get('window_open'); // hrm...this is a bit dickey $link = str_replace('index.php', 'index2.php', $tmp->url); $data = '<a href="' . $link . '" onclick="window.open(this.href,\'targetWindow\',\'' . $attribs . '\');return false;">' . $image . $tmp->name . '</a>'; break; } } else { $data = '<a>' . $image . $tmp->name . '</a>'; } return $data; }