- md5
- ed8a26fb8a3415965d3baf35943bb741
- sha1
- 6e1ec85fa50e473adf2ec8312aa70ea33c453c8f
- sha256
- db550c805921b0ae5385f338f93f5c97b67a77ab534136ae5104c03f0fd9ab9e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
<?php
/**
* @version $Id: menus.php 20267 2011-01-11 03:44:44Z eddieajau $
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.modellist');
/**
* Menu List Model for Menus.
*
* @package Joomla.Administrator
* @subpackage com_menus
* @since 1.6
*/
class MenusModelMenus extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'id', 'a.id',
'title', 'a.title',
'menutype', 'a.menutype',
);
}
parent::__construct($config);
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select all fields from the table.
$query->select($this->getState('list.select', 'a.*'));
$query->from('`#__menu_types` AS a');
// Self join to find the number of published menu items in the menu.
$query->select('COUNT(DISTINCT m1.id) AS count_published');
$query->join('LEFT', '`#__menu` AS m1 ON m1.menutype = a.menutype AND m1.published = 1');
// Self join to find the number of unpublished menu items in the menu.
$query->select('COUNT(DISTINCT m2.id) AS count_unpublished');
$query->join('LEFT', '`#__menu` AS m2 ON m2.menutype = a.menutype AND m2.published = 0');
// Self join to find the number of trashed menu items in the menu.
$query->select('COUNT(DISTINCT m3.id) AS count_trashed');
$query->join('LEFT', '`#__menu` AS m3 ON m3.menutype = a.menutype AND m3.published = -2');
$query->group('a.id');
// Add the list ordering clause.
$query->order($db->getEscaped($this->getState('list.ordering', 'a.id')).' '.$db->getEscaped($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',(string)$query)).'<hr/>';
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = JFactory::getApplication('administrator');
// List state information.
parent::populateState('a.id', 'asc');
}
/**
* Gets a list of all mod_mainmenu modules and collates them by menutype
*
* @return array
*/
function &getModules()
{
$model = JModel::getInstance('Menu', 'MenusModel', array('ignore_request' => true));
$result = &$model->getModules();
return $result;
}
}
The same content is in 7 releases, Joomla 1.6.0 to 1.6.6. See them all, or every version of this file.