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 $from = Title
::capitalize( $from, NS_CATEGORY
);
40 $this->mOffset
= $from;
44 function getQueryInfo() {
46 'tables' => array( 'category' ),
47 'fields' => array( 'cat_title','cat_pages' ),
48 'conds' => array( 'cat_pages > 0' ),
49 'options' => array( 'USE INDEX' => 'cat_title' ),
53 function getIndexField() {
54 # return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
58 function getDefaultQuery() {
59 parent
::getDefaultQuery();
60 unset( $this->mDefaultQuery
['from'] );
61 return $this->mDefaultQuery
;
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 $batch = new LinkBatch
;
77 $this->mResult
->rewind();
79 while ( $row = $this->mResult
->fetchObject() ) {
80 $batch->addObj( Title
::makeTitleSafe( NS_CATEGORY
, $row->cat_title
) );
83 $this->mResult
->rewind();
84 return parent
::getBody();
87 function formatRow($result) {
89 $title = Title
::makeTitle( NS_CATEGORY
, $result->cat_title
);
90 $titleText = $this->getSkin()->link( $title, htmlspecialchars( $title->getText() ) );
91 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
92 $wgLang->formatNum( $result->cat_pages
) );
93 return Xml
::tags('li', null, "$titleText ($count)" ) . "\n";
96 public function getStartForm( $from ) {
98 $t = SpecialPage
::getTitleFor( 'Categories' );
101 Xml
::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
102 Xml
::hidden( 'title', $t->getPrefixedText() ) .
103 Xml
::fieldset( wfMsg( 'categories' ),
104 Xml
::inputLabel( wfMsg( 'categoriesfrom' ),
105 'from', 'from', 20, $from ) .
107 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) ) );