Source for file controller.php

Documentation is available at controller.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_search
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Search Component Controller
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_search
  17.  * @since       1.5
  18.  */
  19. {
  20.     /**
  21.      * Method to display a view.
  22.      *
  23.      * @param   boolean            If true, the view output will be cached
  24.      * @param   array  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  25.      *
  26.      * @return  JController        This object to support chaining.
  27.      * @since   1.5
  28.      */
  29.     public function display($cachable false$urlparams false)
  30.     {
  31.         $this->input->set('view''search')// force it to be the search view
  32.  
  33.         return parent::display($cachable$urlparams);
  34.     }
  35.  
  36.     public function search()
  37.     {
  38.         // slashes cause errors, <> get stripped anyway later on. # causes problems.
  39.         $badchars array('#''>''<''\\');
  40.         $searchword trim(str_replace($badchars''$this->input->getString('searchword'null'post')));
  41.         // if searchword enclosed in double quotes, strip quotes and do exact match
  42.         if (substr($searchword01== '"' && substr($searchword-1== '"')
  43.         {
  44.             $post['searchword'substr($searchword1-1);
  45.             $this->input->set('searchphrase''exact');
  46.         }
  47.         else
  48.         {
  49.             $post['searchword'$searchword;
  50.         }
  51.         $post['ordering']     $this->input->getWord('ordering'null'post');
  52.         $post['searchphrase'$this->input->getWord('searchphrase''all''post');
  53.         $post['limit']        $this->input->getUInt('limit'null'post');
  54.  
  55.         if ($post['limit'=== null)
  56.         {
  57.             unset($post['limit']);
  58.         }
  59.  
  60.         $areas $this->input->post->get('areas'null'array');
  61.         if ($areas)
  62.         {
  63.             foreach ($areas as $area)
  64.             {
  65.                 $post['areas'][JFilterInput::getInstance()->clean($area'cmd');
  66.             }
  67.         }
  68.  
  69.         // set Itemid id for links from menu
  70.         $app    JFactory::getApplication();
  71.         $menu    $app->getMenu();
  72.         $items    $menu->getItems('link''index.php?option=com_search&view=search');
  73.  
  74.         if (isset($items[0]))
  75.         {
  76.             $post['Itemid'$items[0]->id;
  77.         elseif ($this->input->getInt('Itemid'0//use Itemid from requesting page only if there is no existing menu
  78.             $post['Itemid'$this->input->getInt('Itemid');
  79.         }
  80.  
  81.         unset($post['task']);
  82.         unset($post['submit']);
  83.  
  84.         $uri JUri::getInstance();
  85.         $uri->setQuery($post);
  86.         $uri->setVar('option''com_search');
  87.  
  88.         $this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query''fragment'))false));
  89.     }
  90. }

Documentation generated on Tue, 19 Nov 2013 14:57:24 +0100 by phpDocumentor 1.4.3