Source for file links.php

Documentation is available at links.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 Links class for the Joomla Platform.
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  MediaWiki
  17.  * @since       12.3
  18.  */
  19. {
  20.  
  21.     /**
  22.      * Method to return all links from the given page(s).
  23.      *
  24.      * @param   array   $titles       Page titles to retrieve links.
  25.      * @param   array   $plnamespace  Namespaces to get links.
  26.      * @param   string  $pllimit      Number of links to return.
  27.      * @param   string  $plcontinue   Continue when more results are available.
  28.      * @param   array   $pltitles     List links to these titles.
  29.      * @param   string  $pldir        Direction of listing.
  30.      *
  31.      * @return  object 
  32.      *
  33.      * @since   12.3
  34.      */
  35.     public function getLinks(array $titlesarray $plnamespace null$pllimit null$plcontinue nullarray $pltitles null$pldir null)
  36.     {
  37.         // Build the request.
  38.         $path '?action=query&prop=links';
  39.  
  40.         // Append titles to the request.
  41.         $path .= '&titles=' $this->buildParameter($titles);
  42.  
  43.         if (isset($plnamespace))
  44.         {
  45.             $path .= '&plnamespace=' $this->buildParameter($plnamespace);
  46.         }
  47.  
  48.         if (isset($pllimit))
  49.         {
  50.             $path .= '&pllimit=' $pllimit;
  51.         }
  52.  
  53.         if (isset($plcontinue))
  54.         {
  55.             $path .= '&plcontinue=' $plcontinue;
  56.         }
  57.  
  58.         if (isset($pltitles))
  59.         {
  60.             $path .= '&pltitles=' $this->buildParameter($pltitles);
  61.         }
  62.  
  63.         if (isset($pldir))
  64.         {
  65.             $path .= '&pldir=' $pldir;
  66.         }
  67.  
  68.         // Send the request.
  69.         $response $this->client->get($this->fetchUrl($path));
  70.  
  71.         return $this->validateResponse($response);
  72.     }
  73.  
  74.     /**
  75.      * Method to return info about the link pages.
  76.      *
  77.      * @param   array  $titles  Page titles to retrieve links.
  78.      *
  79.      * @return  object 
  80.      *
  81.      * @since   12.3
  82.      */
  83.     public function getLinksUsed(array $titles)
  84.     {
  85.         // Build the request.
  86.         $path '?action=query&generator=links&prop=info';
  87.  
  88.         // Append titles to the request.
  89.         $path .= '&titles=' $this->buildParameter($titles);
  90.  
  91.         // Send the request.
  92.         $response $this->client->get($this->fetchUrl($path));
  93.  
  94.         return $this->validateResponse($response);
  95.     
  96.  
  97.     /**
  98.      * Method to return all interwiki links from the given page(s).
  99.      *
  100.      * @param   array    $titles      Page titles to retrieve links.
  101.      * @param   boolean  $iwurl       Whether to get the full url.
  102.      * @param   integer  $iwlimit     Number of interwiki links to return.
  103.      * @param   boolean  $iwcontinue  When more results are available, use this to continue.
  104.      * @param   string   $iwprefix    Prefix for the interwiki.
  105.      * @param   string   $iwtitle     Interwiki link to search for.
  106.      * @param   string   $iwdir       The direction in which to list.
  107.      *
  108.      * @return  object 
  109.      *
  110.      * @since   12.3
  111.      */
  112.     public function getIWLinks(array $titles$iwurl false$iwlimit null$iwcontinue false$iwprefix null$iwtitle null$iwdir null)
  113.     {
  114.         // Build the request.
  115.         $path '?action=query&prop=links';
  116.  
  117.         // Append titles to the request.
  118.         $path .= '&titles=' $this->buildParameter($titles);
  119.  
  120.         if ($iwurl)
  121.         {
  122.             $path .= '&iwurl=';
  123.         }
  124.  
  125.         if (isset($iwlimit))
  126.         {
  127.             $path .= '&iwlimit=' $iwlimit;
  128.         }
  129.  
  130.         if ($iwcontinue)
  131.         {
  132.             $path .= '&iwcontinue=';
  133.         }
  134.  
  135.         if (isset($iwprefix))
  136.         {
  137.             $path .= '&iwprefix=' $iwprefix;
  138.         }
  139.  
  140.         if (isset($iwtitle))
  141.         {
  142.             $path .= '&iwtitle=' $iwtitle;
  143.         }
  144.  
  145.         if (isset($iwdir))
  146.         {
  147.             $path .= '&iwdir=' $iwdir;
  148.         }
  149.  
  150.         // Send the request.
  151.         $response $this->client->get($this->fetchUrl($path));
  152.  
  153.         return $this->validateResponse($response);
  154.     }
  155.  
  156.     /**
  157.      * Method to return all interlanguage links from the given page(s).
  158.      *
  159.      * @param   array    $titles      Page titles to retrieve links.
  160.      * @param   integer  $lllimit     Number of langauge links to return.
  161.      * @param   boolean  $llcontinue  When more results are available, use this to continue.
  162.      * @param   string   $llurl       Whether to get the full URL.
  163.      * @param   string   $lllang      Language code.
  164.      * @param   string   $lltitle     Link to search for.
  165.      * @param   string   $lldir       The direction in which to list.
  166.      *
  167.      * @return  object 
  168.      *
  169.      * @since   12.3
  170.      */
  171.     public function getLangLinks(array $titles$lllimit null$llcontinue false$llurl null$lllang null$lltitle null$lldir null)
  172.     {
  173.         // Build the request.
  174.         $path '?action=query&prop=langlinks';
  175.  
  176.         // Append titles to the request.
  177.         $path .= '&titles=' $this->buildParameter($titles);
  178.  
  179.         if (isset($lllimit))
  180.         {
  181.             $path .= '&lllimit=' $lllimit;
  182.         }
  183.  
  184.         if ($llcontinue)
  185.         {
  186.             $path .= '&llcontinue=';
  187.         }
  188.  
  189.         if (isset($llurl))
  190.         {
  191.             $path .= '&llurl=' $llurl;
  192.         }
  193.  
  194.         if (isset($lllang))
  195.         {
  196.             $path .= '&lllang=' $lllang;
  197.         }
  198.  
  199.         if (isset($lltitle))
  200.         {
  201.             $path .= '&lltitle=' $lltitle;
  202.         }
  203.  
  204.         if (isset($lldir))
  205.         {
  206.             $path .= '&lldir=' $lldir;
  207.         }
  208.  
  209.         // Send the request.
  210.         $response $this->client->get($this->fetchUrl($path));
  211.  
  212.         return $this->validateResponse($response);
  213.     }
  214.  
  215.     /**
  216.      * Method to return all external urls from the given page(s).
  217.      *
  218.      * @param   array    $titles      Page titles to retrieve links.
  219.      * @param   integer  $ellimit     Number of links to return.
  220.      * @param   string   $eloffset    When more results are available, use this to continue.
  221.      * @param   string   $elprotocol  Protocol of the url.
  222.      * @param   string   $elquery     Search string without protocol.
  223.      *
  224.      * @return  object 
  225.      *
  226.      * @since   12.3
  227.      */
  228.     public function getExtLinks(array $titles$ellimit null$eloffset null$elprotocol null$elquery null)
  229.     {
  230.         // Build the request.
  231.         $path '?action=query&prop=extlinks';
  232.  
  233.         // Append titles to the request.
  234.         $path .= '&titles=' $this->buildParameter($titles);
  235.  
  236.         if (isset($ellimit))
  237.         {
  238.             $path .= '&ellimit=' $ellimit;
  239.         }
  240.  
  241.         if (isset($eloffset))
  242.         {
  243.             $path .= '&eloffset=' $eloffset;
  244.         }
  245.  
  246.         if (isset($elprotocol))
  247.         {
  248.             $path .= '&elprotocol=' $elprotocol;
  249.         }
  250.  
  251.         if (isset($elquery))
  252.         {
  253.             $path .= '&elquery=' $elquery;
  254.         }
  255.  
  256.         // Send the request.
  257.         $response $this->client->get($this->fetchUrl($path));
  258.  
  259.         return $this->validateResponse($response);
  260.     }
  261.  
  262.     /**
  263.      * Method to enumerate all links that point to a given namespace.
  264.      *
  265.      * @param   boolean  $alcontinue   When more results are available, use this to continue.
  266.      * @param   string   $alfrom       Start listing at this title. The title need not exist.
  267.      * @param   string   $alto         The page title to stop enumerating at.
  268.      * @param   string   $alprefix     Search for all page titles that begin with this value.
  269.      * @param   string   $alunique     Only show unique links.
  270.      * @param   array    $alprop       What pieces of information to include.
  271.      * @param   string   $alnamespace  The namespace to enumerate.
  272.      * @param   integer  $allimit      Number of links to return.
  273.      *
  274.      * @return  object 
  275.      *
  276.      * @since   12.3
  277.      */
  278.     public function enumerateLinks($alcontinue false$alfrom null$alto null$alprefix null$alunique nullarray $alprop null,
  279.         $alnamespace null$allimit null)
  280.     {
  281.         // Build the request.
  282.         $path '?action=query&meta=siteinfo';
  283.  
  284.         if ($alcontinue)
  285.         {
  286.             $path .= '&alcontinue=';
  287.         }
  288.  
  289.         if (isset($alfrom))
  290.         {
  291.             $path .= '&alfrom=' $alfrom;
  292.         }
  293.  
  294.         if (isset($alto))
  295.         {
  296.             $path .= '&alto=' $alto;
  297.         }
  298.  
  299.         if (isset($alprefix))
  300.         {
  301.             $path .= '&alprefix=' $alprefix;
  302.         }
  303.  
  304.         if (isset($alunique))
  305.         {
  306.             $path .= '&alunique=' $alunique;
  307.         }
  308.  
  309.         if (isset($alprop))
  310.         {
  311.             $path .= '&alprop=' $this->buildParameter($alprop);
  312.         }
  313.  
  314.         if (isset($alnamespace))
  315.         {
  316.             $path .= '&alnamespace=' $alnamespace;
  317.         }
  318.  
  319.         if (isset($allimit))
  320.         {
  321.             $path .= '&allimit=' $allimit;
  322.         }
  323.  
  324.         // Send the request.
  325.         $response $this->client->get($this->fetchUrl($path));
  326.  
  327.         return $this->validateResponse($response);
  328.     }
  329. }

Documentation generated on Tue, 19 Nov 2013 15:07:10 +0100 by phpDocumentor 1.4.3