aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryAllpages.php
diff options
context:
space:
mode:
authorJack Phoenix <ashley@users.mediawiki.org>2010-02-24 13:34:11 +0000
committerJack Phoenix <ashley@users.mediawiki.org>2010-02-24 13:34:11 +0000
commit96b4f302af4b3c074b0a6c9c6054899230fb388a (patch)
tree10aa303281d80abe0806e74cb2078b43da1a3f65 /includes/api/ApiQueryAllpages.php
parenta1e605da42cb4893695df20b92b33d1bc92437a4 (diff)
downloadmediawikicore-96b4f302af4b3c074b0a6c9c6054899230fb388a.tar.gz
mediawikicore-96b4f302af4b3c074b0a6c9c6054899230fb388a.zip
API: fix copyright symbol, coding style cleanup, more braces
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/62915
Diffstat (limited to 'includes/api/ApiQueryAllpages.php')
-rw-r--r--includes/api/ApiQueryAllpages.php126
1 files changed, 66 insertions, 60 deletions
diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php
index a8573d828b67..c4f86d02dd82 100644
--- a/includes/api/ApiQueryAllpages.php
+++ b/includes/api/ApiQueryAllpages.php
@@ -1,11 +1,11 @@
<?php
-/*
+/**
* Created on Sep 25, 2006
*
* API for MediaWiki 1.8+
*
- * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan <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
@@ -25,7 +25,7 @@
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( 'ApiQueryBase.php' );
+ require_once( 'ApiQueryBase.php' );
}
/**
@@ -36,7 +36,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
class ApiQueryAllpages extends ApiQueryGeneratorBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'ap' );
+ parent::__construct( $query, $moduleName, 'ap' );
}
public function execute() {
@@ -44,8 +44,9 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
}
public function executeGenerator( $resultPageSet ) {
- if ( $resultPageSet->isResolvingRedirects() )
+ if ( $resultPageSet->isResolvingRedirects() ) {
$this->dieUsage( 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator', 'params' );
+ }
$this->run( $resultPageSet );
}
@@ -57,22 +58,24 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
// Page filters
$this->addTables( 'page' );
-
- if ( $params['filterredir'] == 'redirects' )
+
+ if ( $params['filterredir'] == 'redirects' ) {
$this->addWhereFld( 'page_is_redirect', 1 );
- else if ( $params['filterredir'] == 'nonredirects' )
+ } elseif ( $params['filterredir'] == 'nonredirects' ) {
$this->addWhereFld( 'page_is_redirect', 0 );
+ }
$this->addWhereFld( 'page_namespace', $params['namespace'] );
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
$from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
$this->addWhereRange( 'page_title', $dir, $from, null );
-
- if ( isset ( $params['prefix'] ) )
+
+ if ( isset( $params['prefix'] ) ) {
$this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
+ }
if ( is_null( $resultPageSet ) ) {
- $selectFields = array (
+ $selectFields = array(
'page_namespace',
'page_title',
'page_id'
@@ -83,40 +86,42 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
$this->addFields( $selectFields );
$forceNameTitleIndex = true;
- if ( isset ( $params['minsize'] ) ) {
+ if ( isset( $params['minsize'] ) ) {
$this->addWhere( 'page_len>=' . intval( $params['minsize'] ) );
$forceNameTitleIndex = false;
}
- if ( isset ( $params['maxsize'] ) ) {
+ if ( isset( $params['maxsize'] ) ) {
$this->addWhere( 'page_len<=' . intval( $params['maxsize'] ) );
$forceNameTitleIndex = false;
}
// Page protection filtering
- if ( !empty ( $params['prtype'] ) ) {
+ if ( !empty( $params['prtype'] ) ) {
$this->addTables( 'page_restrictions' );
$this->addWhere( 'page_id=pr_page' );
$this->addWhere( 'pr_expiry>' . $db->addQuotes( $db->timestamp() ) );
$this->addWhereFld( 'pr_type', $params['prtype'] );
- if ( isset ( $params['prlevel'] ) ) {
+ if ( isset( $params['prlevel'] ) ) {
// Remove the empty string and '*' from the prlevel array
$prlevel = array_diff( $params['prlevel'], array( '', '*' ) );
-
- if ( !empty( $prlevel ) )
+
+ if ( !empty( $prlevel ) ) {
$this->addWhereFld( 'pr_level', $prlevel );
+ }
}
- if ( $params['prfiltercascade'] == 'cascading' )
+ if ( $params['prfiltercascade'] == 'cascading' ) {
$this->addWhereFld( 'pr_cascade', 1 );
- else if ( $params['prfiltercascade'] == 'noncascading' )
+ } elseif ( $params['prfiltercascade'] == 'noncascading' ) {
$this->addWhereFld( 'pr_cascade', 0 );
+ }
$this->addOption( 'DISTINCT' );
$forceNameTitleIndex = false;
- } else if ( isset ( $params['prlevel'] ) ) {
+ } elseif ( isset( $params['prlevel'] ) ) {
$this->dieUsage( 'prlevel may not be used without prtype', 'params' );
}
@@ -125,7 +130,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
$this->addJoinConds( array( 'langlinks' => array( 'LEFT JOIN', 'page_id=ll_from' ) ) );
$this->addWhere( 'll_from IS NULL' );
$forceNameTitleIndex = false;
- } else if ( $params['filterlanglinks'] == 'withlanglinks' ) {
+ } elseif ( $params['filterlanglinks'] == 'withlanglinks' ) {
$this->addTables( 'langlinks' );
$this->addWhere( 'page_id=ll_from' );
$this->addOption( 'STRAIGHT_JOIN' );
@@ -135,8 +140,9 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
$forceNameTitleIndex = false;
}
- if ( $forceNameTitleIndex )
+ if ( $forceNameTitleIndex ) {
$this->addOption( 'USE INDEX', 'name_title' );
+ }
$limit = $params['limit'];
$this->addOption( 'LIMIT', $limit + 1 );
@@ -153,14 +159,14 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
}
if ( is_null( $resultPageSet ) ) {
- $title = Title :: makeTitle( $row->page_namespace, $row->page_title );
+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
$vals = array(
'pageid' => intval( $row->page_id ),
'ns' => intval( $title->getNamespace() ),
- 'title' => $title->getPrefixedText() );
+ 'title' => $title->getPrefixedText()
+ );
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'from', $this->keyToTitle( $row->page_title ) );
break;
}
@@ -178,70 +184,70 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
public function getAllowedParams() {
global $wgRestrictionTypes, $wgRestrictionLevels;
- return array (
+ return array(
'from' => null,
'prefix' => null,
- 'namespace' => array (
- ApiBase :: PARAM_DFLT => 0,
- ApiBase :: PARAM_TYPE => 'namespace',
+ 'namespace' => array(
+ ApiBase::PARAM_DFLT => 0,
+ ApiBase::PARAM_TYPE => 'namespace',
),
- 'filterredir' => array (
- ApiBase :: PARAM_DFLT => 'all',
- ApiBase :: PARAM_TYPE => array (
+ 'filterredir' => array(
+ ApiBase::PARAM_DFLT => 'all',
+ ApiBase::PARAM_TYPE => array(
'all',
'redirects',
'nonredirects'
)
),
- 'minsize' => array (
- ApiBase :: PARAM_TYPE => 'integer',
+ 'minsize' => array(
+ ApiBase::PARAM_TYPE => 'integer',
),
- 'maxsize' => array (
- ApiBase :: PARAM_TYPE => 'integer',
+ 'maxsize' => array(
+ ApiBase::PARAM_TYPE => 'integer',
),
- 'prtype' => array (
- ApiBase :: PARAM_TYPE => $wgRestrictionTypes,
- ApiBase :: PARAM_ISMULTI => true
+ 'prtype' => array(
+ ApiBase::PARAM_TYPE => $wgRestrictionTypes,
+ ApiBase::PARAM_ISMULTI => true
),
- 'prlevel' => array (
- ApiBase :: PARAM_TYPE => $wgRestrictionLevels,
- ApiBase :: PARAM_ISMULTI => true
+ 'prlevel' => array(
+ ApiBase::PARAM_TYPE => $wgRestrictionLevels,
+ ApiBase::PARAM_ISMULTI => true
),
- 'prfiltercascade' => array (
- ApiBase :: PARAM_DFLT => 'all',
- ApiBase :: PARAM_TYPE => array (
+ 'prfiltercascade' => array(
+ ApiBase::PARAM_DFLT => 'all',
+ ApiBase::PARAM_TYPE => array(
'cascading',
'noncascading',
'all'
),
),
- 'limit' => array (
- ApiBase :: PARAM_DFLT => 10,
- ApiBase :: PARAM_TYPE => 'limit',
- ApiBase :: PARAM_MIN => 1,
- ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
- ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+ 'limit' => array(
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
- 'dir' => array (
- ApiBase :: PARAM_DFLT => 'ascending',
- ApiBase :: PARAM_TYPE => array (
+ 'dir' => array(
+ ApiBase::PARAM_DFLT => 'ascending',
+ ApiBase::PARAM_TYPE => array(
'ascending',
'descending'
)
),
'filterlanglinks' => array(
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => array(
'withlanglinks',
'withoutlanglinks',
'all'
),
- ApiBase :: PARAM_DFLT => 'all'
+ ApiBase::PARAM_DFLT => 'all'
)
);
}
public function getParamDescription() {
- return array (
+ return array(
'from' => 'The page title to start enumerating from.',
'prefix' => 'Search for all page titles that begin with this value.',
'namespace' => 'The namespace to enumerate.',
@@ -260,7 +266,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
public function getDescription() {
return 'Enumerate all pages sequentially in a given namespace';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'params', 'info' => 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator' ),
@@ -269,7 +275,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
}
protected function getExamples() {
- return array (
+ return array(
'Simple Use',
' Show a list of pages starting at the letter "B"',
' api.php?action=query&list=allpages&apfrom=B',