| [ Indice ] |
Riferimento incrociato di Joomla! 1.5.14 - VM 1.1.4Servizio fornito da VMItalia |
[Vedi sommario] [Stampa] [Vedi testo]
1 <?php 2 /** 3 * @version $Id: search.php 10752 2008-08-23 01:53:31Z eddieajau $ 4 * @package Joomla 5 * @subpackage Search 6 * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 // Check to ensure this file is included in Joomla! 16 defined( '_JEXEC' ) or die( 'Restricted access' ); 17 18 jimport('joomla.application.component.model'); 19 20 /** 21 * Search Component Search Model 22 * 23 * @package Joomla 24 * @subpackage Search 25 * @since 1.5 26 */ 27 class SearchModelSearch extends JModel 28 { 29 /** 30 * Sezrch data array 31 * 32 * @var array 33 */ 34 var $_data = null; 35 36 /** 37 * Search total 38 * 39 * @var integer 40 */ 41 var $_total = null; 42 43 /** 44 * Search areas 45 * 46 * @var integer 47 */ 48 var $_areas = null; 49 50 /** 51 * Pagination object 52 * 53 * @var object 54 */ 55 var $_pagination = null; 56 57 /** 58 * Constructor 59 * 60 * @since 1.5 61 */ 62 function __construct() 63 { 64 parent::__construct(); 65 66 global $mainframe; 67 68 //Get configuration 69 $config = JFactory::getConfig(); 70 71 // Get the pagination request variables 72 $this->setState('limit', $mainframe->getUserStateFromRequest('com_search.limit', 'limit', $config->getValue('config.list_limit'), 'int')); 73 $this->setState('limitstart', JRequest::getVar('limitstart', 0, '', 'int')); 74 75 // Set the search parameters 76 $keyword = urldecode(JRequest::getString('searchword')); 77 $match = JRequest::getWord('searchphrase', 'all'); 78 $ordering = JRequest::getWord('ordering', 'newest'); 79 $this->setSearch($keyword, $match, $ordering); 80 81 //Set the search areas 82 $areas = JRequest::getVar('areas'); 83 $this->setAreas($areas); 84 } 85 86 /** 87 * Method to set the search parameters 88 * 89 * @access public 90 * @param string search string 91 * @param string mathcing option, exact|any|all 92 * @param string ordering option, newest|oldest|popular|alpha|category 93 */ 94 function setSearch($keyword, $match = 'all', $ordering = 'newest') 95 { 96 if(isset($keyword)) { 97 $this->setState('keyword', $keyword); 98 } 99 100 if(isset($match)) { 101 $this->setState('match', $match); 102 } 103 104 if(isset($ordering)) { 105 $this->setState('ordering', $ordering); 106 } 107 } 108 109 /** 110 * Method to set the search areas 111 * 112 * @access public 113 * @param array Active areas 114 * @param array Search areas 115 */ 116 function setAreas($active = array(), $search = array()) 117 { 118 $this->_areas['active'] = $active; 119 $this->_areas['search'] = $search; 120 } 121 122 /** 123 * Method to get weblink item data for the category 124 * 125 * @access public 126 * @return array 127 */ 128 function getData() 129 { 130 // Lets load the content if it doesn't already exist 131 if (empty($this->_data)) 132 { 133 $areas = $this->getAreas(); 134 135 JPluginHelper::importPlugin( 'search'); 136 $dispatcher =& JDispatcher::getInstance(); 137 $results = $dispatcher->trigger( 'onSearch', array( 138 $this->getState('keyword'), 139 $this->getState('match'), 140 $this->getState('ordering'), 141 $areas['active']) ); 142 143 $rows = array(); 144 foreach($results AS $result) { 145 $rows = array_merge( (array) $rows, (array) $result); 146 } 147 148 $this->_total = count($rows); 149 if($this->getState('limit') > 0) { 150 $this->_data = array_splice($rows, $this->getState('limitstart'), $this->getState('limit')); 151 } else { 152 $this->_data = $rows; 153 } 154 } 155 156 return $this->_data; 157 } 158 159 /** 160 * Method to get the total number of weblink items for the category 161 * 162 * @access public 163 * @return integer 164 */ 165 function getTotal() 166 { 167 return $this->_total; 168 } 169 170 /** 171 * Method to get a pagination object of the weblink items for the category 172 * 173 * @access public 174 * @return integer 175 */ 176 function getPagination() 177 { 178 // Lets load the content if it doesn't already exist 179 if (empty($this->_pagination)) 180 { 181 jimport('joomla.html.pagination'); 182 $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') ); 183 } 184 185 return $this->_pagination; 186 } 187 188 /** 189 * Method to get the search areas 190 * 191 * @since 1.5 192 */ 193 function getAreas() 194 { 195 global $mainframe; 196 197 // Load the Category data 198 if (empty($this->_areas['search'])) 199 { 200 $areas = array(); 201 202 JPluginHelper::importPlugin( 'search'); 203 $dispatcher =& JDispatcher::getInstance(); 204 $searchareas = $dispatcher->trigger( 'onSearchAreas' ); 205 206 foreach ($searchareas as $area) { 207 $areas = array_merge( $areas, $area ); 208 } 209 210 $this->_areas['search'] = $areas; 211 } 212 213 return $this->_areas; 214 } 215 }
titolo
Descrizione
Corpo
titolo
Descrizione
Corpo
titolo
Descrizione
Corpo
titolo
Corpo
| Generato il: Mon Oct 19 20:29:27 2009 | Generato con PHPXref 0.7 |