| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: view.html.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Weblinks 6 * @copyright Copyright (C) 2005 - 2010 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 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and 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.view'); 19 20 /** 21 * HTML View class for the WebLinks component 22 * 23 * @static 24 * @package Joomla 25 * @subpackage Weblinks 26 * @since 1.0 27 */ 28 class SearchViewSearch extends JView 29 { 30 function display($tpl = null) 31 { 32 global $mainframe; 33 34 require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers'.DS.'search.php' ); 35 36 // Initialize some variables 37 $pathway =& $mainframe->getPathway(); 38 $uri =& JFactory::getURI(); 39 40 $error = ''; 41 $rows = null; 42 $total = 0; 43 44 // Get some data from the model 45 $areas = &$this->get('areas'); 46 $state = &$this->get('state'); 47 $searchword = $state->get('keyword'); 48 49 $params = &$mainframe->getParams(); 50 51 $menus = &JSite::getMenu(); 52 $menu = $menus->getActive(); 53 54 // because the application sets a default page title, we need to get it 55 // right from the menu item itself 56 if (is_object( $menu )) { 57 $menu_params = new JParameter( $menu->params ); 58 if (!$menu_params->get( 'page_title')) { 59 $params->set('page_title', JText::_( 'Search' )); 60 } 61 } else { 62 $params->set('page_title', JText::_( 'Search' )); 63 } 64 65 $document = &JFactory::getDocument(); 66 $document->setTitle( $params->get( 'page_title' ) ); 67 68 // Get the parameters of the active menu item 69 $params = &$mainframe->getParams(); 70 71 // built select lists 72 $orders = array(); 73 $orders[] = JHTML::_('select.option', 'newest', JText::_( 'Newest first' ) ); 74 $orders[] = JHTML::_('select.option', 'oldest', JText::_( 'Oldest first' ) ); 75 $orders[] = JHTML::_('select.option', 'popular', JText::_( 'Most popular' ) ); 76 $orders[] = JHTML::_('select.option', 'alpha', JText::_( 'Alphabetical' ) ); 77 $orders[] = JHTML::_('select.option', 'category', JText::_( 'Section/Category' ) ); 78 79 $lists = array(); 80 $lists['ordering'] = JHTML::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering') ); 81 82 $searchphrases = array(); 83 $searchphrases[] = JHTML::_('select.option', 'all', JText::_( 'All words' ) ); 84 $searchphrases[] = JHTML::_('select.option', 'any', JText::_( 'Any words' ) ); 85 $searchphrases[] = JHTML::_('select.option', 'exact', JText::_( 'Exact phrase' ) ); 86 $lists['searchphrase' ]= JHTML::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match') ); 87 88 // log the search 89 SearchHelper::logSearch( $searchword); 90 91 //limit searchword 92 93 if(SearchHelper::limitSearchWord($searchword)) { 94 $error = JText::_( 'SEARCH_MESSAGE' ); 95 } 96 97 //sanatise searchword 98 if(SearchHelper::santiseSearchWord($searchword, $state->get('match'))) { 99 $error = JText::_( 'IGNOREKEYWORD' ); 100 } 101 102 if (!$searchword && count( JRequest::get('post') ) ) { 103 //$error = JText::_( 'Enter a search keyword' ); 104 } 105 106 // put the filtered results back into the model 107 // for next release, the checks should be done in the model perhaps... 108 $state->set('keyword', $searchword); 109 110 if(!$error) 111 { 112 $results = &$this->get('data' ); 113 $total = &$this->get('total'); 114 $pagination = &$this->get('pagination'); 115 116 require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); 117 118 for ($i=0; $i < count($results); $i++) 119 { 120 $row = &$results[$i]->text; 121 122 if ($state->get('match') == 'exact') 123 { 124 $searchwords = array($searchword); 125 $needle = $searchword; 126 } 127 else 128 { 129 $searchwords = preg_split("/\s+/u", $searchword); 130 $needle = $searchwords[0]; 131 } 132 133 $row = SearchHelper::prepareSearchContent( $row, 200, $needle ); 134 $searchwords = array_unique( $searchwords ); 135 $searchRegex = '#('; 136 $x = 0; 137 foreach ($searchwords as $k => $hlword) 138 { 139 $searchRegex .= ($x == 0 ? '' : '|'); 140 $searchRegex .= preg_quote($hlword, '#'); 141 $x++; 142 } 143 $searchRegex .= ')#iu'; 144 145 $row = preg_replace($searchRegex, '<span class="highlight">\0</span>', $row ); 146 147 $result =& $results[$i]; 148 if ($result->created) { 149 $created = JHTML::Date ( $result->created ); 150 } 151 else { 152 $created = ''; 153 } 154 155 $result->created = $created; 156 $result->count = $i + 1; 157 } 158 } 159 160 $this->result = JText::sprintf( 'TOTALRESULTSFOUND', $total ); 161 162 $this->assignRef('pagination', $pagination); 163 $this->assignRef('results', $results); 164 $this->assignRef('lists', $lists); 165 $this->assignRef('params', $params); 166 167 $this->assign('ordering', $state->get('ordering')); 168 $this->assign('searchword', $searchword); 169 $this->assign('searchphrase', $state->get('match')); 170 $this->assign('searchareas', $areas); 171 172 $this->assign('total', $total); 173 $this->assign('error', $error); 174 $this->assign('action', $uri->toString()); 175 176 parent::display($tpl); 177 } 178 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |