Source for file modules.php
Documentation is available at modules.php
* @package Joomla.Administrator
* @subpackage com_modules
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Modules Component Module Model
* @package Joomla.Administrator
* @subpackage com_modules
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'published', 'a.published',
'access', 'a.access', 'access_level',
'ordering', 'a.ordering',
'language', 'a.language', 'language_title',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'client_id', 'a.client_id',
'position', 'a.position',
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
protected function populateState($ordering =
null, $direction =
null)
// Load the filter state.
$this->setState('filter.search', $search);
$this->setState('filter.access', $accessId);
$this->setState('filter.state', $state);
$this->setState('filter.position', $position);
$this->setState('filter.module', $module);
$previousId =
$app->getUserState($this->context .
'.filter.client_id_previous', null);
if ($previousId !=
$clientId ||
$previousId ===
null)
$app->setUserState($this->context .
'.filter.client_id_previous', $clientId);
$this->setState('filter.client_id', $clientId);
$this->setState('filter.language', $language);
// List state information.
* Method to get a store id based on model configuration state.
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* @param string A prefix for the store id.
* @return string A store id.
$id .=
':' .
$this->getState('filter.search');
$id .=
':' .
$this->getState('filter.access');
$id .=
':' .
$this->getState('filter.state');
$id .=
':' .
$this->getState('filter.position');
$id .=
':' .
$this->getState('filter.module');
$id .=
':' .
$this->getState('filter.client_id');
$id .=
':' .
$this->getState('filter.language');
* @param string The query
* @param int The number of records
protected function _getList($query, $limitstart =
0, $limit =
0)
$ordering =
$this->getState('list.ordering', 'ordering');
if (in_array($ordering, array('pages', 'name')))
$this->_db->setQuery($query);
$result =
$this->_db->loadObjectList();
if ($total <
$limitstart)
return array_slice($result, $limitstart, $limit ?
$limit :
null);
if ($ordering ==
'ordering')
$query->order('a.position ASC');
$ordering =
'a.ordering';
if ($ordering ==
'language_title')
$query->order($this->_db->quoteName($ordering) .
' ' .
$this->getState('list.direction'));
if ($ordering ==
'position')
$query->order('a.ordering ASC');
$result =
parent::_getList($query, $limitstart, $limit);
* Translate a list of objects
* @param array The array of objects
* @return array The array of translated objects
$client =
$this->getState('filter.client_id') ?
'administrator' :
'site';
foreach ($items as $item)
$extension =
$item->module;
$lang->load("$extension.sys", constant('JPATH_' .
strtoupper($client)), null, false, true)
||
$lang->load("$extension.sys", $source, null, false, true);
$item->name =
JText::_($item->name);
$item->pages =
JText::_('JNONE');
elseif ($item->pages <
0)
$item->pages =
JText::_('COM_MODULES_ASSIGNED_VARIES_EXCEPT');
elseif ($item->pages >
0)
$item->pages =
JText::_('COM_MODULES_ASSIGNED_VARIES_ONLY');
$item->pages =
JText::_('JALL');
* Build an SQL query to load the list data.
// Create a new query object.
$query =
$db->getQuery(true);
// Select the required fields from the table.
'a.id, a.title, a.note, a.position, a.module, a.language,' .
'a.checked_out, a.checked_out_time, a.published+2*(e.enabled-1) as published, a.access, a.ordering, a.publish_up, a.publish_down'
$query->from($db->quoteName('#__modules') .
' AS a');
// Join over the language
$query->select('l.title AS language_title')
->join('LEFT', $db->quoteName('#__languages') .
' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the asset groups.
$query->select('ag.title AS access_level')
->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Join over the module menus
$query->select('MIN(mm.menuid) AS pages')
->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = a.id');
// Join over the extensions
$query->select('e.name AS name')
->join('LEFT', '#__extensions AS e ON e.element = a.module')
'a.id, a.title, a.note, a.position, a.module, a.language,a.checked_out,' .
'a.checked_out_time, a.published, a.access, a.ordering,l.title, uc.name, ag.title, e.name,' .
'l.lang_code, uc.id, ag.id, mm.moduleid, e.element, a.publish_up, a.publish_down,e.enabled'
// Filter by access level.
if ($access =
$this->getState('filter.access'))
$query->where('a.access = ' . (int)
$access);
// Filter by published state
$state =
$this->getState('filter.state');
$query->where('a.published = ' . (int)
$state);
$query->where('(a.published IN (0, 1))');
$position =
$this->getState('filter.position');
if ($position &&
$position !=
'none')
$query->where('a.position = ' .
$db->quote($position));
elseif ($position ==
'none')
$query->where('a.position = ' .
$db->quote(''));
$module =
$this->getState('filter.module');
$query->where('a.module = ' .
$db->quote($module));
$clientId =
$this->getState('filter.client_id');
$query->where('a.client_id = ' . (int)
$clientId .
' AND e.client_id =' . (int)
$clientId);
// Filter by search in title
$search =
$this->getState('filter.search');
$query->where('a.id = ' . (int)
substr($search, 3));
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('(' .
'a.title LIKE ' .
$search .
' OR a.note LIKE ' .
$search .
')');
// Filter on the language.
if ($language =
$this->getState('filter.language'))
$query->where('a.language = ' .
$db->quote($language));
//echo nl2br(str_replace('#__','jos_',$query));
Documentation generated on Tue, 19 Nov 2013 15:08:52 +0100 by phpDocumentor 1.4.3