Source for file searches.php
Documentation is available at searches.php
* @package Joomla.Administrator
* @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 search terms.
* @package Joomla.Administrator
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'search_term', 'a.search_term',
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
protected function populateState($ordering =
null, $direction =
null)
// Load the filter state.
$this->setState('filter.search', $search);
$this->setState('filter.results', $showResults);
// 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 $id A prefix for the store id.
* @return string A store id.
$id .=
':' .
$this->getState('filter.search');
$id .=
':' .
$this->getState('filter.results');
* 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.
$query->from($db->quoteName('#__core_log_searches') .
' AS a');
// Filter by access level.
if ($access =
$this->getState('filter.access'))
$query->where('a.access = ' . (int)
$access);
// Filter by search in title
$search =
$this->getState('filter.search');
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('a.search_term LIKE ' .
$search);
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.hits')) .
' ' .
$db->escape($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',$query));
* Override the parnet getItems to inject optional data.
* @return mixed An array of objects on success, false on failure.
// Determine if number of results for search item should be calculated
// by default it is `off` as it is highly query intensive
// This fools the routers in the search plugins into thinking it's in the frontend
foreach ($items as &$item)
$results =
$app->triggerEvent('onContentSearch', array($item->search_term));
foreach ($results as $result)
$item->returns +=
count($result);
* Method to reset the seach log table.
'DELETE FROM #__core_log_searches'
catch
(RuntimeException $e)
Documentation generated on Tue, 19 Nov 2013 15:12:45 +0100 by phpDocumentor 1.4.3