| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Site 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 * Suggestions model class for the Finder package. 16 * 17 * @package Joomla.Site 18 * @subpackage com_finder 19 * @since 2.5 20 */ 21 class FinderModelSuggestions extends JModelList 22 { 23 /** 24 * Context string for the model type. 25 * 26 * @var string 27 * @since 2.5 28 */ 29 protected $context = 'com_finder.suggestions'; 30 31 /** 32 * Method to get an array of data items. 33 * 34 * @return array An array of data items. 35 * 36 * @since 2.5 37 */ 38 public function getItems() 39 { 40 // Get the items. 41 $items = &parent::getItems(); 42 43 // Convert them to a simple array. 44 foreach ($items as $k => $v) 45 { 46 $items[$k] = $v->term; 47 } 48 49 return $items; 50 } 51 52 /** 53 * Method to build a database query to load the list data. 54 * 55 * @return JDatabaseQuery A database query 56 * 57 * @since 2.5 58 */ 59 protected function getListQuery() 60 { 61 // Create a new query object. 62 $db = $this->getDbo(); 63 $query = $db->getQuery(true); 64 65 // Select required fields 66 $query->select('t.term'); 67 $query->from($db->quoteName('#__finder_terms') . ' AS t'); 68 $query->where('t.term LIKE ' . $db->quote($db->escape($this->getState('input'), true) . '%')); 69 $query->where('t.common = 0'); 70 $query->order('t.links DESC'); 71 $query->order('t.weight DESC'); 72 73 return $query; 74 } 75 76 /** 77 * Method to get a store id based on model the configuration state. 78 * 79 * This is necessary because the model is used by the component and 80 * different modules that might need different sets of data or different 81 * ordering requirements. 82 * 83 * @param string $id An identifier string to generate the store id. [optional] 84 * 85 * @return string A store id. 86 * 87 * @since 2.5 88 */ 89 protected function getStoreId($id = '') 90 { 91 // Add the search query state. 92 $id .= ':' . $this->getState('input'); 93 $id .= ':' . $this->getState('language'); 94 95 // Add the list state. 96 $id .= ':' . $this->getState('list.start'); 97 $id .= ':' . $this->getState('list.limit'); 98 99 return parent::getStoreId($id); 100 } 101 102 /** 103 * Method to auto-populate the model state. Calling getState in this method will result in recursion. 104 * 105 * @return void 106 * 107 * @since 2.5 108 */ 109 protected function populateState() 110 { 111 // Get the configuration options. 112 $app = JFactory::getApplication(); 113 $input = $app->input; 114 $params = JComponentHelper::getParams('com_finder'); 115 $user = JFactory::getUser(); 116 117 // Get the query input. 118 $this->setState('input', $input->request->get('q', '', 'string')); 119 $this->setState('language', $input->request->get('l', '', 'string')); 120 121 // Load the list state. 122 $this->setState('list.start', 0); 123 $this->setState('list.limit', 10); 124 125 // Load the parameters. 126 $this->setState('params', $params); 127 128 // Load the user state. 129 $this->setState('user.id', (int) $user->get('id')); 130 } 131 }
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 |