(bug 13166) Adding TitleSecureAndSplit hook. Modified patch by Joshua Bacher
[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 global $wgRequest;
26 return array(
27 'tables' => array('categorylinks'),
28 'fields' => array('cl_to','count(*) AS count'),
29 'options' => array('GROUP BY' => 'cl_to')
30 );
31 }
32
33 function getIndexField() {
34 return "cl_to";
35 }
36
37 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
38 function getBody() {
39 if (!$this->mQueryDone) {
40 $this->doQuery();
41 }
42 $batch = new LinkBatch;
43
44 $this->mResult->rewind();
45
46 while ( $row = $this->mResult->fetchObject() ) {
47 $batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cl_to ) );
48 }
49 $batch->execute();
50 $this->mResult->rewind();
51 return parent::getBody();
52 }
53
54 function formatRow($result) {
55 global $wgLang;
56 $title = Title::makeTitle( NS_CATEGORY, $result->cl_to );
57 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
58 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
59 $wgLang->formatNum( $result->count ) );
60 return Xml::tags('li', null, "$titleText ($count)" ) . "\n";
61 }
62 }
63
64