<?php
/**
+ * Implements Special:Categories
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
*/
/**
- * @file
* @ingroup SpecialPage
*/
+class SpecialCategories extends SpecialPage {
+
+ function __construct() {
+ parent::__construct( 'Categories' );
+ }
+
+ function execute( $par ) {
+ global $wgOut, $wgRequest;
-function wfSpecialCategories( $par=null ) {
- global $wgOut, $wgRequest;
+ $this->setHeaders();
+ $this->outputHeader();
+ $wgOut->allowClickjacking();
- if( $par == '' ) {
- $from = $wgRequest->getText( 'from' );
- } else {
- $from = $par;
+ $from = $wgRequest->getText( 'from', $par );
+
+ $cap = new CategoryPager( $from );
+ $cap->doQuery();
+
+ $wgOut->addHTML(
+ Html::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) .
+ wfMsgExt( 'categoriespagetext', array( 'parse' ), $cap->getNumRows() ) .
+ $cap->getStartForm( $from ) .
+ $cap->getNavigationBar() .
+ '<ul>' . $cap->getBody() . '</ul>' .
+ $cap->getNavigationBar() .
+ Html::closeElement( 'div' )
+ );
}
- $cap = new CategoryPager( $from );
- $cap->doQuery();
- $wgOut->addHTML(
- Xml::openElement( 'div', array('class' => 'mw-spcontent') ) .
- wfMsgExt( 'categoriespagetext', array( 'parse' ), $cap->getNumRows() ) .
- $cap->getStartForm( $from ) .
- $cap->getNavigationBar() .
- '<ul>' . $cap->getBody() . '</ul>' .
- $cap->getNavigationBar() .
- Xml::closeElement( 'div' )
- );
}
/**
$this->mOffset = $from;
}
}
-
+
function getQueryInfo() {
return array(
'tables' => array( 'category' ),
'fields' => array( 'cat_title','cat_pages' ),
- 'conds' => array( 'cat_pages > 0' ),
+ 'conds' => array( 'cat_pages > 0' ),
'options' => array( 'USE INDEX' => 'cat_title' ),
);
}
$this->mResult->rewind();
- while ( $row = $this->mResult->fetchObject() ) {
+ foreach ( $this->mResult as $row ) {
$batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cat_title ) );
}
$batch->execute();
$wgLang->formatNum( $result->cat_pages ) );
return Xml::tags('li', null, "$titleText ($count)" ) . "\n";
}
-
+
public function getStartForm( $from ) {
global $wgScript;
$t = SpecialPage::getTitleFor( 'Categories' );
-
+
return
Xml::tags( 'form', array( 'method' => 'get', 'action' => $wgScript ),
- Xml::hidden( 'title', $t->getPrefixedText() ) .
+ Html::hidden( 'title', $t->getPrefixedText() ) .
Xml::fieldset( wfMsg( 'categories' ),
Xml::inputLabel( wfMsg( 'categoriesfrom' ),
'from', 'from', 20, $from ) .