Source for file search.php

Documentation is available at search.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  MediaWiki
  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
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * MediaWiki API Search class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  MediaWiki
  17.  * @since       12.3
  18.  */
  19. {
  20.  
  21.     /**
  22.      * Method to perform a full text search.
  23.      *
  24.      * @param   string   $srsearch     Search for all page titles (or content) that has this value.
  25.      * @param   array    $srnamespace  The namespace(s) to enumerate.
  26.      * @param   string   $srwhat       Search inside the text or titles.
  27.      * @param   array    $srinfo       What metadata to return.
  28.      * @param   array    $srprop       What properties to return.
  29.      * @param   boolean  $srredirects  Include redirect pages in the search.
  30.      * @param   integer  $sroffest     Use this value to continue paging.
  31.      * @param   integer  $srlimit      How many total pages to return.
  32.      *
  33.      * @return  object 
  34.      *
  35.      * @since   12.3
  36.      */
  37.     public function search($srsearcharray $srnamespace null$srwhat nullarray $srinfo nullarray $srprop null,
  38.         $srredirects null$sroffest null$srlimit null)
  39.     {
  40.         // Build the request.
  41.         $path '?action=query&list=search';
  42.  
  43.         if (isset($srsearch))
  44.         {
  45.             $path .= '&srsearch=' $srsearch;
  46.         }
  47.  
  48.         if (isset($srnamespace))
  49.         {
  50.             $path .= '&srnamespace=' $this->buildParameter($srnamespace);
  51.         }
  52.  
  53.         if (isset($srwhat))
  54.         {
  55.             $path .= '&srwhat=' $srwhat;
  56.         }
  57.  
  58.         if (isset($srinfo))
  59.         {
  60.             $path .= '&srinfo=' $this->buildParameter($srinfo);
  61.         }
  62.  
  63.         if (isset($srprop))
  64.         {
  65.             $path .= '&srprop=' $this->buildParameter($srprop);
  66.         }
  67.  
  68.         if ($srredirects)
  69.         {
  70.             $path .= '&srredirects=';
  71.         }
  72.  
  73.         if (isset($sroffest))
  74.         {
  75.             $path .= '&sroffest=' $sroffest;
  76.         }
  77.  
  78.         if (isset($srlimit))
  79.         {
  80.             $path .= '&srlimit=' $srlimit;
  81.         }
  82.  
  83.         // Send the request.
  84.         $response $this->client->get($this->fetchUrl($path));
  85.  
  86.         return $this->validateResponse($response);
  87.     }
  88.  
  89.     /**
  90.      * Method to search the wiki using opensearch protocol.
  91.      *
  92.      * @param   string   $search     Search string.
  93.      * @param   integer  $limit         Maximum amount of results to return.
  94.      * @param   array    $namespace  Namespaces to search.
  95.      * @param   string   $suggest    Do nothing if $wgEnableOpenSearchSuggest is false.
  96.      * @param   string   $format     Output format.
  97.      *
  98.      * @return  object 
  99.      *
  100.      * @since   12.3
  101.      */
  102.     public function openSearch($search$limit nullarray $namespace null$suggest null$format null)
  103.     {
  104.         // Build the request.
  105.         $path '?action=query&list=search';
  106.  
  107.         if (isset($search))
  108.         {
  109.             $path .= '&search=' $search;
  110.         }
  111.  
  112.         if (isset($limit))
  113.         {
  114.             $path .= '&limit=' $limit;
  115.         }
  116.  
  117.         if (isset($namespace))
  118.         {
  119.             $path .= '&namespace=' $this->buildParameter($namespace);
  120.         }
  121.  
  122.         if (isset($suggest))
  123.         {
  124.             $path .= '&suggest=' $suggest;
  125.         }
  126.  
  127.         if (isset($format))
  128.         {
  129.             $path .= '&format=' $format;
  130.         }
  131.  
  132.         // Send the request.
  133.         $response $this->client->get($this->fetchUrl($path));
  134.  
  135.         return $this->validateResponse($response);
  136.     }
  137. }

Documentation generated on Tue, 19 Nov 2013 15:12:39 +0100 by phpDocumentor 1.4.3