From: Victor Vasiliev Date: Thu, 20 Mar 2008 09:20:23 +0000 (+0000) Subject: * (bug 13395) list=allcategories should use category table X-Git-Tag: 1.31.0-rc.0~48946 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=caf1e1004367d51c9b7ce1475fd10e0a2be9a54a;p=lhc%2Fweb%2Fwiklou.git * (bug 13395) list=allcategories should use category table * cat_hidden doesn't work. why? --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6e25693854..21efa3cf1e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -110,6 +110,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13428) Fix regression in protection form layout HTML validity * (bug 9403) Sanitize newlines from search term input * (bug 13429) Separate date and time in message sp-newimages-showfrom +* (bug 13137) Allow setting 'editprotected' right separately from 'protect', + so groups may optionally edit protected pages without having 'protect' perms === API changes in 1.13 === @@ -133,8 +135,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13390) One invalid title no longer kills an entire API query * (bug 13419) Fix gblredirect so it actually works * (bug 13418) Disable eiredirect because it's useless -* (bug 13137) Allow setting 'editprotected' right separately from 'protect', - so groups may optionally edit protected pages without having 'protect' perms +* (bug 13395) list=allcategories should use category table === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index 78ed363704..51b7a8590c 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -53,21 +53,27 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $db = $this->getDB(); $params = $this->extractRequestParams(); - $this->addTables('categorylinks'); - $this->addFields('cl_to'); + $this->addTables('category'); + $this->addFields('cat_title'); if (!is_null($params['from'])) - $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); + $this->addWhere('cat_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); if (isset ($params['prefix'])) - $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); + $this->addWhere("cat_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); $this->addOption('LIMIT', $params['limit']+1); - $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'descending' ? ' DESC' : '')); + $this->addOption('ORDER BY', 'cat_title' . ($params['dir'] == 'descending' ? ' DESC' : '')); $this->addOption('DISTINCT'); + + $prop = array_flip($params['prop']); + $this->addFieldsIf( array( 'cat_pages', 'cat_subcats', 'cat_files' ), isset($prop['size']) ); + //$this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) ); $res = $this->select(__METHOD__); $pages = array(); + $categories = array(); + $result = $this->getResult(); $count = 0; while ($row = $db->fetchObject($res)) { if (++ $count > $params['limit']) { @@ -78,19 +84,29 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { } // Normalize titles - $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to); + $titleObj = Title::makeTitle(NS_CATEGORY, $row->cat_title); if(!is_null($resultPageSet)) $pages[] = $titleObj->getPrefixedText(); - else - // Don't show "Category:" everywhere in non-generator mode - $pages[] = $titleObj->getText(); + else { + $item = array(); + $result->setContent( $item, $titleObj->getText() ); + if( isset( $prop['size'] ) ) { + $item['size'] = $row->cat_pages; + $item['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files; + $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'] = ''; + $categories[] = $item; + } } $db->freeResult($res); if (is_null($resultPageSet)) { - $result = $this->getResult(); - $result->setIndexedTagName($pages, 'c'); - $result->addValue('query', $this->getModuleName(), $pages); + $result->setIndexedTagName($categories, 'c'); + $result->addValue('query', $this->getModuleName(), $categories); } else { $resultPageSet->populateFromTitles($pages); } @@ -113,7 +129,12 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { ApiBase :: PARAM_MIN => 1, ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 - ) + ), + 'prop' => array ( + ApiBase :: PARAM_TYPE => array( 'size', /*'hidden'*/ ), + ApiBase :: PARAM_DFLT => '', + ApiBase :: PARAM_ISMULTI => true + ), ); } @@ -122,7 +143,8 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { 'from' => 'The category to start enumerating from.', 'prefix' => 'Search for all category titles that begin with this value.', 'dir' => 'Direction to sort in.', - 'limit' => 'How many categories to return.' + 'limit' => 'How many categories to return.', + 'prop' => 'Indicates if API should output category size', ); } @@ -132,6 +154,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { protected function getExamples() { return array ( + 'api.php?action=query&list=allcategories&acprop=size', 'api.php?action=query&generator=allcategories&gacprefix=List&prop=info', ); }