6ffe65b4536a2be5f8629cf4471f663c3ee49a5f
4 * @addtogroup SpecialPage
7 function wfSpecialCategories() {
10 $cap = new CategoryPager();
12 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
13 $cap->getNavigationBar()
14 . '<ul>' . $cap->getBody() . '</ul>' .
15 $cap->getNavigationBar()
20 * @addtogroup SpecialPage
23 class CategoryPager
extends AlphabeticPager
{
24 private $mOrderType = 'abc';
26 public function __construct() {
27 parent
::__construct();
28 if( $this->mRequest
->getText( 'order' ) == 'count' ) {
29 $this->mOrderType
= 'count';
31 if( $this->mRequest
->getText( 'direction' ) == 'asc' ) {
32 $this->mDefaultDirection
= false;
33 } elseif( $this->mRequest
->getText( 'direction' ) == 'desc'
34 ||
$this->mOrderType
== 'count' ) {
35 $this->mDefaultDirection
= true;
39 function getQueryInfo() {
42 'tables' => array( 'category' ),
43 'fields' => array( 'cat_title','cat_pages' ),
44 'conds' => array( 'cat_pages > 0' )
48 function getIndexField() {
49 # We can't use mOrderType here, since this is called from the parent
51 if( $this->mRequest
->getText( 'order' ) == 'count' ) {
58 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
59 public function getBody() {
60 if (!$this->mQueryDone
) {
63 $batch = new LinkBatch
;
65 $this->mResult
->rewind();
67 while ( $row = $this->mResult
->fetchObject() ) {
68 $batch->addObj( Title
::makeTitleSafe( NS_CATEGORY
, $row->cat_title
) );
71 $this->mResult
->rewind();
72 return parent
::getBody();
75 function formatRow($result) {
77 $title = Title
::makeTitle( NS_CATEGORY
, $result->cat_title
);
78 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
79 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
80 $wgLang->formatNum( $result->cat_pages
) );
81 return Xml
::tags('li', null, "$titleText ($count)" ) . "\n";
84 /** Override this to order by count */
85 public function getNavigationBar() {
86 $nav = parent
::getNavigationBar() . ' (';
87 if( $this->mOrderType
== 'abc' ) {
88 $nav .= $this->makeLink(
89 wfMsgHTML( 'special-categories-sort-count' ),
90 array( 'order' => 'count' )
93 $nav .= $this->makeLink(
94 wfMsgHTML( 'special-categories-sort-abc' ),
95 array( 'order' => 'abc' )
99 # FIXME, these are stupid query names. "order" and "dir" are already
101 if( $this->mDefaultDirection
) {
103 $nav .= $this->makeLink(
104 wfMsgHTML( 'special-categories-sort-asc' ),
105 array( 'direction' => 'asc' )
108 $nav .= $this->makeLink(
109 wfMsgHTML( 'special-categories-sort-desc' ),
110 array( 'direction' => 'desc' )