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