7 function wfSpecialCategories( $par=null ) {
8 global $wgOut, $wgRequest;
11 $from = $wgRequest->getText( 'from' );
15 $cap = new CategoryPager( $from );
17 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
18 $cap->getStartForm( $from ) .
19 $cap->getNavigationBar() .
20 '<ul>' . $cap->getBody() . '</ul>' .
21 $cap->getNavigationBar()
26 * TODO: Allow sorting by count. We need to have a unique index to do this
29 * @ingroup SpecialPage Pager
31 class CategoryPager
extends AlphabeticPager
{
32 function __construct( $from ) {
33 parent
::__construct();
34 $from = str_replace( ' ', '_', $from );
36 global $wgCapitalLinks, $wgContLang;
37 if( $wgCapitalLinks ) {
38 $from = $wgContLang->ucfirst( $from );
40 $this->mOffset
= $from;
44 function getQueryInfo() {
47 'tables' => array( 'category' ),
48 'fields' => array( 'cat_title','cat_pages' ),
49 'conds' => array( 'cat_pages > 0' ),
50 'options' => array( 'USE INDEX' => 'cat_title' ),
54 function getIndexField() {
55 # return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
59 function getDefaultQuery() {
60 parent
::getDefaultQuery();
61 unset( $this->mDefaultQuery
['from'] );
63 # protected function getOrderTypeMessages() {
64 # return array( 'abc' => 'special-categories-sort-abc',
65 # 'count' => 'special-categories-sort-count' );
68 protected function getDefaultDirections() {
69 # return array( 'abc' => false, 'count' => true );
73 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
74 public function getBody() {
75 if (!$this->mQueryDone
) {
78 $batch = new LinkBatch
;
80 $this->mResult
->rewind();
82 while ( $row = $this->mResult
->fetchObject() ) {
83 $batch->addObj( Title
::makeTitleSafe( NS_CATEGORY
, $row->cat_title
) );
86 $this->mResult
->rewind();
87 return parent
::getBody();
90 function formatRow($result) {
92 $title = Title
::makeTitle( NS_CATEGORY
, $result->cat_title
);
93 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
94 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
95 $wgLang->formatNum( $result->cat_pages
) );
96 return Xml
::tags('li', null, "$titleText ($count)" ) . "\n";
99 public function getStartForm( $from ) {
101 $t = SpecialPage
::getTitleFor( 'Categories' );
104 Xml
::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
105 Xml
::hidden( 'title', $t->getPrefixedText() ) .
106 Xml
::fieldset( wfMsg( 'categories' ),
107 Xml
::inputLabel( wfMsg( 'categoriesfrom' ),
108 'from', 'from', 20, $from ) .
110 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) ) );