Source for file banners.php
Documentation is available at banners.php
* @package Joomla.Administrator
* @subpackage com_banners
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Methods supporting a list of banner records.
* @package Joomla.Administrator
* @subpackage com_banners
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'cid', 'a.cid', 'client_name',
'ordering', 'a.ordering',
'language', 'a.language',
'catid', 'a.catid', 'category_title',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'imptotal', 'a.imptotal',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'state', 'sticky', 'a.sticky',
* Method to get the maximum ordering value for each category.
if (!isset
($this->cache['categoryorders']))
$query =
$db->getQuery(true)
->select('MAX(ordering) as ' .
$db->quoteName('max') .
', catid')
$this->cache['categoryorders'] =
$db->loadAssocList('catid', 0);
return $this->cache['categoryorders'];
* Build an SQL query to load the list data.
$query =
$db->getQuery(true);
// Select the required fields from the table.
'a.id AS id, a.name AS name, a.alias AS alias,' .
'a.checked_out AS checked_out,' .
'a.checked_out_time AS checked_out_time, a.catid AS catid,' .
'a.clicks AS clicks, a.metakey AS metakey, a.sticky AS sticky,' .
'a.impmade AS impmade, a.imptotal AS imptotal,' .
'a.state AS state, a.ordering AS ordering,' .
'a.purchase_type as purchase_type,' .
'a.language, a.publish_up, a.publish_down'
$query->from($db->quoteName('#__banners') .
' 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 categories.
$query->select('c.title AS category_title')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Join over the clients.
$query->select('cl.name AS client_name,cl.purchase_type as client_purchase_type')
->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid');
// Filter by published state
$published =
$this->getState('filter.state');
$query->where('a.state = ' . (int)
$published);
elseif ($published ===
'')
$query->where('(a.state IN (0, 1))');
$categoryId =
$this->getState('filter.category_id');
$query->where('a.catid = ' . (int)
$categoryId);
$clientId =
$this->getState('filter.client_id');
$query->where('a.cid = ' . (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.name LIKE ' .
$search .
' OR a.alias LIKE ' .
$search .
')');
// Filter on the language.
if ($language =
$this->getState('filter.language'))
$query->where('a.language = ' .
$db->quote($language));
// Add the list ordering clause.
$orderCol =
$this->state->get('list.ordering', 'ordering');
$orderDirn =
$this->state->get('list.direction', 'ASC');
if ($orderCol ==
'ordering' ||
$orderCol ==
'category_title')
$orderCol =
'c.title ' .
$orderDirn .
', a.ordering';
if ($orderCol ==
'client_name')
$query->order($db->escape($orderCol .
' ' .
$orderDirn));
* 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 $id 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.category_id');
$id .=
':' .
$this->getState('filter.language');
* Returns a reference to the a Table object, always creating it.
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
public function getTable($type =
'Banner', $prefix =
'BannersTable', $config =
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);
$this->setState('filter.category_id', $categoryId);
$this->setState('filter.client_id', $clientId);
$this->setState('filter.language', $language);
// List state information.
Documentation generated on Tue, 19 Nov 2013 14:54:20 +0100 by phpDocumentor 1.4.3