[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_search/ -> controller.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: controller.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Content
   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 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.controller');
  19  
  20  /**
  21   * Search Component Controller
  22   *
  23   * @package        Joomla
  24   * @subpackage    Search
  25   * @since 1.5
  26   */
  27  class SearchController extends JController
  28  {
  29      /**
  30       * Method to show the search view
  31       *
  32       * @access    public
  33       * @since    1.5
  34       */
  35  	function display()
  36      {
  37          JRequest::setVar('view','search'); // force it to be the polls view
  38          parent::display();
  39      }
  40  
  41  	function search()
  42      {
  43          // slashes cause errors, <> get stripped anyway later on. # causes problems.
  44          $badchars = array('#','>','<','\\'); 
  45          $searchword = trim(str_replace($badchars, '', JRequest::getString('searchword', null, 'post')));
  46          // if searchword enclosed in double quotes, strip quotes and do exact match
  47          if (substr($searchword,0,1) == '"' && substr($searchword, -1) == '"') { 
  48              $post['searchword'] = substr($searchword,1,-1);
  49              JRequest::setVar('searchphrase', 'exact');
  50          }
  51          else {
  52              $post['searchword'] = $searchword;
  53          }
  54          $post['ordering']    = JRequest::getWord('ordering', null, 'post');
  55          $post['searchphrase']    = JRequest::getWord('searchphrase', 'all', 'post');
  56          $post['limit']  = JRequest::getInt('limit', null, 'post');
  57          if($post['limit'] === null) unset($post['limit']);
  58  
  59          $areas = JRequest::getVar('areas', null, 'post', 'array');
  60          if ($areas) {
  61              foreach($areas as $area)
  62              {
  63                  $post['areas'][] = JFilterInput::clean($area, 'cmd');
  64              }
  65          }
  66          
  67          // set Itemid id for links from menu
  68          $menu = &JSite::getMenu();
  69          $items    = $menu->getItems('link', 'index.php?option=com_search&view=search');
  70  
  71          if(isset($items[0])) {
  72              $post['Itemid'] = $items[0]->id;
  73          } else if (JRequest::getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
  74              $post['Itemid'] = JRequest::getInt('Itemid');
  75          } 
  76          
  77          unset($post['task']);
  78          unset($post['submit']);
  79  
  80          $uri = JURI::getInstance();
  81          $uri->setQuery($post);
  82          $uri->setVar('option', 'com_search');
  83  
  84  
  85          $this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query', 'fragment')), false));
  86      }
  87  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1