From 4eaf657ebbbe208bfe0733709f76a57d92d13277 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 15 Jun 2008 20:28:48 +0000 Subject: [PATCH] API: Adding 'hidden' field to list=allcategories and prop=categoryinfo output --- RELEASE-NOTES | 1 + includes/api/ApiQueryAllCategories.php | 9 ++++----- includes/api/ApiQueryCategoryInfo.php | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ae413a562c..c928bdfdce 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -445,6 +445,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14471) Use HTMLTidy and generate limit report in action=parse * (bug 14459) Added prependtext and appendtext parameters to action=edit * (bug 14526) Unescaped SQL in list=backlinks +* Added 'hidden' flag to list=allcategories and prop=categoryinfo output === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index df08efac60..4e675b0301 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -66,7 +66,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $prop = array_flip($params['prop']); $this->addFieldsIf( array( 'cat_pages', 'cat_subcats', 'cat_files' ), isset($prop['size']) ); - //$this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) ); + $this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) ); $res = $this->select(__METHOD__); @@ -95,9 +95,8 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $item['files'] = $row->cat_files; $item['subcats'] = $row->cat_subcats; } - //Isn't populated, so doesn't work - //if( isset( $prop['hidden'] ) && $row->cat_hidden ) - // $item['hidden'] = ''; + if( isset( $prop['hidden'] ) && $row->cat_hidden ) + $item['hidden'] = ''; $categories[] = $item; } } @@ -130,7 +129,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 ), 'prop' => array ( - ApiBase :: PARAM_TYPE => array( 'size', /*'hidden'*/ ), + ApiBase :: PARAM_TYPE => array( 'size', 'hidden' ), ApiBase :: PARAM_DFLT => '', ApiBase :: PARAM_ISMULTI => true ), diff --git a/includes/api/ApiQueryCategoryInfo.php b/includes/api/ApiQueryCategoryInfo.php index 865b553ee4..bbb428eb73 100644 --- a/includes/api/ApiQueryCategoryInfo.php +++ b/includes/api/ApiQueryCategoryInfo.php @@ -55,7 +55,7 @@ class ApiQueryCategoryInfo extends ApiQueryBase { } $this->addTables('category'); - $this->addFields(array('cat_title', 'cat_pages', 'cat_subcats', 'cat_files')); + $this->addFields(array('cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'cat_hidden')); $this->addWhere(array('cat_title' => $cattitles)); $db = $this->getDB(); @@ -70,6 +70,8 @@ class ApiQueryCategoryInfo extends ApiQueryBase { $vals['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files; $vals['files'] = $row->cat_files; $vals['subcats'] = $row->cat_subcats; + if($row->cat_hidden) + $vals['hidden'] = ''; $this->addPageSubItems($catids[$row->cat_title], $vals); } $db->freeResult($res); -- 2.20.1