Add support for Number grouping(commafy) based on CLDR number grouping patterns like...
[lhc/web/wiklou.git] / includes / api / ApiQueryLinks.php
index 9e5b75d..8090daf 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-
 /**
- * Created on May 12, 2007
  *
- * API for MediaWiki 1.8+
+ *
+ * Created on May 12, 2007
  *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
@@ -21,6 +20,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -38,7 +39,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        const LINKS = 'links';
        const TEMPLATES = 'templates';
 
-       private $table, $prefix, $description;
+       private $table, $prefix, $description, $helpUrl;
 
        public function __construct( $query, $moduleName ) {
                switch ( $moduleName ) {
@@ -47,12 +48,14 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                $this->prefix = 'pl';
                                $this->description = 'link';
                                $this->titlesParam = 'titles';
+                               $this->helpUrl = 'http://www.mediawiki.org/wiki/API:Properties#links_.2F_pl';
                                break;
                        case self::TEMPLATES:
                                $this->table = 'templatelinks';
                                $this->prefix = 'tl';
                                $this->description = 'template';
                                $this->titlesParam = 'templates';
+                               $this->helpUrl = 'http://www.mediawiki.org/wiki/API:Properties#templates_.2F_tl';
                                break;
                        default:
                                ApiBase::dieDebug( __METHOD__, 'Unknown module name' );
@@ -65,10 +68,18 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                $this->run();
        }
 
+       public function getCacheMode( $params ) {
+               return 'public';
+       }
+
        public function executeGenerator( $resultPageSet ) {
                $this->run( $resultPageSet );
        }
 
+       /**
+        * @param $resultPageSet ApiPageSet
+        * @return
+        */
        private function run( $resultPageSet = null ) {
                if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
                        return; // nothing to do
@@ -85,7 +96,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                $this->addTables( $this->table );
                $this->addWhereFld( $this->prefix . '_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
                $this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] );
-               
+
                if ( !is_null( $params[$this->titlesParam] ) ) {
                        $lb = new LinkBatch;
                        foreach ( $params[$this->titlesParam] as $t ) {
@@ -208,7 +219,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                );
                if ( $this->getModuleName() == self::LINKS ) {
                        $arr[$this->titlesParam] = 'Only list links to these titles. Useful for checking whether a certain page links to a certain title.';
-               } else if ( $this->getModuleName() == self::TEMPLATES ) {
+               } elseif ( $this->getModuleName() == self::TEMPLATES ) {
                        $arr[$this->titlesParam] = 'Only list these templates. Useful for checking whether a certain page uses a certain template.';
                }
                return $arr;
@@ -218,7 +229,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                return "Returns all {$this->description}s from the given page(s)";
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
                        "Get {$this->description}s from the [[Main Page]]:",
                        "  api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
@@ -229,7 +240,11 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                );
        }
 
+       public function getHelpUrls() {
+               return $this->helpUrl;
+       }
+
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }
-}
\ No newline at end of file
+}