Source for file category.php
Documentation is available at category.php
* @subpackage com_weblinks
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Weblinks Component Weblink Model
* @subpackage com_weblinks
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'ordering', 'a.ordering',
* The category that applies.
* The list of other weblink categories.
* 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
foreach ($items as $item)
if (!isset
($this->_params))
$params->loadString($item->params);
$item->tags->getItemTags('com_weblinks.weblink', $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.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__weblinks') .
' AS a')
->where('a.access IN (' .
$groups .
')');
if ($categoryId =
$this->getState('category.id'))
$query->where('a.catid = ' . (int)
$categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' .
$groups .
')');
//Filter by published category
$cpublished =
$this->getState('filter.c.published');
$query->where('c.published = ' . (int)
$cpublished);
// 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.state');
$query->where('a.state = ' . (int)
$state);
// do not show trashed links on the front-end
$query->where('a.state != -2');
// Filter by start and end dates.
$nullDate =
$db->quote($db->getNullDate());
$nowDate =
$db->quote($date->toSql());
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 .
')');
$query->where('a.language in (' .
$db->quote(JFactory::getLanguage()->getTag()) .
',' .
$db->quote('*') .
')');
// Filter by search in title
$search =
$this->getState('list.filter');
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('(a.title LIKE ' .
$search .
')');
// Add the list ordering clause.
$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
$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'));
$orderCol =
$app->input->get('filter_order', '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_weblinks')) &&
(!$user->authorise('core.edit', 'com_weblinks')))
// 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_num_links_cat', 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 int $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:20 +0100 by phpDocumentor 1.4.3