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
* Menu List Model for Menus.
* @package Joomla.Administrator
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'menutype', 'a.menutype',
* Overrides the getItems method to attach additional metrics to the list.
* @return mixed An array of data items on success, false on failure.
// Try to load the data from internal storage.
if (!empty($this->cache[$store]))
return $this->cache[$store];
// If emtpy or an error, just return.
// Getting the following metric by joins is WAY TOO SLOW.
// Faster to do three queries for very large menu trees.
// Get the menu types of menus in the list.
// Get the published menu counts.
$query =
$db->getQuery(true)
->select('m.menutype, COUNT(DISTINCT m.id) AS count_published')
->where('m.published = 1')
->where('m.menutype IN (' .
$menuTypes .
')')
$countPublished =
$db->loadAssocList('menutype', 'count_published');
catch
(RuntimeException $e)
// Get the unpublished menu counts.
->where('m.published = 0')
->where('m.menutype IN (' .
$menuTypes .
')');
$countUnpublished =
$db->loadAssocList('menutype', 'count_published');
catch
(RuntimeException $e)
// Get the trashed menu counts.
->where('m.published = -2')
->where('m.menutype IN (' .
$menuTypes .
')');
$countTrashed =
$db->loadAssocList('menutype', 'count_published');
catch
(RuntimeException $e)
// Inject the values back into the array.
foreach ($items as $item)
$item->count_published = isset
($countPublished[$item->menutype]) ?
$countPublished[$item->menutype] :
0;
$item->count_unpublished = isset
($countUnpublished[$item->menutype]) ?
$countUnpublished[$item->menutype] :
0;
$item->count_trashed = isset
($countTrashed[$item->menutype]) ?
$countTrashed[$item->menutype] :
0;
// Add the items to the internal cache.
$this->cache[$store] =
$items;
return $this->cache[$store];
* Method to build an SQL query to load the list data.
* @return string An SQL query
// Create a new query object.
$query =
$db->getQuery(true);
// Select all fields from the table.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__menu_types') .
' AS a')
->group('a.id, a.menutype, a.title, a.description');
// Filter by search in title or menutype
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('(' .
'a.title LIKE ' .
$search .
' OR a.menutype LIKE ' .
$search .
')');
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.id')) .
' ' .
$db->escape($this->getState('list.direction', 'ASC')));
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
protected function populateState($ordering =
null, $direction =
null)
$this->setState('filter.search', $search);
// List state information.
* Gets the extension id of the core mod_menu module.
$query =
$db->getQuery(true)
->select('e.extension_id')
->from('#__extensions AS e')
->where('e.type = ' .
$db->quote('module'))
->where('e.element = ' .
$db->quote('mod_menu'))
->where('e.client_id = 0');
return $db->loadResult();
* Gets a list of all mod_mainmenu modules and collates them by menutype
$result =
& $model->getModules();
Documentation generated on Tue, 19 Nov 2013 15:07:59 +0100 by phpDocumentor 1.4.3