mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-27 07:33:41 +00:00
Fixed issue [#21791] Menu Item Alias (Stian Totland, Christophe Demko).
git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@18917 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
parent
4fd8f6a7c0
commit
d57d71371b
|
@ -21,6 +21,9 @@ class JPathwaySite extends JPathway
|
|||
* Class constructor.
|
||||
*
|
||||
* @param array
|
||||
*
|
||||
* @return JPathwaySite
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
|
@ -30,13 +33,11 @@ class JPathwaySite extends JPathway
|
|||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
|
||||
if ($item = $menu->getActive())
|
||||
{
|
||||
if ($item = $menu->getActive()) {
|
||||
$menus = $menu->getMenu();
|
||||
$home = $menu->getDefault();
|
||||
|
||||
if (is_object($home) && ($item->id != $home->id))
|
||||
{
|
||||
if (is_object($home) && ($item->id != $home->id)) {
|
||||
foreach($item->tree as $menupath)
|
||||
{
|
||||
$url = '';
|
||||
|
@ -44,17 +45,34 @@ class JPathwaySite extends JPathway
|
|||
|
||||
switch($link->type)
|
||||
{
|
||||
case 'menulink':
|
||||
case 'url':
|
||||
$url = $link->link;
|
||||
break;
|
||||
|
||||
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:
|
||||
$url = 'index.php?Itemid='.$link->id;
|
||||
$router = JSite::getRouter();
|
||||
if ($router->getMode() == JROUTER_MODE_SEF) {
|
||||
$url = 'index.php?Itemid='.$link->id;
|
||||
}
|
||||
else {
|
||||
$url .= '&Itemid='.$link->id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$this->addItem($menus[$menupath]->title, $url);
|
||||
|
@ -62,4 +80,4 @@ class JPathwaySite extends JPathway
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ $ -> Language fix or change
|
|||
# Fixed issue [#22212] Create New Module (Brian Teeman, Michael Babker).
|
||||
# Fixed issue [#22244] control_panel0004Test.php system test failing (Matt Thomas).
|
||||
# Fixed issue [#22021] ACL System Tests (Matt Thomas).
|
||||
# Fixed issue [#21791] Menu Item Alias (Stian Totland, Christophe Demko).
|
||||
|
||||
14-Sep-2010 Jean-Marie Simonet
|
||||
# [#22288] Content category - displaying title twice. Thanks Bill.
|
||||
|
|
|
@ -43,16 +43,25 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @return boolean True on success
|
||||
* @param array $options An array of configuration options.
|
||||
*
|
||||
* @return JMenu
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
$this->load(); //load the menu items
|
||||
|
||||
foreach ($this->_items as $k => $item) {
|
||||
foreach ($this->_items as $k => $item)
|
||||
{
|
||||
if ($item->home) {
|
||||
$this->_default[$item->language] = $item->id;
|
||||
}
|
||||
|
||||
// Decode params
|
||||
$result = new JRegistry;
|
||||
$result->loadJSON($item->params);
|
||||
$item->params = $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +70,7 @@ class JMenu extends JObject
|
|||
*
|
||||
* @param string The name of the client
|
||||
* @param array An associative array of options
|
||||
*
|
||||
* @return JMenu A menu object.
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -83,7 +93,8 @@ class JMenu extends JObject
|
|||
// Create a JPathway object
|
||||
$classname = 'JMenu'.ucfirst($client);
|
||||
$instance = new $classname($options);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//$error = JError::raiseError(500, 'Unable to load menu: '.$client);
|
||||
$error = null; //Jinx : need to fix this
|
||||
return $error;
|
||||
|
@ -98,11 +109,12 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Get menu item by id
|
||||
*
|
||||
* @access public
|
||||
* @param int The item id
|
||||
* @return mixed The item object, or null if not found
|
||||
* @param int $id The item id
|
||||
*
|
||||
* @return mixed The item object, or null if not found
|
||||
* @since 1.5
|
||||
*/
|
||||
function getItem($id)
|
||||
public function getItem($id)
|
||||
{
|
||||
$result = null;
|
||||
if (isset($this->_items[$id])) {
|
||||
|
@ -113,10 +125,13 @@ class JMenu extends JObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the default item by id
|
||||
* Set the default item by id and language code.
|
||||
*
|
||||
* @param int The item id
|
||||
* @return True, if succesfull
|
||||
* @param int $id The menu item id.
|
||||
* @param string $language The language cod (since 1.6).
|
||||
*
|
||||
* @return boolean True, if succesfull
|
||||
* @since 1.5
|
||||
*/
|
||||
public function setDefault($id, $language='')
|
||||
{
|
||||
|
@ -131,17 +146,20 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Get menu item by id
|
||||
*
|
||||
* @access public
|
||||
* @param string $language The language code.
|
||||
*
|
||||
* @return object The item object
|
||||
* @return object The item object
|
||||
* @since 1.5
|
||||
*/
|
||||
function getDefault($language='*')
|
||||
{
|
||||
if (array_key_exists($language, $this->_default)) {
|
||||
return $this->_items[$this->_default[$language]];
|
||||
} else if (array_key_exists('*', $this->_default)) {
|
||||
}
|
||||
else if (array_key_exists('*', $this->_default)) {
|
||||
return $this->_items[$this->_default['*']];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +167,9 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Set the default item by id
|
||||
*
|
||||
* @param int The item id
|
||||
* @return If successfull the active item, otherwise null
|
||||
* @param int $id The item id
|
||||
*
|
||||
* @return mixed If successfull the active item, otherwise null
|
||||
*/
|
||||
public function setActive($id)
|
||||
{
|
||||
|
@ -164,9 +183,9 @@ class JMenu extends JObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Get menu item by id
|
||||
* Get menu item by id.
|
||||
*
|
||||
* @return object The item object
|
||||
* @return object The item object.
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
|
@ -181,9 +200,9 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Gets menu items by attribute
|
||||
*
|
||||
* @param string The field name
|
||||
* @param string The value of the field
|
||||
* @param boolean If true, only returns the first item found
|
||||
* @param string $attributes The field name
|
||||
* @param string $values The value of the field
|
||||
* @param boolean $firstonly If true, only returns the first item found
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -193,13 +212,15 @@ class JMenu extends JObject
|
|||
$attributes = (array) $attributes;
|
||||
$values = (array) $values;
|
||||
|
||||
foreach ($this->_items as $item) {
|
||||
foreach ($this->_items as $item)
|
||||
{
|
||||
if (!is_object($item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$test = true;
|
||||
for ($i=0, $count = count($attributes); $i<$count; $i++) {
|
||||
for ($i=0, $count = count($attributes); $i < $count; $i++)
|
||||
{
|
||||
if (is_array($values[$i])) {
|
||||
if (!in_array($item->$attributes[$i], $values[$i])) {
|
||||
$test = false;
|
||||
|
@ -229,17 +250,18 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Gets the parameter object for a certain menu item
|
||||
*
|
||||
* @param int The item id
|
||||
* @param int $id The item id
|
||||
*
|
||||
* @return object A JRegistry object
|
||||
*/
|
||||
public function getParams($id)
|
||||
{
|
||||
$result = new JRegistry;
|
||||
if ($menu = $this->getItem($id)) {
|
||||
$result->loadJSON($menu->params);
|
||||
return $menu->params;
|
||||
}
|
||||
else {
|
||||
return new JRegistry;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,8 +278,9 @@ class JMenu extends JObject
|
|||
* Method to check JMenu object authorization against an access control
|
||||
* object and optionally an access extension object
|
||||
*
|
||||
* @param integer $id The menu id
|
||||
* @param integer $id The menu id
|
||||
* @return boolean True if authorized
|
||||
* @since 1.6
|
||||
*/
|
||||
public function authorise($id)
|
||||
{
|
||||
|
@ -266,7 +289,8 @@ class JMenu extends JObject
|
|||
|
||||
if ($menu) {
|
||||
return in_array((int) $menu->access, $user->authorisedLevels());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +298,7 @@ class JMenu extends JObject
|
|||
/**
|
||||
* Loads the menu items
|
||||
*
|
||||
* @abstract
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
|
|
|
@ -11,11 +11,17 @@ defined('_JEXEC') or die;
|
|||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_menu
|
||||
* @since 1.5
|
||||
*/
|
||||
class modMenuHelper
|
||||
{
|
||||
/**
|
||||
* Get a list of the menu items.
|
||||
*
|
||||
* @param JRegistry $params The module options.
|
||||
*
|
||||
* @return array
|
||||
* @since 1.5
|
||||
*/
|
||||
static function getList(&$params)
|
||||
{
|
||||
|
@ -37,31 +43,33 @@ class modMenuHelper
|
|||
$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))
|
||||
|| ($maxdepth && $item->level > $maxdepth))
|
||||
{
|
||||
if (($start && $start > $item->level)
|
||||
|| ($end && $item->level > $end)
|
||||
|| (!$showAll && $item->level > 1 && !in_array($item->parent_id, $path))
|
||||
|| ($maxdepth && $item->level > $maxdepth)
|
||||
) {
|
||||
unset($items[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$item->deeper = false;
|
||||
$item->shallower = false;
|
||||
$item->level_diff = 0;
|
||||
|
||||
if(isset($items[$lastitem]))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
$lastitem = $i;
|
||||
$item->active = false;
|
||||
$item->params = new JObject(json_decode($item->params));
|
||||
$item->flink = $item->link;
|
||||
|
||||
switch ($item->type)
|
||||
{
|
||||
case 'separator':
|
||||
|
@ -84,13 +92,16 @@ class modMenuHelper
|
|||
$router = JSite::getRouter();
|
||||
if ($router->getMode() == JROUTER_MODE_SEF) {
|
||||
$item->flink = 'index.php?Itemid='.$item->id;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$item->flink .= '&Itemid='.$item->id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$item->flink = JRoute::_($item->flink);
|
||||
}
|
||||
|
||||
if (isset($items[$lastitem])) {
|
||||
$items[$lastitem]->deeper = (($start?$start:1) > $items[$lastitem]->level);
|
||||
$items[$lastitem]->shallower = (($start?$start:1) < $items[$lastitem]->level);
|
||||
|
@ -100,4 +111,4 @@ class modMenuHelper
|
|||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user