Source for file filters.php

Documentation is available at filters.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_finder
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Filters model class for Finder.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_finder
  17.  * @since       2.5
  18.  */
  19. {
  20.     /**
  21.      * Constructor.
  22.      *
  23.      * @param   array  $config  An associative array of configuration settings. [optional]
  24.      *
  25.      * @since   2.5
  26.      * @see     JController
  27.      */
  28.     public function __construct($config array())
  29.     {
  30.         if (empty($config['filter_fields']))
  31.         {
  32.             $config['filter_fields'array(
  33.                 'filter_id''a.filter_id',
  34.                 'title''a.title',
  35.                 'state''a.state',
  36.                 'created_by_alias''a.created_by_alias',
  37.                 'created''a.created',
  38.                 'map_count''a.map_count'
  39.             );
  40.         }
  41.  
  42.         parent::__construct($config);
  43.     }
  44.  
  45.     /**
  46.      * Build an SQL query to load the list data.
  47.      *
  48.      * @return  JDatabaseQuery  A JDatabaseQuery object
  49.      *
  50.      * @since   2.5
  51.      */
  52.     protected function getListQuery()
  53.     {
  54.         $db $this->getDbo();
  55.         $query $db->getQuery(true);
  56.  
  57.         // Select all fields from the table.
  58.         $query->select('a.*')
  59.             ->from($db->quoteName('#__finder_filters'' AS a');
  60.  
  61.         // Join over the users for the checked out user.
  62.         $query->select('uc.name AS editor')
  63.             ->join('LEFT'$db->quoteName('#__users'' AS uc ON uc.id=a.checked_out');
  64.  
  65.         // Join over the users for the author.
  66.         $query->select('ua.name AS user_name')
  67.             ->join('LEFT'$db->quoteName('#__users'' AS ua ON ua.id = a.created_by');
  68.  
  69.         // Check for a search filter.
  70.         if ($this->getState('filter.search'))
  71.         {
  72.             $query->where('( a.title LIKE \'%' $db->escape($this->getState('filter.search')) '%\' )');
  73.         }
  74.  
  75.         // If the model is set to check item state, add to the query.
  76.         if (is_numeric($this->getState('filter.state')))
  77.         {
  78.             $query->where('a.state = ' . (int) $this->getState('filter.state'));
  79.         }
  80.  
  81.         // Add the list ordering clause.
  82.         $query->order($db->escape($this->getState('list.ordering'' ' $db->escape($this->getState('list.direction'))));
  83.  
  84.         return $query;
  85.     }
  86.  
  87.     /**
  88.      * Method to get a store id based on model configuration state.
  89.      *
  90.      * This is necessary because the model is used by the component and
  91.      * different modules that might need different sets of data or different
  92.      * ordering requirements.
  93.      *
  94.      * @param   string  $id  A prefix for the store id. [optional]
  95.      *
  96.      * @return  string  A store id.
  97.      *
  98.      * @since   2.5
  99.      */
  100.     protected function getStoreId($id '')
  101.     {
  102.         // Compile the store id.
  103.         $id .= ':' $this->getState('filter.search');
  104.         $id .= ':' $this->getState('filter.state');
  105.  
  106.         return parent::getStoreId($id);
  107.     }
  108.  
  109.     /**
  110.      * Method to auto-populate the model state.  Calling getState in this method will result in recursion.
  111.      *
  112.      * @param   string  $ordering   An optional ordering field. [optional]
  113.      * @param   string  $direction  An optional direction. [optional]
  114.      *
  115.      * @return  void 
  116.      *
  117.      * @since   2.5
  118.      */
  119.     protected function populateState($ordering null$direction null)
  120.     {
  121.         // Load the filter state.
  122.         $search $this->getUserStateFromRequest($this->context . '.filter.search''filter_search');
  123.         $this->setState('filter.search'$search);
  124.  
  125.         $state $this->getUserStateFromRequest($this->context . '.filter.state''filter_state''''string');
  126.         $this->setState('filter.state'$state);
  127.  
  128.         // Load the parameters.
  129.         $params JComponentHelper::getParams('com_finder');
  130.         $this->setState('params'$params);
  131.  
  132.         // List state information.
  133.         parent::populateState('a.title''asc');
  134.     }
  135. }

Documentation generated on Tue, 19 Nov 2013 15:03:21 +0100 by phpDocumentor 1.4.3