本文整理汇总了PHP中JSite::getRouter方法的典型用法代码示例。如果您正苦于以下问题:PHP JSite::getRouter方法的具体用法?PHP JSite::getRouter怎么用?PHP JSite::getRouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSite
的用法示例。
在下文中一共展示了JSite::getRouter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FGetLink
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);
}
示例2: buildLink
/**
* 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);
}
}
示例3: getMenu
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;
}
示例4: render
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>';
}
示例5: __construct
/**
* 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);
}
}
}
}
示例6: B2JGetLink
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);
}
示例7: _getItemData
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;
//.........这里部分代码省略.........
示例8: buildInternalUrl
/**
* 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;
}
示例9: getList
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;
}
示例10: getFullMenuItems
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()));
}
}
}
//.........这里部分代码省略.........
示例11: initMenu
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) : '';
}
}
示例12: loadMenu
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;
}
示例13: mosGetLink
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;
}
示例14: _getItemData
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;
//.........这里部分代码省略.........
示例15: GetMenu
//.........这里部分代码省略.........
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;
}