Source for file categories.php

Documentation is available at categories.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 Categories class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  MediaWiki
  17.  * @since       12.3
  18.  */
  19. {
  20.     /**
  21.      * Method to list all categories the page(s) belong to.
  22.      *
  23.      * @param   array    $titles        Page titles to retrieve categories.
  24.      * @param   array    $clprop        List of additional properties to get.
  25.      * @param   array    $clshow        Type of categories to show.
  26.      * @param   integer  $cllimit       Number of categories to return.
  27.      * @param   boolean  $clcontinue    Continue when more results are available.
  28.      * @param   array    $clcategories  Only list these categories.
  29.      * @param   string   $cldir         Direction of listing.
  30.      *
  31.      * @return  object 
  32.      *
  33.      * @since   12.1
  34.      */
  35.     public function getCategories(array $titlesarray $clprop nullarray $clshow null$cllimit null$clcontinue false,
  36.         array $clcategories null$cldir null)
  37.     {
  38.         // Build the request.
  39.         $path '?action=query&prop=categories';
  40.  
  41.         // Append titles to the request.
  42.         $path .= '&titles=' $this->buildParameter($titles);
  43.  
  44.         if (isset($clprop))
  45.         {
  46.             $path .= '&clprop=' $this->buildParameter($clprop);
  47.         }
  48.  
  49.         if (isset($clshow))
  50.         {
  51.             $path .= '&$clshow=' $this->buildParameter($clshow);
  52.         }
  53.  
  54.         if (isset($cllimit))
  55.         {
  56.             $path .= '&cllimit=' $cllimit;
  57.         }
  58.  
  59.         if ($clcontinue)
  60.         {
  61.             $path .= '&clcontinue=';
  62.         }
  63.  
  64.         if (isset($clcategories))
  65.         {
  66.             $path .= '&clcategories=' $this->buildParameter($clcategories);
  67.         }
  68.  
  69.         if (isset($cldir))
  70.         {
  71.             $path .= '&cldir=' $cldir;
  72.         }
  73.  
  74.         // Send the request.
  75.         $response $this->client->get($this->fetchUrl($path));
  76.  
  77.         return $this->validateResponse($response);
  78.     }
  79.  
  80.     /**
  81.      * Method to get information about all categories used.
  82.      *
  83.      * @param   array  $titles  Page titles to retrieve categories.
  84.      *
  85.      * @return  object 
  86.      *
  87.      * @since   12.3
  88.      */
  89.     public function getCategoriesUsed(array $titles)
  90.     {
  91.         // Build the request
  92.         $path '?action=query&generator=categories&prop=info';
  93.  
  94.         // Append titles to the request
  95.         $path .= '&titles=' $this->buildParameter($titles);
  96.  
  97.         // Send the request.
  98.         $response $this->client->get($this->fetchUrl($path));
  99.  
  100.         return $this->validateResponse($response);
  101.     
  102.  
  103.     /**
  104.      * Method to get information about the given categories.
  105.      *
  106.      * @param   array    $titles      Page titles to retrieve categories.
  107.      * @param   boolean  $clcontinue  Continue when more results are available.
  108.      *
  109.      * @return  object 
  110.      *
  111.      * @since   12.3
  112.      */
  113.     public function getCategoriesInfo(array $titles$clcontinue false)
  114.     {
  115.         // Build the request.
  116.         $path '?action=query&prop=categoryinfo';
  117.  
  118.         // Append titles to the request
  119.         $path .= '&titles=' $this->buildParameter($titles);
  120.  
  121.         if ($clcontinue)
  122.         {
  123.             $path .= '&clcontinue=';
  124.         }
  125.  
  126.         // Send the request.
  127.         $response $this->client->get($this->fetchUrl($path));
  128.  
  129.         return $this->validateResponse($response);
  130.     }
  131.  
  132.     /**
  133.      * Method to enumerate all categories.
  134.      *
  135.      * @param   string   $acfrom    The category to start enumerating from.
  136.      * @param   string   $acto      The category to stop enumerating at.
  137.      * @param   string   $acprefix  Search for all category titles that begin with this value.
  138.      * @param   string   $acdir     Direction to sort in.
  139.      * @param   integer  $acmin     Minimum number of category members.
  140.      * @param   integer  $acmax     Maximum number of category members.
  141.      * @param   integer  $aclimit   How many categories to return.
  142.      * @param   array    $acprop    Which properties to get.
  143.      *
  144.      * @return  object 
  145.      *
  146.      * @since   12.3
  147.      */
  148.     public function enumerateCategories($acfrom null$acto null$acprefix null$acdir null$acmin null,
  149.         $acmax null$aclimit nullarray $acprop null)
  150.     {
  151.         // Build the request.
  152.         $path '?action=query&list=allcategories';
  153.  
  154.         if (isset($acfrom))
  155.         {
  156.             $path .= '&acfrom=' $acfrom;
  157.         }
  158.  
  159.         if (isset($acto))
  160.         {
  161.             $path .= '&acto=' $acto;
  162.         }
  163.  
  164.         if (isset($acprefix))
  165.         {
  166.             $path .= '&acprefix=' $acprefix;
  167.         }
  168.  
  169.         if (isset($acdir))
  170.         {
  171.             $path .= '&acdir=' $acdir;
  172.         }
  173.  
  174.         if (isset($acfrom))
  175.         {
  176.             $path .= '&acfrom=' $acfrom;
  177.         }
  178.  
  179.         if (isset($acmin))
  180.         {
  181.             $path .= '&acmin=' $acmin;
  182.         }
  183.  
  184.         if (isset($acmax))
  185.         {
  186.             $path .= '&acmax=' $acmax;
  187.         }
  188.  
  189.         if (isset($aclimit))
  190.         {
  191.             $path .= '&aclimit=' $aclimit;
  192.         }
  193.  
  194.         if (isset($acprop))
  195.         {
  196.             $path .= '&acprop=' $this->buildParameter($acprop);
  197.         }
  198.  
  199.         // Send the request.
  200.         $response $this->client->get($this->fetchUrl($path));
  201.  
  202.         return $this->validateResponse($response);
  203.     }
  204.  
  205.     /**
  206.      * Method to list change tags.
  207.      *
  208.      * @param   array   $tgprop   List of properties to get.
  209.      * @param   string  $tglimit  The maximum number of tags to limit.
  210.      *
  211.      * @return  object 
  212.      *
  213.      * @since   12.3
  214.      */
  215.     public function getChangeTags(array $tgprop null$tglimit null)
  216.     {
  217.         // Build the request.
  218.         $path '?action=query&list=tags';
  219.  
  220.         if (isset($tgprop))
  221.         {
  222.             $path .= '&tgprop=' $this->buildParameter($tgprop);
  223.         }
  224.  
  225.         if (isset($tglimit))
  226.         {
  227.             $path .= '&tglimit=' $tglimit;
  228.         }
  229.  
  230.         // @TODO add support for $tgcontinue
  231.  
  232.         // Send the request.
  233.         $response $this->client->get($this->fetchUrl($path));
  234.  
  235.         return $this->validateResponse($response);
  236.     }
  237. }

Documentation generated on Tue, 19 Nov 2013 14:55:04 +0100 by phpDocumentor 1.4.3