7 function wfSpecialCategories() {
8 global $wgOut, $wgRequest;
10 $cap = new CategoryPager();
12 wfMsgExt( 'categoriespagetext', array( 'parse' ) ) .
13 $cap->getStartForm( str_replace( '_', ' ', $wgRequest->getVal( 'offset' ) ) ) .
14 $cap->getNavigationBar() .
15 '<ul>' . $cap->getBody() . '</ul>' .
16 $cap->getNavigationBar()
21 * TODO: Allow sorting by count. We need to have a unique index to do this
24 * @ingroup SpecialPage Pager
26 class CategoryPager
extends AlphabeticPager
{
27 function getQueryInfo() {
30 'tables' => array( 'category' ),
31 'fields' => array( 'cat_title','cat_pages' ),
32 'conds' => array( 'cat_pages > 0' ),
33 'options' => array( 'USE INDEX' => 'cat_title' ),
37 function getIndexField() {
38 # return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
42 # protected function getOrderTypeMessages() {
43 # return array( 'abc' => 'special-categories-sort-abc',
44 # 'count' => 'special-categories-sort-count' );
47 protected function getDefaultDirections() {
48 # return array( 'abc' => false, 'count' => true );
52 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
53 public function getBody() {
54 if (!$this->mQueryDone
) {
57 $batch = new LinkBatch
;
59 $this->mResult
->rewind();
61 while ( $row = $this->mResult
->fetchObject() ) {
62 $batch->addObj( Title
::makeTitleSafe( NS_CATEGORY
, $row->cat_title
) );
65 $this->mResult
->rewind();
66 return parent
::getBody();
69 function formatRow($result) {
71 $title = Title
::makeTitle( NS_CATEGORY
, $result->cat_title
);
72 $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
73 $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ),
74 $wgLang->formatNum( $result->cat_pages
) );
75 return Xml
::tags('li', null, "$titleText ($count)" ) . "\n";
78 public function getStartForm( $from='' ) {
80 $t = SpecialPage
::getTitleFor( 'Categories' );
83 Xml
::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
84 Xml
::hidden( 'title', $t->getPrefixedText() ) .
85 Xml
::fieldset( wfMsg( 'categories' ),
86 Xml
::inputLabel( wfMsg( 'categoriesfrom' ),
87 'offset', 'offset', 20, $from ) .
89 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) ) );