Source code for file /joomla/application/menu.php
Documentation is available at menu.php
* @version $Id: menu.php 6634 2007-02-15 18:27:18Z Jinx $
* @package Joomla.Framework
* @subpackage Application
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* @package Joomla.Framework
* @subpackage Application
* Array to hold the menu items
* Identifier of the default menu item
* Identifier of the active menu item
* @return boolean True on success
$this->_items =
$this->_load();
$n =
count($this->_items );
foreach ($this->_items as $k =>
$item)
$this->_default =
$item->id;
* Returns a reference to the global JMenu object, only creating it if it
* This method must be invoked as:
* <pre> $menu = &JMenu::getInstance();</pre>
* @return JMenu The Menu object.
* @return mixed The item object, or null if not found
if (isset
($this->_items[$id])) {
$result =
&$this->_items[$id];
* Set the default item by id
* @return True, if succesfull
if(exists($this->_items[$id])) {
* @return object The item object
$item =
& $this->_items[$this->_default];
* Set the default item by id
* @return True, if succesfull
if(isset
($this->_items[$id])) {
* @return object The item object
$item =
& $this->_items[$this->_active];
* 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
function getItems($attribute, $value, $firstonly =
false)
foreach ($this->_items as $item)
if ($item->$attribute ==
$value)
* Gets the parameter object for a certain menu item
* @return object A JParameter object
if ($menu =
& $this->getItem($id)) {
* Getter for the menu array
* @param string $name The menu name
* 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 $accessid The users access identifier
* @return boolean True if authorized
return ($menu->access <=
$accessid);
* Loads the entire menu table into memory
// Initialize some variables
$sql =
'SELECT m.*, c.option as component' .
' LEFT JOIN #__components AS c ON m.componentid = c.id'.
' WHERE m.published = 1'.
' ORDER BY m.sublevel, m.parent, m.ordering';
if (!($menus =
$db->loadObjectList('id'))) {
foreach($menus as $key =>
$menu)
if($parent =
$menus[$key]->parent) {
$parent_route =
$menus[$parent]->route.
'/';
$parent_tree =
$menus[$parent]->tree;
$menus[$key]->tree =
$parent_tree;
$route =
$parent_route.
$menus[$key]->alias;
$menus[$key]->route =
$route;
$menus[$key]->query =
$url->getQuery(true);