API: Adding 'hidden' field to list=allcategories and prop=categoryinfo output
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 15 Jun 2008 20:28:48 +0000 (20:28 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 15 Jun 2008 20:28:48 +0000 (20:28 +0000)
RELEASE-NOTES
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryCategoryInfo.php

index ae413a5..c928bdf 100644 (file)
@@ -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 ===
 
index df08efa..4e675b0 100644 (file)
@@ -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
                        ),
index 865b553..bbb428e 100644 (file)
@@ -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);