From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- includes/api/ApiQueryLinks.php | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'includes/api/ApiQueryLinks.php') diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 55217e2f..0377eddb 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -24,11 +24,6 @@ * @file */ -if ( !defined( 'MEDIAWIKI' ) ) { - // Eclipse helper - will be ignored in production - require_once( "ApiQueryBase.php" ); -} - /** * A query module to list all wiki links on a given set of pages. * @@ -48,6 +43,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $this->prefix = 'pl'; $this->description = 'link'; $this->titlesParam = 'titles'; + $this->titlesParamDescription = 'Only list links to these titles. Useful for checking whether a certain page links to a certain title.'; $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#links_.2F_pl'; break; case self::TEMPLATES: @@ -55,6 +51,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $this->prefix = 'tl'; $this->description = 'template'; $this->titlesParam = 'templates'; + $this->titlesParamDescription = 'Only list these templates. Useful for checking whether a certain page uses a certain template.'; $this->helpUrl = 'https://www.mediawiki.org/wiki/API:Properties#templates_.2F_tl'; break; default: @@ -102,7 +99,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { foreach ( $params[$this->titlesParam] as $t ) { $title = Title::newFromText( $t ); if ( !$title ) { - $this->setWarning( "``$t'' is not a valid title" ); + $this->setWarning( "\"$t\" is not a valid title" ); } else { $lb->addObj( $title ); } @@ -131,6 +128,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { ); } + $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' ); // Here's some MySQL craziness going on: if you use WHERE foo='bar' // and later ORDER BY foo MySQL doesn't notice the ORDER BY is pointless // but instead goes and filesorts, because the index for foo was used @@ -138,15 +136,15 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { // clause from the ORDER BY clause $order = array(); if ( count( $this->getPageSet()->getGoodTitles() ) != 1 ) { - $order[] = "{$this->prefix}_from"; + $order[] = $this->prefix . '_from' . $dir; } if ( count( $params['namespace'] ) != 1 ) { - $order[] = "{$this->prefix}_namespace"; + $order[] = $this->prefix . '_namespace' . $dir; } - $order[] = "{$this->prefix}_title"; - $this->addOption( 'ORDER BY', implode( ', ', $order ) ); - $this->addOption( 'USE INDEX', "{$this->prefix}_from" ); + $order[] = $this->prefix . "_title" . $dir; + $this->addOption( 'ORDER BY', $order ); + $this->addOption( 'USE INDEX', $this->prefix . '_from' ); $this->addOption( 'LIMIT', $params['limit'] + 1 ); $res = $this->select( __METHOD__ ); @@ -207,36 +205,38 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $this->titlesParam => array( ApiBase::PARAM_ISMULTI => true, ), + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ) + ), ); } public function getParamDescription() { $desc = $this->description; - $arr = array( + return array( 'namespace' => "Show {$desc}s in this namespace(s) only", 'limit' => "How many {$desc}s to return", 'continue' => 'When more results are available, use this to continue', + $this->titlesParam => $this->titlesParamDescription, + 'dir' => 'The direction in which to list', ); - 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.'; - } 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; } public function getDescription() { return "Returns all {$this->description}s from the given page(s)"; } - protected function getExamples() { + public function getExamples() { + $desc = $this->description; + $name = $this->getModuleName(); return array( - "Get {$this->description}s from the [[Main Page]]:", - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page", - "Get information about the {$this->description} pages in the [[Main Page]]:", - " api.php?action=query&generator={$this->getModuleName()}&titles=Main%20Page&prop=info", - "Get {$this->description}s from the Main Page in the User and Template namespaces:", - " api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page&{$this->prefix}namespace=2|10" + "api.php?action=query&prop={$name}&titles=Main%20Page" => "Get {$desc}s from the [[Main Page]]:", + "api.php?action=query&generator={$name}&titles=Main%20Page&prop=info" => "Get information about the {$desc} pages in the [[Main Page]]:", + "api.php?action=query&prop={$name}&titles=Main%20Page&{$this->prefix}namespace=2|10" => "Get {$desc}s from the Main Page in the User and Template namespaces:", ); } -- cgit v1.2.3-54-g00ecf