Source for file positions.php
Documentation is available at positions.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 Positions 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(
* 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.state', $state);
$clientId =
$app->input->getInt('client_id', 0);
$this->setState('filter.client_id', $clientId);
$this->setState('filter.template', $template);
// List state information.
* Method to get an array of data items.
* @return mixed An array of data items on success, false on failure.
if (!isset
($this->items))
$search =
$this->getState('filter.search');
$state =
$this->getState('filter.state');
$clientId =
$this->getState('filter.client_id');
$filter_template =
$this->getState('filter.template');
$ordering =
$this->getState('list.ordering');
$direction =
$this->getState('list.direction');
$limitstart =
$this->getState('list.start');
// Get the database object and a new query object.
$query =
$this->_db->getQuery(true)
->select('DISTINCT(position) as value')
->where($this->_db->quoteName('client_id').
' = '.(int)
$clientId);
$query->where('position LIKE '.
$this->_db->quote('%'.
$this->_db->escape($search, true).
'%'));
$this->_db->setQuery($query);
$positions =
$this->_db->loadObjectList('value');
catch
(RuntimeException $e)
foreach ($positions as $value =>
$position)
$positions[$value] =
array();
// Load the positions from the installed templates.
$path =
JPath::clean($client->path.
'/templates/'.
$template->element.
'/templateDetails.xml');
if (isset
($xml->positions[0]))
$lang->load('tpl_'.
$template->element.
'.sys', $client->path, null, false, true)
||
$lang->load('tpl_'.
$template->element.
'.sys', $client->path.
'/templates/'.
$template->element, null, false, true);
foreach ($xml->positions[0] as $position)
$value = (string)
$position['value'];
$label = (string)
$position;
$label =
preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_'.
$template->element.
'_POSITION_'.
$value);
$altlabel =
preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'COM_MODULES_POSITION_'.
$value);
if (!$lang->hasKey($label) &&
$lang->hasKey($altlabel))
if ($type ==
'user' ||
($state !=
'' &&
$state !=
$template->enabled))
unset
($positions[$value]);
elseif (preg_match(chr(1) .
$search .
chr(1) .
'i', $value) &&
($filter_template ==
'' ||
$filter_template ==
$template->element))
if (!isset
($positions[$value]))
$positions[$value] =
array();
$positions[$value][$template->name] =
$label;
$this->total =
count($positions);
if ($limitstart >=
$this->total)
$limitstart =
$limitstart <
$limit ?
0 :
$limitstart -
$limit;
$this->setState('list.start', $limitstart);
if ($ordering ==
'value')
$this->items =
array_slice($positions, $limitstart, $limit ?
$limit :
null);
* Method to get the total number of items.
* @return int The total number of items.
if (!isset
($this->total))
Documentation generated on Tue, 19 Nov 2013 15:11:00 +0100 by phpDocumentor 1.4.3