Index: trunk/phase3/includes/api/ApiQueryAllCategories.php |
— | — | @@ -53,21 +53,27 @@ |
54 | 54 | $db = $this->getDB(); |
55 | 55 | $params = $this->extractRequestParams(); |
56 | 56 | |
57 | | - $this->addTables('categorylinks'); |
58 | | - $this->addFields('cl_to'); |
| 57 | + $this->addTables('category'); |
| 58 | + $this->addFields('cat_title'); |
59 | 59 | |
60 | 60 | if (!is_null($params['from'])) |
61 | | - $this->addWhere('cl_to>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); |
| 61 | + $this->addWhere('cat_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); |
62 | 62 | if (isset ($params['prefix'])) |
63 | | - $this->addWhere("cl_to LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); |
| 63 | + $this->addWhere("cat_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'"); |
64 | 64 | |
65 | 65 | $this->addOption('LIMIT', $params['limit']+1); |
66 | | - $this->addOption('ORDER BY', 'cl_to' . ($params['dir'] == 'descending' ? ' DESC' : '')); |
| 66 | + $this->addOption('ORDER BY', 'cat_title' . ($params['dir'] == 'descending' ? ' DESC' : '')); |
67 | 67 | $this->addOption('DISTINCT'); |
| 68 | + |
| 69 | + $prop = array_flip($params['prop']); |
| 70 | + $this->addFieldsIf( array( 'cat_pages', 'cat_subcats', 'cat_files' ), isset($prop['size']) ); |
| 71 | + //$this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) ); |
68 | 72 | |
69 | 73 | $res = $this->select(__METHOD__); |
70 | 74 | |
71 | 75 | $pages = array(); |
| 76 | + $categories = array(); |
| 77 | + $result = $this->getResult(); |
72 | 78 | $count = 0; |
73 | 79 | while ($row = $db->fetchObject($res)) { |
74 | 80 | if (++ $count > $params['limit']) { |
— | — | @@ -78,19 +84,29 @@ |
79 | 85 | } |
80 | 86 | |
81 | 87 | // Normalize titles |
82 | | - $titleObj = Title::makeTitle(NS_CATEGORY, $row->cl_to); |
| 88 | + $titleObj = Title::makeTitle(NS_CATEGORY, $row->cat_title); |
83 | 89 | if(!is_null($resultPageSet)) |
84 | 90 | $pages[] = $titleObj->getPrefixedText(); |
85 | | - else |
86 | | - // Don't show "Category:" everywhere in non-generator mode |
87 | | - $pages[] = $titleObj->getText(); |
| 91 | + else { |
| 92 | + $item = array(); |
| 93 | + $result->setContent( $item, $titleObj->getText() ); |
| 94 | + if( isset( $prop['size'] ) ) { |
| 95 | + $item['size'] = $row->cat_pages; |
| 96 | + $item['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files; |
| 97 | + $item['files'] = $row->cat_files; |
| 98 | + $item['subcats'] = $row->cat_subcats; |
| 99 | + } |
| 100 | + //Isn't populated, so doesn't work |
| 101 | + //if( isset( $prop['hidden'] ) && $row->cat_hidden ) |
| 102 | + // $item['hidden'] = ''; |
| 103 | + $categories[] = $item; |
| 104 | + } |
88 | 105 | } |
89 | 106 | $db->freeResult($res); |
90 | 107 | |
91 | 108 | if (is_null($resultPageSet)) { |
92 | | - $result = $this->getResult(); |
93 | | - $result->setIndexedTagName($pages, 'c'); |
94 | | - $result->addValue('query', $this->getModuleName(), $pages); |
| 109 | + $result->setIndexedTagName($categories, 'c'); |
| 110 | + $result->addValue('query', $this->getModuleName(), $categories); |
95 | 111 | } else { |
96 | 112 | $resultPageSet->populateFromTitles($pages); |
97 | 113 | } |
— | — | @@ -113,7 +129,12 @@ |
114 | 130 | ApiBase :: PARAM_MIN => 1, |
115 | 131 | ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
116 | 132 | ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
117 | | - ) |
| 133 | + ), |
| 134 | + 'prop' => array ( |
| 135 | + ApiBase :: PARAM_TYPE => array( 'size', /*'hidden'*/ ), |
| 136 | + ApiBase :: PARAM_DFLT => '', |
| 137 | + ApiBase :: PARAM_ISMULTI => true |
| 138 | + ), |
118 | 139 | ); |
119 | 140 | } |
120 | 141 | |
— | — | @@ -122,7 +143,8 @@ |
123 | 144 | 'from' => 'The category to start enumerating from.', |
124 | 145 | 'prefix' => 'Search for all category titles that begin with this value.', |
125 | 146 | 'dir' => 'Direction to sort in.', |
126 | | - 'limit' => 'How many categories to return.' |
| 147 | + 'limit' => 'How many categories to return.', |
| 148 | + 'prop' => 'Indicates if API should output category size', |
127 | 149 | ); |
128 | 150 | } |
129 | 151 | |
— | — | @@ -132,6 +154,7 @@ |
133 | 155 | |
134 | 156 | protected function getExamples() { |
135 | 157 | return array ( |
| 158 | + 'api.php?action=query&list=allcategories&acprop=size', |
136 | 159 | 'api.php?action=query&generator=allcategories&gacprefix=List&prop=info', |
137 | 160 | ); |
138 | 161 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -110,6 +110,8 @@ |
111 | 111 | * (bug 13428) Fix regression in protection form layout HTML validity |
112 | 112 | * (bug 9403) Sanitize newlines from search term input |
113 | 113 | * (bug 13429) Separate date and time in message sp-newimages-showfrom |
| 114 | +* (bug 13137) Allow setting 'editprotected' right separately from 'protect', |
| 115 | + so groups may optionally edit protected pages without having 'protect' perms |
114 | 116 | |
115 | 117 | |
116 | 118 | === API changes in 1.13 === |
— | — | @@ -133,8 +135,7 @@ |
134 | 136 | * (bug 13390) One invalid title no longer kills an entire API query |
135 | 137 | * (bug 13419) Fix gblredirect so it actually works |
136 | 138 | * (bug 13418) Disable eiredirect because it's useless |
137 | | -* (bug 13137) Allow setting 'editprotected' right separately from 'protect', |
138 | | - so groups may optionally edit protected pages without having 'protect' perms |
| 139 | +* (bug 13395) list=allcategories should use category table |
139 | 140 | |
140 | 141 | === Languages updated in 1.13 === |
141 | 142 | |