From f758f07e8d079dc621d1d9416833fc1d300f8533 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sat, 16 Aug 2008 21:21:12 +0000 Subject: [PATCH] (bug 15178) Added clshow to prop=categories to allow filtering for hidden/non-hidden categories --- RELEASE-NOTES | 2 ++ includes/api/ApiQueryCategories.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index cee93deab3..bc7d928ec9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -151,6 +151,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN output. * When the limit on multivalue parameters is exceeded, a warning is issued * list=search doesn't list missing pages any more +* (bug 15178) Added clshow to prop=categories to allow filtering for hidden/ + non-hidden categories === Languages updated in 1.14 === diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 8f7949aa97..9ec0d7a588 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -54,6 +54,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $params = $this->extractRequestParams(); $prop = $params['prop']; + $show = array_flip((array)$params['show']); $this->addFields(array ( 'cl_from', @@ -91,6 +92,15 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { "(cl_from = $clfrom AND ". "cl_to >= '$clto')"); } + if(isset($show['hidden']) && isset($show['!hidden'])) + $this->dieUsage("Incorrect parameter - mutually exclusive values may not be supplied", 'show'); + if(isset($show['hidden']) || isset($show['!hidden'])) + { + $this->addTables('category'); + $this->addWhere(array( 'cl_to = cat_title', + 'cat_hidden' => isset($show['hidden']))); + } + # 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'); @@ -166,6 +176,13 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { 'timestamp', ) ), + 'show' => array( + ApiBase :: PARAM_ISMULTI => true, + ApiBase :: PARAM_TYPE => array( + 'hidden', + '!hidden', + ) + ), 'limit' => array( ApiBase :: PARAM_DFLT => 10, ApiBase :: PARAM_TYPE => 'limit', @@ -181,6 +198,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { return array ( 'prop' => 'Which additional properties to get for each category.', 'limit' => 'How many categories to return', + 'show' => 'Which kind of categories to show', 'continue' => 'When more results are available, use this to continue', ); } -- 2.20.1