Move some of the changes I made to Special:Categories out of SpecialCategories.php...
[mediawiki.git] / includes / SpecialCategories.php
blob38996dcd4a3d9f8ad74b85d76a0e437f8f05029e
1 <?php
2 /**
4 * @addtogroup SpecialPage
5 */
7 function wfSpecialCategories() {
8 global $wgOut;
10 $cap = new CategoryPager();
11 $wgOut->addHTML(
12 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
13 $cap->getNavigationBar()
14 . '<ul>' . $cap->getBody() . '</ul>' .
15 $cap->getNavigationBar()
19 /**
20 * @addtogroup SpecialPage
21 * @addtogroup Pager
23 class CategoryPager extends AlphabeticPager {
24 function getQueryInfo() {
25 global $wgRequest;
26 return array(
27 'tables' => array( 'category' ),
28 'fields' => array( 'cat_title','cat_pages' ),
29 'conds' => array( 'cat_pages > 0' )
33 function getIndexField() {
34 return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
37 protected function getOrderTypeMessages() {
38 return array( 'abc' => 'special-categories-sort-abc',
39 'count' => 'special-categories-sort-count' );
42 protected function getDefaultDirection() {
43 return array( 'abc' => false, 'count' => true );
46 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
47 public function getBody() {
48 if (!$this->mQueryDone) {
49 $this->doQuery();
51 $batch = new LinkBatch;
53 $this->mResult->rewind();
55 while ( $row = $this->mResult->fetchObject() ) {
56 $batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cat_title ) );
58 $batch->execute();
59 $this->mResult->rewind();
60 return parent::getBody();
63 function formatRow($result) {
64 global $wgLang;
65 $title = Title::makeTitle( NS_CATEGORY, $result->cat_title );
66 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
67 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
68 $wgLang->formatNum( $result->cat_pages ) );
69 return Xml::tags('li', null, "$titleText ($count)" ) . "\n";