Source for file category.php
Documentation is available at category.php
* @subpackage com_contact
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @subpackage com_contact
* The category that applies.
* The list of other newfeed categories.
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'con_position', 'a.con_position',
'ordering', 'a.ordering',
'sortname1', 'a.sortname1',
'sortname2', 'a.sortname2',
'sortname3', 'a.sortname3'
* Method to get a list of items.
* @return mixed An array of objects on success, false on failure.
// Invoke the parent getItems method to get the main list
// Convert the params field into an object, saving original in _params
for ($i =
0, $n =
count($items); $i <
$n; $i++
)
if (!isset
($this->_params))
$params->loadString($item->params);
$this->tags->getItemTags('com_contact.contact', $item->id);
* Method to build an SQL query to load the list data.
* @return string An SQL query
$groups =
implode(',', $user->getAuthorisedViewLevels());
// Create a new query object.
$query =
$db->getQuery(true);
// Select required fields from the categories.
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id .
' END as slug';
$case_when1 =
' CASE WHEN ';
$case_when1 .=
$query->charLength('c.alias', '!=', '0');
$c_id =
$query->castAsChar('c.id');
$case_when1 .=
$query->concatenate(array($c_id, 'c.alias'), ':');
$case_when1 .=
$c_id .
' END as catslug';
$query->select($this->getState('list.select', 'a.*') .
',' .
$case_when .
',' .
$case_when1)
// TODO: we actually should be doing it but it's wrong this way
// . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, '
// . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug ');
->from($db->quoteName('#__contact_details') .
' AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('a.access IN (' .
$groups .
')');
if ($categoryId =
$this->getState('category.id'))
$query->where('a.catid = ' . (int)
$categoryId)
->where('c.access IN (' .
$groups .
')');
// Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
$state =
$this->getState('filter.published');
$query->where('a.published = ' . (int)
$state);
// Filter by start and end dates.
$nullDate =
$db->quote($db->getNullDate());
if ($this->getState('filter.publish_date'))
$query->where('(a.publish_up = ' .
$nullDate .
' OR a.publish_up <= ' .
$nowDate .
')')
->where('(a.publish_down = ' .
$nullDate .
' OR a.publish_down >= ' .
$nowDate .
')');
// Filter by search in title
$search =
$this->getState('list.filter');
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('(a.name LIKE ' .
$search .
')');
$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) .
',' .
$db->quote('*') .
')');
// Set sortname ordering if selected
if ($this->getState('list.ordering') ==
'sortname')
$query->order($db->escape('a.sortname1') .
' ' .
$db->escape($this->getState('list.direction', 'ASC')))
->order($db->escape('a.sortname2') .
' ' .
$db->escape($this->getState('list.direction', 'ASC')))
->order($db->escape('a.sortname3') .
' ' .
$db->escape($this->getState('list.direction', 'ASC')));
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) .
' ' .
$db->escape($this->getState('list.direction', 'ASC')));
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
protected function populateState($ordering =
null, $direction =
null)
// List state information
$format =
$app->input->getWord('format');
$limit =
$app->getCfg('feed_limit');
$limit =
$app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
$limitstart =
$app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
$this->setState('list.filter', $app->input->getString('filter-search'));
// Get list ordering default from the parameters
if ($menu =
$app->getMenu()->getActive())
$menuParams->loadString($menu->params);
$mergedParams =
clone $params;
$mergedParams->merge($menuParams);
$orderCol =
$app->input->get('filter_order', $mergedParams->get('initial_sort', 'ordering'));
$this->setState('list.ordering', $orderCol);
$listOrder =
$app->input->get('filter_order_Dir', 'ASC');
$this->setState('list.direction', $listOrder);
$id =
$app->input->get('id', 0, 'int');
if ((!$user->authorise('core.edit.state', 'com_contact')) &&
(!$user->authorise('core.edit', 'com_contact')))
// limit to published for people who can't edit or edit.state.
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
* Method to get category data for the current category
* @param integer An optional ID
$active =
$menu->getActive();
$params->loadString($active->params);
$options['countItems'] =
$params->get('show_cat_items', 1) ||
$params->get('show_empty_categories', 0);
$this->_item =
$categories->get($this->getState('category.id', 'root'));
if ($this->_item->getParent())
$this->_rightsibling =
$this->_item->getSibling();
$this->_leftsibling =
$this->_item->getSibling(false);
* Get the parent category.
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
* @return mixed An array of categories or false if an error occurs.
* Get the sibling (adjacent) categories.
* @return mixed An array of categories or false if an error occurs.
return $this->_leftsibling;
return $this->_rightsibling;
* Get the child categories.
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
* @return mixed An array of categories or false if an error occurs.
* Increment the hit counter for the category.
* @param integer $pk Optional primary key of the category to increment.
* @return boolean True if successful; false otherwise and internal error set.
public function hit($pk =
0)
$hitcount =
$input->getInt('hitcount', 1);
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('category.id');
Documentation generated on Tue, 19 Nov 2013 14:55:23 +0100 by phpDocumentor 1.4.3