Source for file menus.php
Documentation is available at menus.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Menus component helper.
* @package Joomla.Administrator
* Defines the valid request variables for the reverse lookup.
protected static $_filter =
array('option', 'view', 'layout');
* @param string The name of the active view.
JText::_('COM_MENUS_SUBMENU_MENUS'),
'index.php?option=com_menus&view=menus',
JText::_('COM_MENUS_SUBMENU_ITEMS'),
'index.php?option=com_menus&view=items',
* Gets a list of the actions that can be performed.
* @param integer The menu ID.
$assetName =
'com_menus';
$assetName =
'com_menus.item.' . (int)
$parentId;
foreach ($actions as $action)
$result->set($action->name, $user->authorise($action->name, $assetName));
* Gets a standard form of a link for lookups.
* @param mixed A link string or array of request variables.
* @return mixed A link in standard option-view-layout form, or false if the supplied response is invalid.
// Check if the link is in the form of index.php?...
if (strpos($request, 'index.php') ===
0)
// Only take the option, view and layout parts.
foreach ($request as $name =>
$value)
if ((!in_array($name, self::$_filter)) &&
(!($name ==
'task' &&
!array_key_exists('view', $request))))
// Remove the variables we want to ignore.
* Get the menu list for create a menu module
* @return array The menu array list
$query =
$db->getQuery(true)
->from('#__menu_types AS a');
return $db->loadColumn();
* Get a list of menu links for one or all menus.
* @param string An option menu to filter the list on, otherwise all menu links are returned as a grouped array.
* @param integer An optional parent ID to pivot results around.
* @param integer An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list.
* @param array An optional array of states
public static function getMenuLinks($menuType =
null, $parentId =
0, $mode =
0, $published =
array(), $languages =
array())
$query =
$db->getQuery(true)
->select('a.id AS value, a.title AS text, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out')
->join('LEFT', $db->quoteName('#__menu') .
' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
$query->where('(a.menutype = ' .
$db->quote($menuType) .
' OR a.parent_id = 0)');
// Prevent the parent and children from showing.
$query->join('LEFT', '#__menu AS p ON p.id = ' . (int)
$parentId)
->where('(a.lft <= p.lft OR a.rgt >= p.rgt)');
$languages =
'(' .
implode(',', array_map(array($db, 'quote'), $languages)) .
')';
$query->where('a.language IN ' .
$languages);
$published =
'(' .
implode(',', $published) .
')';
$query->where('a.published IN ' .
$published);
$query->where('a.published != -2')
->group('a.id, a.title, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft')
$links =
$db->loadObjectList();
catch
(RuntimeException $e)
// If the menutype is empty, group the items by menutype.
->where('menutype <> ' .
$db->quote(''))
->order('title, menutype');
$menuTypes =
$db->loadObjectList();
catch
(RuntimeException $e)
// Create a reverse lookup and aggregate the links.
foreach ($menuTypes as &$type)
$rlu[$type->menutype] =
& $type;
// Loop through the list of menu links.
foreach ($links as &$link)
if (isset
($rlu[$link->menutype]))
$rlu[$link->menutype]->links[] =
& $link;
$query =
$db->getQuery(true)
->join('INNER', '#__associations as a ON a.id=m.id AND a.context=' .
$db->quote('com_menus.item'))
->join('INNER', '#__associations as a2 ON a.key=a2.key')
->join('INNER', '#__menu as m2 ON a2.id=m2.id')
->where('m.id=' . (int)
$pk)
->select('m2.language, m2.id');
$menuitems =
$db->loadObjectList('language');
catch
(RuntimeException $e)
throw
new Exception($e->getMessage(), 500);
foreach ($menuitems as $tag =>
$item)
// Do not return itself as result
if ((int)
$item->id !=
$pk)
$associations[$tag] =
$item->id;
Documentation generated on Tue, 19 Nov 2013 15:07:58 +0100 by phpDocumentor 1.4.3