Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php |
— | — | @@ -183,8 +183,7 @@ |
184 | 184 | $page = $dbr->tableName( 'page' ); |
185 | 185 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
186 | 186 | |
187 | | - $sql = "SELECT cat.page_namespace, cat.page_title, |
188 | | - CASE WHEN cat.page_namespace=".NS_CATEGORY." THEN 0 ELSE 1 END AS presort |
| 187 | + $sql = "SELECT cat.page_namespace, cat.page_title |
189 | 188 | $transFields |
190 | 189 | FROM $page as cat |
191 | 190 | JOIN $categorylinks ON cl_from = cat.page_id |
— | — | @@ -193,23 +192,29 @@ |
194 | 193 | $nsmatch |
195 | 194 | "./*AND cat.page_is_redirect = 0*/" |
196 | 195 | $transWhere |
197 | | - ORDER BY presort, cl_sortkey |
| 196 | + ORDER BY cl_sortkey |
198 | 197 | LIMIT " . (int)$wgCategoryTreeMaxChildren; |
199 | 198 | |
200 | 199 | $res = $dbr->query( $sql, __METHOD__ ); |
201 | 200 | |
202 | | - $s= ''; |
| 201 | + #collect categories separately from other pages |
| 202 | + $categories= ''; |
| 203 | + $other= ''; |
203 | 204 | |
204 | 205 | while ( $row = $dbr->fetchRow( $res ) ) { |
205 | | - #TODO: translation support; ideally added to Title object |
206 | | - $t = Title::makeTitle( $row['page_namespace'], $row['page_title'] ); |
207 | | - $s .= $this->renderNode( $t, $mode, $depth>0, false, $depth-1 ); |
208 | | - $s .= "\n\t\t"; |
| 206 | + #TODO: translation support; ideally added to Title object |
| 207 | + $t = Title::makeTitle( $row['page_namespace'], $row['page_title'] ); |
| 208 | + |
| 209 | + $s = $this->renderNode( $t, $mode, $depth>0, false, $depth-1 ); |
| 210 | + $s .= "\n\t\t"; |
| 211 | + |
| 212 | + if ($row['page_namespace'] == NS_CATEGORY) $categories .= $s; |
| 213 | + else $other .= $s; |
209 | 214 | } |
210 | 215 | |
211 | 216 | $dbr->freeResult( $res ); |
212 | 217 | |
213 | | - return $s; |
| 218 | + return $categories . $other; |
214 | 219 | } |
215 | 220 | |
216 | 221 | /** |