<?php
-
/**
- * Created on December 12, 2007
*
- * API for MediaWiki 1.8+
*
- * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Created on December 12, 2007
+ *
+ * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@gmail.com
*
* 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
*/
if ( !defined( 'MEDIAWIKI' ) ) {
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
+ /**
+ * @param $resultPageSet ApiPageSet
+ * @return void
+ */
private function run( $resultPageSet = null ) {
$db = $this->getDB();
$params = $this->extractRequestParams();
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
- $this->addWhereRange( 'cat_title', $dir, $from, null );
+ $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
+ $this->addWhereRange( 'cat_title', $dir, $from, $to );
+
+ $min = $params['minpage'];
+ $max = $params['maxpage'];
+ $this->addWhereRange( 'cat_pages', $dir, $min, $max );
+
if ( isset( $params['prefix'] ) ) {
$this->addWhere( 'cat_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
}
$res = $this->select( __METHOD__ );
$pages = array();
- $categories = array();
+
$result = $this->getResult();
$count = 0;
foreach ( $res as $row ) {
public function getAllowedParams() {
return array(
'from' => null,
+ 'to' => null,
'prefix' => null,
'dir' => array(
ApiBase::PARAM_DFLT => 'ascending',
'descending'
),
),
+ 'minpage' => array(
+ ApiBase::PARAM_DFLT => null,
+ ApiBase::PARAM_TYPE => 'integer'
+ ),
+ 'maxpage' => array(
+ ApiBase::PARAM_DFLT => null,
+ ApiBase::PARAM_TYPE => 'integer'
+ ),
'limit' => array(
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_TYPE => 'limit',
public function getParamDescription() {
return array(
'from' => 'The category to start enumerating from',
+ 'to' => 'The category to stop enumerating at',
'prefix' => 'Search for all category titles that begin with this value',
'dir' => 'Direction to sort in',
+ 'minpage' => 'Minimum number of category page members',
+ 'maxpage' => 'Maximum number of category page members',
'limit' => 'How many categories to return',
'prop' => array(
'Which properties to get',
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}