This is giving me a syntax error. It looks gross this way, but I can't think of any...
[lhc/web/wiklou.git] / includes / SpecialCategories.php
1 <?php
2 /**
3 *
4 * @addtogroup SpecialPage
5 */
6
7 function wfSpecialCategories() {
8 global $wgOut;
9
10 $cap = new CategoryPager();
11 $wgOut->addHTML(
12 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
13 $cap->getNavigationBar()
14 . '<ul>' . $cap->getBody() . '</ul>' .
15 $cap->getNavigationBar()
16 );
17 }
18
19 /**
20 * @addtogroup SpecialPage
21 * @addtogroup Pager
22 */
23 class CategoryPager extends AlphabeticPager {
24 function getQueryInfo() {
25 return array(
26 'tables' => array('categorylinks'),
27 'fields' => array('cl_to','count(*) AS count'),
28 'options' => array('GROUP BY' => 'cl_to')
29 );
30 }
31
32 function getIndexField() {
33 return "cl_to";
34 }
35
36 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
37 function getBody() {
38 if (!$this->mQueryDone) {
39 $this->doQuery();
40 }
41 $batch = new LinkBatch;
42
43 $this->mResult->rewind();
44
45 while ( $row = $this->mResult->fetchObject() ) {
46 $batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cl_to ) );
47 }
48 $batch->execute();
49 $this->mResult->rewind();
50 return parent::getBody();
51 }
52
53 function formatRow($result) {
54 global $wgLang;
55 $title = Title::makeTitle( NS_CATEGORY, $result->cl_to );
56 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
57 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
58 $wgLang->formatNum( $result->count ) );
59 return Xml::tags('li', null, "$titleText ($count)" ) . "\n";
60 }
61 }
62
63