7 function wfSpecialCategories( $par=null ) {
8 global $wgOut, $wgRequest;
11 $from = $wgRequest->getText( 'from' );
15 $cap = new CategoryPager( $from );
18 XML
::openElement( 'div', array('class' => 'mw-spcontent') ) .
19 wfMsgExt( 'categoriespagetext', array( 'parse' ), $cap->getNumRows() ) .
20 $cap->getStartForm( $from ) .
21 $cap->getNavigationBar() .
22 '<ul>' . $cap->getBody() . '</ul>' .
23 $cap->getNavigationBar() .
24 XML
::closeElement( 'div' )
29 * TODO: Allow sorting by count. We need to have a unique index to do this
32 * @ingroup SpecialPage Pager
34 class CategoryPager
extends AlphabeticPager
{
35 function __construct( $from ) {
36 parent
::__construct();
37 $from = str_replace( ' ', '_', $from );
39 global $wgCapitalLinks, $wgContLang;
40 if( $wgCapitalLinks ) {
41 $from = $wgContLang->ucfirst( $from );
43 $this->mOffset
= $from;
47 function getQueryInfo() {
49 'tables' => array( 'category' ),
50 'fields' => array( 'cat_title','cat_pages' ),
51 'conds' => array( 'cat_pages > 0' ),
52 'options' => array( 'USE INDEX' => 'cat_title' ),
56 function getIndexField() {
57 # return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
61 function getDefaultQuery() {
62 parent
::getDefaultQuery();
63 unset( $this->mDefaultQuery
['from'] );
64 return $this->mDefaultQuery
;
66 # protected function getOrderTypeMessages() {
67 # return array( 'abc' => 'special-categories-sort-abc',
68 # 'count' => 'special-categories-sort-count' );
71 protected function getDefaultDirections() {
72 # return array( 'abc' => false, 'count' => true );
76 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
77 public function getBody() {
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()->link( $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' ) ) ) );