7 function wfSpecialCategories( $par=null ) {
8 global $wgOut, $wgRequest;
11 $from = $wgRequest->getText( 'from' );
15 $cap = new CategoryPager( $from );
17 XML
::openElement( 'div', array('class' => 'mw-spcontent') ) .
18 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
19 $cap->getStartForm( $from ) .
20 $cap->getNavigationBar() .
21 '<ul>' . $cap->getBody() . '</ul>' .
22 $cap->getNavigationBar() .
23 XML
::closeElement( 'div' )
28 * TODO: Allow sorting by count. We need to have a unique index to do this
31 * @ingroup SpecialPage Pager
33 class CategoryPager
extends AlphabeticPager
{
34 function __construct( $from ) {
35 parent
::__construct();
36 $from = str_replace( ' ', '_', $from );
38 global $wgCapitalLinks, $wgContLang;
39 if( $wgCapitalLinks ) {
40 $from = $wgContLang->ucfirst( $from );
42 $this->mOffset
= $from;
46 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'] );
65 # protected function getOrderTypeMessages() {
66 # return array( 'abc' => 'special-categories-sort-abc',
67 # 'count' => 'special-categories-sort-count' );
70 protected function getDefaultDirections() {
71 # return array( 'abc' => false, 'count' => true );
75 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
76 public function getBody() {
77 if (!$this->mQueryDone
) {
80 $batch = new LinkBatch
;
82 $this->mResult
->rewind();
84 while ( $row = $this->mResult
->fetchObject() ) {
85 $batch->addObj( Title
::makeTitleSafe( NS_CATEGORY
, $row->cat_title
) );
88 $this->mResult
->rewind();
89 return parent
::getBody();
92 function formatRow($result) {
94 $title = Title
::makeTitle( NS_CATEGORY
, $result->cat_title
);
95 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
96 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
97 $wgLang->formatNum( $result->cat_pages
) );
98 return Xml
::tags('li', null, "$titleText ($count)" ) . "\n";
101 public function getStartForm( $from ) {
103 $t = SpecialPage
::getTitleFor( 'Categories' );
106 Xml
::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
107 Xml
::hidden( 'title', $t->getPrefixedText() ) .
108 Xml
::fieldset( wfMsg( 'categories' ),
109 Xml
::inputLabel( wfMsg( 'categoriesfrom' ),
110 'from', 'from', 20, $from ) .
112 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) ) );