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/ApiQueryCategories.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'includes/api/ApiQueryCategories.php') diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index a6bca698..1c1f1550 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -24,11 +24,6 @@ * @file */ -if ( !defined( 'MEDIAWIKI' ) ) { - // Eclipse helper - will be ignored in production - require_once( "ApiQueryBase.php" ); -} - /** * A query module to enumerate categories the set of pages belong to. * @@ -80,7 +75,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { foreach ( $params['categories'] as $cat ) { $title = Title::newFromText( $cat ); if ( !$title || $title->getNamespace() != NS_CATEGORY ) { - $this->setWarning( "``$cat'' is not a category" ); + $this->setWarning( "\"$cat\" is not a category" ); } else { $cats[] = $title->getDBkey(); } @@ -127,11 +122,16 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { } $this->addOption( 'USE INDEX', array( 'categorylinks' => 'cl_from' ) ); + + $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' ); // Don't order by cl_from if it's constant in the WHERE clause if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) { - $this->addOption( 'ORDER BY', 'cl_to' ); + $this->addOption( 'ORDER BY', 'cl_to' . $dir ); } else { - $this->addOption( 'ORDER BY', "cl_from, cl_to" ); + $this->addOption( 'ORDER BY', array( + 'cl_from' . $dir, + 'cl_to' . $dir + )); } $res = $this->select( __METHOD__ ); @@ -213,6 +213,13 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { 'categories' => array( ApiBase::PARAM_ISMULTI => true, ), + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ) + ), ); } @@ -228,6 +235,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { 'show' => 'Which kind of categories to show', 'continue' => 'When more results are available, use this to continue', 'categories' => 'Only list these categories. Useful for checking whether a certain page is in a certain category', + 'dir' => 'The direction in which to list', ); } @@ -241,12 +249,10 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { ) ); } - protected function getExamples() { + public function getExamples() { return array( - 'Get a list of categories [[Albert Einstein]] belongs to:', - ' api.php?action=query&prop=categories&titles=Albert%20Einstein', - 'Get information about all categories used in the [[Albert Einstein]]:', - ' api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info' + 'api.php?action=query&prop=categories&titles=Albert%20Einstein' => 'Get a list of categories [[Albert Einstein]] belongs to', + 'api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info' => 'Get information about all categories used in the [[Albert Einstein]]', ); } -- cgit v1.2.3-54-g00ecf