<?php
-/*
+/**
* Created on Sep 10, 2007
*
* API for MediaWiki 1.8+
*
- * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( 'ApiQueryBase.php' );
+ require_once( 'ApiQueryBase.php' );
}
/**
* @ingroup API
*/
class ApiQueryBlocks extends ApiQueryBase {
-
+
var $users;
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'bk' );
+ parent::__construct( $query, $moduleName, 'bk' );
}
public function execute() {
global $wgUser;
$params = $this->extractRequestParams();
- if ( isset( $params['users'] ) && isset( $params['ip'] ) )
+ if ( isset( $params['users'] ) && isset( $params['ip'] ) ) {
$this->dieUsage( 'bkusers and bkip cannot be used together', 'usersandip' );
+ }
$prop = array_flip( $params['prop'] );
$fld_id = isset( $prop['id'] );
$this->addTables( 'ipblocks' );
$this->addFields( 'ipb_auto' );
- if ( $fld_id )
+ if ( $fld_id ) {
$this->addFields( 'ipb_id' );
- if ( $fld_user )
+ }
+ if ( $fld_user ) {
$this->addFields( array( 'ipb_address', 'ipb_user' ) );
- if ( $fld_by )
- {
+ }
+ if ( $fld_by ) {
$this->addTables( 'user' );
$this->addFields( array( 'ipb_by', 'user_name' ) );
$this->addWhere( 'user_id = ipb_by' );
}
- if ( $fld_timestamp )
+ if ( $fld_timestamp ) {
$this->addFields( 'ipb_timestamp' );
- if ( $fld_expiry )
+ }
+ if ( $fld_expiry ) {
$this->addFields( 'ipb_expiry' );
- if ( $fld_reason )
+ }
+ if ( $fld_reason ) {
$this->addFields( 'ipb_reason' );
- if ( $fld_range )
+ }
+ if ( $fld_range ) {
$this->addFields( array( 'ipb_range_start', 'ipb_range_end' ) );
- if ( $fld_flags )
+ }
+ if ( $fld_flags ) {
$this->addFields( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ) );
+ }
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$this->addWhereRange( 'ipb_timestamp', $params['dir'], $params['start'], $params['end'] );
- if ( isset( $params['ids'] ) )
+ if ( isset( $params['ids'] ) ) {
$this->addWhereFld( 'ipb_id', $params['ids'] );
- if ( isset( $params['users'] ) )
- {
- foreach ( (array)$params['users'] as $u )
+ }
+ if ( isset( $params['users'] ) ) {
+ foreach ( (array)$params['users'] as $u ) {
$this->prepareUsername( $u );
+ }
$this->addWhereFld( 'ipb_address', $this->usernames );
$this->addWhereFld( 'ipb_auto', 0 );
}
- if ( isset( $params['ip'] ) )
- {
+ if ( isset( $params['ip'] ) ) {
list( $ip, $range ) = IP::parseCIDR( $params['ip'] );
- if ( $ip && $range )
- {
+ if ( $ip && $range ) {
// We got a CIDR range
if ( $range < 16 )
$this->dieUsage( 'CIDR ranges broader than /16 are not accepted', 'cidrtoobroad' );
$lower = wfBaseConvert( $ip, 10, 16, 8, false );
$upper = wfBaseConvert( $ip + pow( 2, 32 - $range ) - 1, 10, 16, 8, false );
- }
- else
+ } else {
$lower = $upper = IP::toHex( $params['ip'] );
+ }
$prefix = substr( $lower, 0, 4 );
-
+
$db = $this->getDB();
$this->addWhere( array(
'ipb_range_start' . $db->buildLike( $prefix, $db->anyString() ),
'ipb_auto' => 0
) );
}
- if ( !$wgUser->isAllowed( 'hideuser' ) )
+ if ( !$wgUser->isAllowed( 'hideuser' ) ) {
$this->addWhereFld( 'ipb_deleted', 0 );
+ }
// Purge expired entries on one in every 10 queries
- if ( !mt_rand( 0, 10 ) )
+ if ( !mt_rand( 0, 10 ) ) {
Block::purgeExpired();
+ }
$res = $this->select( __METHOD__ );
$count = 0;
- while ( $row = $res->fetchObject() )
- {
- if ( ++$count > $params['limit'] )
- {
+ while ( $row = $res->fetchObject() ) {
+ if ( ++$count > $params['limit'] ) {
// We've had enough
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ipb_timestamp ) );
break;
}
$block = array();
- if ( $fld_id )
+ if ( $fld_id ) {
$block['id'] = $row->ipb_id;
- if ( $fld_user && !$row->ipb_auto )
+ }
+ if ( $fld_user && !$row->ipb_auto ) {
$block['user'] = $row->ipb_address;
- if ( $fld_by )
+ }
+ if ( $fld_by ) {
$block['by'] = $row->user_name;
- if ( $fld_timestamp )
+ }
+ if ( $fld_timestamp ) {
$block['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
- if ( $fld_expiry )
+ }
+ if ( $fld_expiry ) {
$block['expiry'] = Block::decodeExpiry( $row->ipb_expiry, TS_ISO_8601 );
- if ( $fld_reason )
+ }
+ if ( $fld_reason ) {
$block['reason'] = $row->ipb_reason;
- if ( $fld_range && !$row->ipb_auto )
- {
+ }
+ if ( $fld_range && !$row->ipb_auto ) {
$block['rangestart'] = IP::hexToQuad( $row->ipb_range_start );
$block['rangeend'] = IP::hexToQuad( $row->ipb_range_end );
}
- if ( $fld_flags )
- {
+ if ( $fld_flags ) {
// For clarity, these flags use the same names as their action=block counterparts
- if ( $row->ipb_auto )
+ if ( $row->ipb_auto ) {
$block['automatic'] = '';
- if ( $row->ipb_anon_only )
+ }
+ if ( $row->ipb_anon_only ) {
$block['anononly'] = '';
- if ( $row->ipb_create_account )
+ }
+ if ( $row->ipb_create_account ) {
$block['nocreate'] = '';
- if ( $row->ipb_enable_autoblock )
+ }
+ if ( $row->ipb_enable_autoblock ) {
$block['autoblock'] = '';
- if ( $row->ipb_block_email )
+ }
+ if ( $row->ipb_block_email ) {
$block['noemail'] = '';
- if ( $row->ipb_deleted )
+ }
+ if ( $row->ipb_deleted ) {
$block['hidden'] = '';
- if ( $row->ipb_allow_usertalk )
+ }
+ if ( $row->ipb_allow_usertalk ) {
$block['allowusertalk'] = '';
+ }
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $block );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ipb_timestamp ) );
break;
}
}
$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'block' );
}
-
- protected function prepareUsername( $user )
- {
- if ( !$user )
+
+ protected function prepareUsername( $user ) {
+ if ( !$user ) {
$this->dieUsage( 'User parameter may not be empty', 'param_user' );
+ }
$name = User::isIP( $user )
? $user
: User::getCanonicalName( $user, 'valid' );
- if ( $name === false )
+ if ( $name === false ) {
$this->dieUsage( "User name {$user} is not valid", 'param_user' );
+ }
$this->usernames[] = $name;
}
public function getAllowedParams() {
- return array (
+ return array(
'start' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'end' => array(
- ApiBase :: PARAM_TYPE => 'timestamp',
+ ApiBase::PARAM_TYPE => 'timestamp',
),
'dir' => array(
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => array(
'newer',
'older'
),
- ApiBase :: PARAM_DFLT => 'older'
+ ApiBase::PARAM_DFLT => 'older'
),
'ids' => array(
- ApiBase :: PARAM_TYPE => 'integer',
- ApiBase :: PARAM_ISMULTI => true
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_ISMULTI => true
),
'users' => array(
- ApiBase :: PARAM_ISMULTI => true
+ ApiBase::PARAM_ISMULTI => true
),
'ip' => null,
'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
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'prop' => array(
- ApiBase :: PARAM_DFLT => 'id|user|by|timestamp|expiry|reason|flags',
- ApiBase :: PARAM_TYPE => array(
- 'id',
- 'user',
- 'by',
- 'timestamp',
- 'expiry',
- 'reason',
- 'range',
- 'flags'
- ),
- ApiBase :: PARAM_ISMULTI => true
+ ApiBase::PARAM_DFLT => 'id|user|by|timestamp|expiry|reason|flags',
+ ApiBase::PARAM_TYPE => array(
+ 'id',
+ 'user',
+ 'by',
+ 'timestamp',
+ 'expiry',
+ 'reason',
+ 'range',
+ 'flags'
+ ),
+ ApiBase::PARAM_ISMULTI => true
)
);
}
public function getParamDescription() {
- return array (
+ return array(
'start' => 'The timestamp to start enumerating from',
'end' => 'The timestamp to stop enumerating at',
'dir' => 'The direction in which to enumerate',
public function getDescription() {
return 'List all blocked users and IP addresses.';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'usersandip', 'info' => 'bkusers and bkip cannot be used together' ),
}
protected function getExamples() {
- return array ( 'api.php?action=query&list=blocks',
- 'api.php?action=query&list=blocks&bkusers=Alice|Bob'
+ return array(
+ 'api.php?action=query&list=blocks',
+ 'api.php?action=query&list=blocks&bkusers=Alice|Bob'
);
}
<?php
-/*
+/**
* Created on May 13, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiQueryBase.php" );
+ require_once( "ApiQueryBase.php" );
}
/**
class ApiQueryCategories extends ApiQueryGeneratorBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'cl' );
+ parent::__construct( $query, $moduleName, 'cl' );
}
public function execute() {
}
private function run( $resultPageSet = null ) {
-
- if ( $this->getPageSet()->getGoodTitleCount() == 0 )
+ if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
return; // nothing to do
+ }
$params = $this->extractRequestParams();
$prop = array_flip( (array)$params['prop'] );
$show = array_flip( (array)$params['show'] );
- $this->addFields( array (
+ $this->addFields( array(
'cl_from',
'cl_to'
) );
$this->addTables( 'categorylinks' );
$this->addWhereFld( 'cl_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
- if ( !is_null( $params['categories'] ) )
- {
+ if ( !is_null( $params['categories'] ) ) {
$cats = array();
- foreach ( $params['categories'] as $cat )
- {
+ foreach ( $params['categories'] as $cat ) {
$title = Title::newFromText( $cat );
- if ( !$title || $title->getNamespace() != NS_CATEGORY )
+ if ( !$title || $title->getNamespace() != NS_CATEGORY ) {
$this->setWarning( "``$cat'' is not a category" );
- else
+ } else {
$cats[] = $title->getDBkey();
+ }
}
$this->addWhereFld( 'cl_to', $cats );
}
if ( !is_null( $params['continue'] ) ) {
$cont = explode( '|', $params['continue'] );
- if ( count( $cont ) != 2 )
+ if ( count( $cont ) != 2 ) {
$this->dieUsage( "Invalid continue param. You should pass the " .
"original value returned by the previous query", "_badcontinue" );
+ }
$clfrom = intval( $cont[0] );
$clto = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
- $this->addWhere( "cl_from > $clfrom OR " .
- "(cl_from = $clfrom AND " .
- "cl_to >= '$clto')" );
+ $this->addWhere(
+ "cl_from > $clfrom OR " .
+ "(cl_from = $clfrom AND " .
+ "cl_to >= '$clto')"
+ );
}
- if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) )
+ if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) ) {
$this->dieUsageMsg( array( 'show' ) );
+ }
if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) )
{
$this->addOption( 'STRAIGHT_JOIN' );
'pp_page=page_id',
'pp_propname' => 'hiddencat' ) )
) );
- if ( isset( $show['hidden'] ) )
+ if ( isset( $show['hidden'] ) ) {
$this->addWhere( array( 'pp_propname IS NOT NULL' ) );
- else if ( isset( $show['!hidden'] ) )
+ } elseif ( isset( $show['!hidden'] ) ) {
$this->addWhere( array( 'pp_propname IS NULL' ) );
+ }
}
$this->addOption( 'USE INDEX', array( 'categorylinks' => 'cl_from' ) );
// Don't order by cl_from if it's constant in the WHERE clause
- if ( count( $this->getPageSet()->getGoodTitles() ) == 1 )
+ if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) {
$this->addOption( 'ORDER BY', 'cl_to' );
- else
+ } else {
$this->addOption( 'ORDER BY', "cl_from, cl_to" );
+ }
$db = $this->getDB();
$res = $this->select( __METHOD__ );
if ( is_null( $resultPageSet ) ) {
-
$count = 0;
while ( $row = $db->fetchObject( $res ) ) {
if ( ++$count > $params['limit'] ) {
break;
}
- $title = Title :: makeTitle( NS_CATEGORY, $row->cl_to );
+ $title = Title::makeTitle( NS_CATEGORY, $row->cl_to );
$vals = array();
- ApiQueryBase :: addTitleInfo( $vals, $title );
- if ( isset( $prop['sortkey'] ) )
+ ApiQueryBase::addTitleInfo( $vals, $title );
+ if ( isset( $prop['sortkey'] ) ) {
$vals['sortkey'] = $row->cl_sortkey;
- if ( isset( $prop['timestamp'] ) )
+ }
+ if ( isset( $prop['timestamp'] ) ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
- if ( isset( $prop['hidden'] ) && !is_null( $row->pp_propname ) )
+ }
+ if ( isset( $prop['hidden'] ) && !is_null( $row->pp_propname ) ) {
$vals['hidden'] = '';
+ }
$fit = $this->addPageSubItem( $row->cl_from, $vals );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->cl_from .
'|' . $this->keyToTitle( $row->cl_to ) );
break;
}
}
} else {
-
$titles = array();
while ( $row = $db->fetchObject( $res ) ) {
if ( ++$count > $params['limit'] ) {
}
public function getAllowedParams() {
- return array (
- 'prop' => array (
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_TYPE => array (
+ return array(
+ 'prop' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => array (
'sortkey',
'timestamp',
'hidden',
)
),
'show' => array(
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => array(
'hidden',
'!hidden',
)
),
'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
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'continue' => null,
'categories' => array(
- ApiBase :: PARAM_ISMULTI => true,
+ ApiBase::PARAM_ISMULTI => true,
),
);
}
public function getParamDescription() {
- return array (
+ return array(
'prop' => 'Which additional properties to get for each category.',
'limit' => 'How many categories to return',
'show' => 'Which kind of categories to show',
}
protected function getExamples() {
- return array (
- "Get a list of categories [[Albert Einstein]] belongs to:",
- " api.php?action=query&prop=categories&titles=Albert%20Einstein",
- "Get information about all categories used in the [[Albert Einstein]]:",
- " api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info"
- );
+ return array(
+ 'Get a list of categories [[Albert Einstein]] belongs to:',
+ ' api.php?action=query&prop=categories&titles=Albert%20Einstein',
+ 'Get information about all categories used in the [[Albert Einstein]]:',
+ ' api.php?action=query&generator=categories&titles=Albert%20Einstein&prop=info'
+ );
}
public function getVersion() {
<?php
-/*
+/**
* Created on May 13, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiQueryBase.php" );
+ require_once( "ApiQueryBase.php" );
}
/**
class ApiQueryCategoryInfo extends ApiQueryBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'ci' );
+ parent::__construct( $query, $moduleName, 'ci' );
}
public function execute() {
$titles = $this->getPageSet()->getGoodTitles() +
$this->getPageSet()->getMissingTitles();
$cattitles = array();
- foreach ( $categories as $c )
- {
+ foreach ( $categories as $c ) {
$t = $titles[$c];
$cattitles[$c] = $t->getDBkey();
}
$this->addFields( array( 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'pp_propname AS cat_hidden' ) );
$this->addWhere( array( 'cat_title' => $cattitles ) );
- if ( !is_null( $params['continue'] ) )
- {
+ if ( !is_null( $params['continue'] ) ) {
$title = $this->getDB()->addQuotes( $params['continue'] );
$this->addWhere( "cat_title >= $title" );
}
$res = $this->select( __METHOD__ );
$catids = array_flip( $cattitles );
- while ( $row = $db->fetchObject( $res ) )
- {
+ while ( $row = $db->fetchObject( $res ) ) {
$vals = array();
$vals['size'] = intval( $row->cat_pages );
$vals['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files;
$vals['files'] = intval( $row->cat_files );
$vals['subcats'] = intval( $row->cat_subcats );
- if ( $row->cat_hidden )
+ if ( $row->cat_hidden ) {
$vals['hidden'] = '';
+ }
$fit = $this->addPageSubItems( $catids[$row->cat_title], $vals );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'continue', $row->cat_title );
break;
}
}
public function getAllowedParams() {
- return array (
+ return array(
'continue' => null,
);
}
public function getParamDescription() {
- return array (
+ return array(
'continue' => 'When more results are available, use this to continue',
);
}
}
protected function getExamples() {
- return "api.php?action=query&prop=categoryinfo&titles=Category:Foo|Category:Bar";
+ return 'api.php?action=query&prop=categoryinfo&titles=Category:Foo|Category:Bar';
}
public function getVersion() {
<?php
-/*
+/**
* Created on June 14, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiQueryBase.php" );
+ require_once( "ApiQueryBase.php" );
}
/**
class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'cm' );
+ parent::__construct( $query, $moduleName, 'cm' );
}
public function execute() {
}
private function run( $resultPageSet = null ) {
-
$params = $this->extractRequestParams();
- if ( !isset( $params['title'] ) || is_null( $params['title'] ) )
- $this->dieUsage( "The cmtitle parameter is required", 'notitle' );
+ if ( !isset( $params['title'] ) || is_null( $params['title'] ) ) {
+ $this->dieUsage( 'The cmtitle parameter is required', 'notitle' );
+ }
$categoryTitle = Title::newFromText( $params['title'] );
- if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY )
- $this->dieUsage( "The category name you entered is not valid", 'invalidcategory' );
+ if ( is_null( $categoryTitle ) || $categoryTitle->getNamespace() != NS_CATEGORY ) {
+ $this->dieUsage( 'The category name you entered is not valid', 'invalidcategory' );
+ }
$prop = array_flip( $params['prop'] );
$fld_ids = isset( $prop['ids'] );
$this->addFieldsIf( 'cl_timestamp', $fld_timestamp || $params['sort'] == 'timestamp' );
$this->addTables( array( 'page', 'categorylinks' ) ); // must be in this order for 'USE INDEX'
// Not needed after bug 10280 is applied to servers
- if ( $params['sort'] == 'timestamp' )
+ if ( $params['sort'] == 'timestamp' ) {
$this->addOption( 'USE INDEX', 'cl_timestamp' );
- else
+ } else {
$this->addOption( 'USE INDEX', 'cl_sortkey' );
+ }
$this->addWhere( 'cl_from=page_id' );
$this->setContinuation( $params['continue'], $params['dir'] );
$this->addWhereFld( 'cl_to', $categoryTitle->getDBkey() );
- // Scanning large datasets for rare categories sucks, and I already told
+ // Scanning large datasets for rare categories sucks, and I already told
// how to have efficient subcategory access :-) ~~~~ (oh well, domas)
global $wgMiserMode;
$miser_ns = array();
} else {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
- if ( $params['sort'] == 'timestamp' )
+ if ( $params['sort'] == 'timestamp' ) {
$this->addWhereRange( 'cl_timestamp', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['start'], $params['end'] );
- else
- {
+ } else {
$this->addWhereRange( 'cl_sortkey', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), $params['startsortkey'], $params['endsortkey'] );
$this->addWhereRange( 'cl_from', ( $params['dir'] == 'asc' ? 'newer' : 'older' ), null, null );
}
$db = $this->getDB();
- $data = array ();
+ $data = array();
$count = 0;
$lastSortKey = null;
$res = $this->select( __METHOD__ );
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
// TODO: Security issue - if the user has no right to view next title, it will still be shown
- if ( $params['sort'] == 'timestamp' )
+ if ( $params['sort'] == 'timestamp' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
- else
+ } else {
$this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
+ }
break;
}
- // Since domas won't tell anyone what he told long ago, apply
- // cmnamespace here. This means the query may return 0 actual
- // results, but on the other hand it could save returning 5000
+ // Since domas won't tell anyone what he told long ago, apply
+ // cmnamespace here. This means the query may return 0 actual
+ // results, but on the other hand it could save returning 5000
// useless results to the client. ~~~~
- if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) )
+ if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
continue;
+ }
if ( is_null( $resultPageSet ) ) {
$vals = array();
- if ( $fld_ids )
+ if ( $fld_ids ) {
$vals['pageid'] = intval( $row->page_id );
+ }
if ( $fld_title ) {
- $title = Title :: makeTitle( $row->page_namespace, $row->page_title );
+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
ApiQueryBase::addTitleInfo( $vals, $title );
}
- if ( $fld_sortkey )
+ if ( $fld_sortkey ) {
$vals['sortkey'] = $row->cl_sortkey;
- if ( $fld_timestamp )
+ }
+ if ( $fld_timestamp ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cl_timestamp );
+ }
$fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ),
null, $vals );
- if ( !$fit )
- {
- if ( $params['sort'] == 'timestamp' )
+ if ( !$fit ) {
+ if ( $params['sort'] == 'timestamp' ) {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) );
- else
+ } else {
$this->setContinueEnumParameter( 'continue', $this->getContinueStr( $row, $lastSortKey ) );
+ }
break;
}
} else {
$resultPageSet->processDbRow( $row );
}
- $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys
+ $lastSortKey = $row->cl_sortkey; // detect duplicate sortkeys
}
$db->freeResult( $res );
private function getContinueStr( $row, $lastSortKey ) {
$ret = $row->cl_sortkey . '|';
- if ( $row->cl_sortkey == $lastSortKey ) // duplicate sort key, add cl_from
+ if ( $row->cl_sortkey == $lastSortKey ) { // duplicate sort key, add cl_from
$ret .= $row->cl_from;
+ }
return $ret;
}
* Add DB WHERE clause to continue previous query based on 'continue' parameter
*/
private function setContinuation( $continue, $dir ) {
- if ( is_null( $continue ) )
+ if ( is_null( $continue ) ) {
return; // This is not a continuation request
+ }
$pos = strrpos( $continue, '|' );
$sortkey = substr( $continue, 0, $pos );
$fromstr = substr( $continue, $pos + 1 );
$from = intval( $fromstr );
- if ( $from == 0 && strlen( $fromstr ) > 0 )
- $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "badcontinue" );
+ if ( $from == 0 && strlen( $fromstr ) > 0 ) {
+ $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
+ }
$encSortKey = $this->getDB()->addQuotes( $sortkey );
$encFrom = $this->getDB()->addQuotes( $from );
-
+
$op = ( $dir == 'desc' ? '<' : '>' );
if ( $from != 0 ) {
}
public function getAllowedParams() {
- return array (
+ return array(
'title' => null,
- 'prop' => array (
- ApiBase :: PARAM_DFLT => 'ids|title',
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_TYPE => array (
+ 'prop' => array(
+ ApiBase::PARAM_DFLT => 'ids|title',
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => array (
'ids',
'title',
'sortkey',
)
),
'namespace' => array (
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_TYPE => 'namespace',
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => 'namespace',
),
'continue' => null,
- 'limit' => array (
- ApiBase :: PARAM_TYPE => 'limit',
- ApiBase :: PARAM_DFLT => 10,
- ApiBase :: PARAM_MIN => 1,
- ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
- ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+ 'limit' => array(
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'sort' => array(
- ApiBase :: PARAM_DFLT => 'sortkey',
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_DFLT => 'sortkey',
+ ApiBase::PARAM_TYPE => array(
'sortkey',
'timestamp'
)
),
'dir' => array(
- ApiBase :: PARAM_DFLT => 'asc',
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_DFLT => 'asc',
+ ApiBase::PARAM_TYPE => array(
'asc',
'desc'
)
),
'start' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'end' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'startsortkey' => null,
'endsortkey' => null,
public function getParamDescription() {
global $wgMiserMode;
- $desc = array (
+ $desc = array(
'title' => 'Which category to enumerate (required). Must include Category: prefix',
'prop' => 'What pieces of information to include',
'namespace' => 'Only include pages in these namespaces',
public function getDescription() {
return 'List all pages in a given category';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'notitle', 'info' => 'The cmtitle parameter is required' ),
}
protected function getExamples() {
- return array (
- "Get first 10 pages in [[Category:Physics]]:",
- " api.php?action=query&list=categorymembers&cmtitle=Category:Physics",
- "Get page info about first 10 pages in [[Category:Physics]]:",
- " api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info",
- );
+ return array(
+ 'Get first 10 pages in [[Category:Physics]]:',
+ ' api.php?action=query&list=categorymembers&cmtitle=Category:Physics',
+ 'Get page info about first 10 pages in [[Category:Physics]]:',
+ ' api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info',
+ );
}
public function getVersion() {
<?php
-/*
+/**
* Created on Jul 2, 2007
*
* API for MediaWiki 1.8+
*
- * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( 'ApiQueryBase.php' );
+ require_once( 'ApiQueryBase.php' );
}
/**
class ApiQueryDeletedrevs extends ApiQueryBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'dr' );
+ parent::__construct( $query, $moduleName, 'dr' );
}
public function execute() {
-
global $wgUser;
// Before doing anything at all, let's check permissions
- if ( !$wgUser->isAllowed( 'deletedhistory' ) )
+ if ( !$wgUser->isAllowed( 'deletedhistory' ) ) {
$this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' );
+ }
$db = $this->getDB();
$params = $this->extractRequestParams( false );
$fld_len = isset( $prop['len'] );
$fld_content = isset( $prop['content'] );
$fld_token = isset( $prop['token'] );
-
+
$result = $this->getResult();
$pageSet = $this->getPageSet();
$titles = $pageSet->getTitles();
$data = array();
-
+
// This module operates in three modes:
// 'revs': List deleted revs for certain titles
// 'user': List deleted revs by a certain user
// 'all': List all deleted revs
$mode = 'all';
- if ( count( $titles ) > 0 )
+ if ( count( $titles ) > 0 ) {
$mode = 'revs';
- else if ( !is_null( $params['user'] ) )
+ } elseif ( !is_null( $params['user'] ) ) {
$mode = 'user';
-
- if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) )
+ }
+
+ if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
$this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
+ }
$this->addTables( 'archive' );
$this->addWhere( 'ar_deleted = 0' );
$this->addFields( array( 'ar_title', 'ar_namespace', 'ar_timestamp' ) );
- if ( $fld_revid )
+ if ( $fld_revid ) {
$this->addFields( 'ar_rev_id' );
- if ( $fld_user )
+ }
+ if ( $fld_user ) {
$this->addFields( 'ar_user_text' );
- if ( $fld_comment || $fld_parsedcomment )
+ }
+ if ( $fld_comment || $fld_parsedcomment ) {
$this->addFields( 'ar_comment' );
- if ( $fld_minor )
+ }
+ if ( $fld_minor ) {
$this->addFields( 'ar_minor_edit' );
- if ( $fld_len )
+ }
+ if ( $fld_len ) {
$this->addFields( 'ar_len' );
+ }
if ( $fld_content ) {
$this->addTables( 'text' );
$this->addFields( array( 'ar_text', 'ar_text_id', 'old_text', 'old_flags' ) );
$this->addWhere( 'ar_text_id = old_id' );
// This also means stricter restrictions
- if ( !$wgUser->isAllowed( 'undelete' ) )
+ if ( !$wgUser->isAllowed( 'undelete' ) ) {
$this->dieUsage( 'You don\'t have permission to view deleted revision content', 'permissiondenied' );
+ }
}
// Check limits
- $userMax = $fld_content ? ApiBase :: LIMIT_SML1 : ApiBase :: LIMIT_BIG1;
- $botMax = $fld_content ? ApiBase :: LIMIT_SML2 : ApiBase :: LIMIT_BIG2;
+ $userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
+ $botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
$limit = $params['limit'];
$this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
- if ( $fld_token )
+ if ( $fld_token ) {
// Undelete tokens are identical for all pages, so we cache one here
$token = $wgUser->editToken();
+ }
// We need a custom WHERE clause that matches all titles.
if ( $mode == 'revs' ) {
$this->addWhere( $where );
} elseif ( $mode == 'all' ) {
$this->addWhereFld( 'ar_namespace', $params['namespace'] );
- if ( !is_null( $params['from'] ) )
- {
+ if ( !is_null( $params['from'] ) ) {
$from = $this->getDB()->strencode( $this->titleToKey( $params['from'] ) );
$this->addWhere( "ar_title >= '$from'" );
}
}
-
+
if ( !is_null( $params['user'] ) ) {
$this->addWhereFld( 'ar_user_text', $params['user'] );
} elseif ( !is_null( $params['excludeuser'] ) ) {
$this->addWhere( 'ar_user_text != ' .
$this->getDB()->addQuotes( $params['excludeuser'] ) );
}
-
+
if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) )
{
$cont = explode( '|', $params['continue'] );
- if ( count( $cont ) != 3 )
- $this->dieUsage( "Invalid continue param. You should pass the original value returned by the previous query", "badcontinue" );
+ if ( count( $cont ) != 3 ) {
+ $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
+ }
$ns = intval( $cont[0] );
$title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
$ts = $this->getDB()->strencode( $cont[2] );
$this->addOption( 'LIMIT', $limit + 1 );
$this->addOption( 'USE INDEX', array( 'archive' => ( $mode == 'user' ? 'usertext_timestamp' : 'name_title_timestamp' ) ) );
if ( $mode == 'all' ) {
- if ( $params['unique'] )
- {
+ if ( $params['unique'] ) {
$this->addOption( 'GROUP BY', 'ar_title' );
$this->addOption( 'ORDER BY', 'ar_title' );
- } else
+ } else {
$this->addOption( 'ORDER BY', 'ar_title, ar_timestamp' );
+ }
} else {
- if ( $mode == 'revs' )
- {
+ if ( $mode == 'revs' ) {
// Sort by ns and title in the same order as timestamp for efficiency
$this->addWhereRange( 'ar_namespace', $params['dir'], null, null );
$this->addWhereRange( 'ar_title', $params['dir'], null, null );
$pageMap = array(); // Maps ns&title to (fake) pageid
$count = 0;
$newPageID = 0;
- while ( $row = $db->fetchObject( $res ) )
- {
+ while ( $row = $db->fetchObject( $res ) ) {
if ( ++$count > $limit ) {
// We've had enough
- if ( $mode == 'all' || $mode == 'revs' )
+ if ( $mode == 'all' || $mode == 'revs' ) {
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
- else
+ } else {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
+ }
break;
}
$rev = array();
$rev['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ar_timestamp );
- if ( $fld_revid )
+ if ( $fld_revid ) {
$rev['revid'] = intval( $row->ar_rev_id );
- if ( $fld_user )
+ }
+ if ( $fld_user ) {
$rev['user'] = $row->ar_user_text;
- if ( $fld_comment )
+ }
+ if ( $fld_comment ) {
$rev['comment'] = $row->ar_comment;
+ }
$title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
global $wgUser;
$rev['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->ar_comment, $title );
}
- if ( $fld_minor && $row->ar_minor_edit == 1 )
+ if ( $fld_minor && $row->ar_minor_edit == 1 ) {
$rev['minor'] = '';
- if ( $fld_len )
+ }
+ if ( $fld_len ) {
$rev['len'] = $row->ar_len;
- if ( $fld_content )
+ }
+ if ( $fld_content ) {
ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
+ }
if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
$pageID = $newPageID++;
$a['revisions'] = array( $rev );
$result->setIndexedTagName( $a['revisions'], 'rev' );
ApiQueryBase::addTitleInfo( $a, $title );
- if ( $fld_token )
+ if ( $fld_token ) {
$a['token'] = $token;
+ }
$fit = $result->addValue( array( 'query', $this->getModuleName() ), $pageID, $a );
} else {
$pageID = $pageMap[$row->ar_namespace][$row->ar_title];
null, $rev );
}
if ( !$fit ) {
- if ( $mode == 'all' || $mode == 'revs' )
+ if ( $mode == 'all' || $mode == 'revs' ) {
$this->setContinueEnumParameter( 'continue', intval( $row->ar_namespace ) . '|' .
$this->keyToTitle( $row->ar_title ) . '|' . $row->ar_timestamp );
- else
+ } else {
$this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->ar_timestamp ) );
+ }
break;
}
}
}
public function getAllowedParams() {
- return array (
+ return array(
'start' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'end' => array(
- ApiBase :: PARAM_TYPE => 'timestamp',
+ ApiBase::PARAM_TYPE => 'timestamp',
),
'dir' => array(
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => array(
'newer',
'older'
),
- ApiBase :: PARAM_DFLT => 'older'
+ ApiBase::PARAM_DFLT => 'older'
),
'from' => null,
'continue' => null,
'unique' => false,
'user' => array(
- ApiBase :: PARAM_TYPE => 'user'
+ ApiBase::PARAM_TYPE => 'user'
),
'excludeuser' => array(
- ApiBase :: PARAM_TYPE => 'user'
+ ApiBase::PARAM_TYPE => 'user'
),
'namespace' => array(
- ApiBase :: PARAM_TYPE => 'namespace',
- ApiBase :: PARAM_DFLT => 0,
+ ApiBase::PARAM_TYPE => 'namespace',
+ ApiBase::PARAM_DFLT => 0,
),
'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
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'prop' => array(
- ApiBase :: PARAM_DFLT => 'user|comment',
- ApiBase :: PARAM_TYPE => array(
+ ApiBase::PARAM_DFLT => 'user|comment',
+ ApiBase::PARAM_TYPE => array(
'revid',
'user',
'comment',
'content',
'token'
),
- ApiBase :: PARAM_ISMULTI => true
+ ApiBase::PARAM_ISMULTI => true
),
);
}
public function getParamDescription() {
- return array (
+ return array(
'start' => 'The timestamp to start enumerating from. (1,2)',
'end' => 'The timestamp to stop enumerating at. (1,2)',
'dir' => 'The direction in which to enumerate. (1,2)',
}
public function getDescription() {
- return array( 'List deleted revisions.',
- 'This module operates in three modes:',
- '1) List deleted revisions for the given title(s), sorted by timestamp',
- '2) List deleted contributions for the given user, sorted by timestamp (no titles specified)',
- '3) List all deleted revisions in the given namespace, sorted by title and timestamp (no titles specified, druser not set)',
- 'Certain parameters only apply to some modes and are ignored in others.',
- 'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3.',
+ return array(
+ 'List deleted revisions.',
+ 'This module operates in three modes:',
+ '1) List deleted revisions for the given title(s), sorted by timestamp',
+ '2) List deleted contributions for the given user, sorted by timestamp (no titles specified)',
+ '3) List all deleted revisions in the given namespace, sorted by title and timestamp (no titles specified, druser not set)',
+ 'Certain parameters only apply to some modes and are ignored in others.',
+ 'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3.',
);
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revision information' ),
}
protected function getExamples() {
- return array (
+ return array(
'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1):',
' api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&drprop=user|comment|content',
'List the last 50 deleted contributions by Bob (mode 2):',
<?php
-/*
+/**
* Created on Sep 25, 2008
* API for MediaWiki 1.8+
*
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Copyright © 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiBase.php" );
+ require_once( "ApiBase.php" );
}
-
/**
- * API module that does nothing
+ * API module that does nothing
*
* Use this to disable core modules with e.g.
* $wgAPIPropModules['modulename'] = 'ApiQueryDisabled';
class ApiQueryDisabled extends ApiQueryBase {
public function __construct( $main, $action ) {
- parent :: __construct( $main, $action );
+ parent::__construct( $main, $action );
}
public function execute() {
}
public function getAllowedParams() {
- return array ();
+ return array();
}
public function getParamDescription() {
- return array ();
+ return array();
}
public function getDescription() {
}
protected function getExamples() {
- return array ();
+ return array();
}
public function getVersion() {
<?php
-/*
+/**
* Created on Sep 27, 2008
*
* API for MediaWiki 1.8+
*
- * Copyright (C) 2008 Roan Kattow <Firstname>,<Lastname>@home.nl
+ * Copyright © 2008 Roan Kattow <Firstname>,<Lastname>@home.nl
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiQueryBase.php" );
+ require_once( "ApiQueryBase.php" );
}
/**
class ApiQueryDuplicateFiles extends ApiQueryGeneratorBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'df' );
+ parent::__construct( $query, $moduleName, 'df' );
}
public function execute() {
return;
}
$images = $namespaces[NS_FILE];
-
+
$this->addTables( 'image', 'i1' );
$this->addTables( 'image', 'i2' );
$this->addFields( array(
'i1.img_name != i2.img_name',
) );
- if ( isset( $params['continue'] ) )
- {
+ if ( isset( $params['continue'] ) ) {
$cont = explode( '|', $params['continue'] );
- if ( count( $cont ) != 2 )
- $this->dieUsage( "Invalid continue param. You should pass the " .
- "original value returned by the previous query", "_badcontinue" );
+ if ( count( $cont ) != 2 ) {
+ $this->dieUsage( 'Invalid continue param. You should pass the ' .
+ 'original value returned by the previous query', '_badcontinue' );
+ }
$orig = $this->getDB()->strencode( $this->titleTokey( $cont[0] ) );
$dup = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
- $this->addWhere( "i1.img_name > '$orig' OR " .
- "(i1.img_name = '$orig' AND " .
- "i2.img_name >= '$dup')" );
+ $this->addWhere(
+ "i1.img_name > '$orig' OR " .
+ "(i1.img_name = '$orig' AND " .
+ "i2.img_name >= '$dup')"
+ );
}
$this->addOption( 'ORDER BY', 'i1.img_name' );
$db = $this->getDB();
$count = 0;
$titles = array();
- while ( $row = $db->fetchObject( $res ) )
- {
- if ( ++$count > $params['limit'] )
- {
+ while ( $row = $db->fetchObject( $res ) ) {
+ if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue',
$this->keyToTitle( $row->dup_name ) );
break;
}
- if ( !is_null( $resultPageSet ) )
+ if ( !is_null( $resultPageSet ) ) {
$titles[] = Title::makeTitle( NS_FILE, $row->dup_name );
- else
- {
+ } else {
$r = array(
'name' => $row->dup_name,
'user' => $row->dup_user_text,
'timestamp' => wfTimestamp( TS_ISO_8601, $row->dup_timestamp )
);
$fit = $this->addPageSubItem( $images[$row->orig_name], $r );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'continue',
$this->keyToTitle( $row->orig_name ) . '|' .
$this->keyToTitle( $row->dup_name ) );
}
}
}
- if ( !is_null( $resultPageSet ) )
+ if ( !is_null( $resultPageSet ) ) {
$resultPageSet->populateFromTitles( $titles );
+ }
$db->freeResult( $res );
}
public function getAllowedParams() {
- return array (
+ return array(
'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
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'continue' => null,
);
}
public function getParamDescription() {
- return array (
+ return array(
'limit' => 'How many files to return',
'continue' => 'When more results are available, use this to continue',
);
public function getDescription() {
return 'List all files that are duplicates of the given file(s).';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
}
protected function getExamples() {
- return array ( 'api.php?action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles',
- 'api.php?action=query&generator=allimages&prop=duplicatefiles',
- );
+ return array(
+ 'api.php?action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles',
+ 'api.php?action=query&generator=allimages&prop=duplicatefiles',
+ );
}
public function getVersion() {
<?php
-/*
+/**
* Created on July 7, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( 'ApiQueryBase.php' );
+ require_once( 'ApiQueryBase.php' );
}
/**
class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'eu' );
+ parent::__construct( $query, $moduleName, 'eu' );
}
public function execute() {
}
private function run( $resultPageSet = null ) {
-
$params = $this->extractRequestParams();
$protocol = $params['protocol'];
// Find the right prefix
global $wgUrlProtocols;
- if ( $protocol && !in_array( $protocol, $wgUrlProtocols ) )
- {
+ if ( $protocol && !in_array( $protocol, $wgUrlProtocols ) ) {
foreach ( $wgUrlProtocols as $p ) {
if ( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
$protocol = $p;
break;
}
}
- }
- else
+ } else {
$protocol = null;
+ }
$db = $this->getDB();
$this->addTables( array( 'page', 'externallinks' ) ); // must be in this order for 'USE INDEX'
$this->addWhere( 'page_id=el_from' );
$this->addWhereFld( 'page_namespace', $params['namespace'] );
- if ( !is_null( $query ) || $query != '' )
- {
- if ( is_null( $protocol ) )
+ if ( !is_null( $query ) || $query != '' ) {
+ if ( is_null( $protocol ) ) {
$protocol = 'http://';
+ }
$likeQuery = LinkFilter::makeLikeArray( $query, $protocol );
- if ( !$likeQuery )
+ if ( !$likeQuery ) {
$this->dieUsage( 'Invalid query', 'bad_query' );
+ }
$likeQuery = LinkFilter::keepOneWildcard( $likeQuery );
$this->addWhere( 'el_index ' . $db->buildLike( $likeQuery ) );
- }
- else if ( !is_null( $protocol ) )
+ } elseif ( !is_null( $protocol ) ) {
$this->addWhere( 'el_index ' . $db->buildLike( "$protocol", $db->anyString() ) );
+ }
$prop = array_flip( $params['prop'] );
$fld_ids = isset( $prop['ids'] );
$fld_url = isset( $prop['url'] );
if ( is_null( $resultPageSet ) ) {
- $this->addFields( array (
+ $this->addFields( array(
'page_id',
'page_namespace',
'page_title'
$limit = $params['limit'];
$offset = $params['offset'];
$this->addOption( 'LIMIT', $limit + 1 );
- if ( isset ( $offset ) )
+ if ( isset( $offset ) ) {
$this->addOption( 'OFFSET', $offset );
+ }
$res = $this->select( __METHOD__ );
if ( is_null( $resultPageSet ) ) {
$vals = array();
- if ( $fld_ids )
+ if ( $fld_ids ) {
$vals['pageid'] = intval( $row->page_id );
+ }
if ( $fld_title ) {
- $title = Title :: makeTitle( $row->page_namespace, $row->page_title );
+ $title = Title::makeTitle( $row->page_namespace, $row->page_title );
ApiQueryBase::addTitleInfo( $vals, $title );
}
- if ( $fld_url )
+ if ( $fld_url ) {
$vals['url'] = $row->el_to;
+ }
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $offset + $count - 1 );
break;
}
$protocols[] = substr( $p, 0, strpos( $p, ':' ) );
}
- return array (
- 'prop' => array (
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_DFLT => 'ids|title|url',
- ApiBase :: PARAM_TYPE => array (
+ return array(
+ 'prop' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_DFLT => 'ids|title|url',
+ ApiBase::PARAM_TYPE => array(
'ids',
'title',
'url'
)
),
- 'offset' => array (
- ApiBase :: PARAM_TYPE => 'integer'
+ 'offset' => array(
+ ApiBase::PARAM_TYPE => 'integer'
),
- 'protocol' => array (
- ApiBase :: PARAM_TYPE => $protocols,
- ApiBase :: PARAM_DFLT => '',
+ 'protocol' => array(
+ ApiBase::PARAM_TYPE => $protocols,
+ ApiBase::PARAM_DFLT => '',
),
'query' => null,
- 'namespace' => array (
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_TYPE => 'namespace'
+ 'namespace' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_TYPE => 'namespace'
),
- '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
)
);
}
public function getParamDescription() {
- return array (
+ return array(
'prop' => 'What pieces of information to include',
'offset' => 'Used for paging. Use the value returned for "continue"',
- 'protocol' => array( 'Protocol of the url. If empty and euquery set, the protocol is http.',
- 'Leave both this and euquery empty to list all external links' ),
+ 'protocol' => array(
+ 'Protocol of the url. If empty and euquery set, the protocol is http.',
+ 'Leave both this and euquery empty to list all external links'
+ ),
'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links',
'namespace' => 'The page namespace(s) to enumerate.',
'limit' => 'How many pages to return.'
public function getDescription() {
return 'Enumerate pages that contain a given URL';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'bad_query', 'info' => 'Invalid query' ),
}
protected function getExamples() {
- return array (
+ return array(
'api.php?action=query&list=exturlusage&euquery=www.mediawiki.org'
);
}
<?php
-/*
+/**
* Created on May 13, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( "ApiQueryBase.php" );
+ require_once( "ApiQueryBase.php" );
}
/**
class ApiQueryExternalLinks extends ApiQueryBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'el' );
+ parent::__construct( $query, $moduleName, 'el' );
}
public function execute() {
- if ( $this->getPageSet()->getGoodTitleCount() == 0 )
+ if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
return;
+ }
$params = $this->extractRequestParams();
- $this->addFields( array (
+ $this->addFields( array(
'el_from',
'el_to'
) );
$this->addWhereFld( 'el_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
// Don't order by el_from if it's constant in the WHERE clause
- if ( count( $this->getPageSet()->getGoodTitles() ) != 1 )
+ if ( count( $this->getPageSet()->getGoodTitles() ) != 1 ) {
$this->addOption( 'ORDER BY', 'el_from' );
+ }
$this->addOption( 'LIMIT', $params['limit'] + 1 );
- if ( !is_null( $params['offset'] ) )
+ if ( !is_null( $params['offset'] ) ) {
$this->addOption( 'OFFSET', $params['offset'] );
+ }
$db = $this->getDB();
$res = $this->select( __METHOD__ );
break;
}
$entry = array();
- ApiResult :: setContent( $entry, $row->el_to );
+ ApiResult::setContent( $entry, $row->el_to );
$fit = $this->addPageSubItem( $row->el_from, $entry );
- if ( !$fit )
- {
+ if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', @$params['offset'] + $count - 1 );
break;
}
public function getAllowedParams() {
return array(
- '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
- ),
- 'offset' => null,
+ '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
+ ),
+ 'offset' => null,
);
}
- public function getParamDescription () {
+ public function getParamDescription() {
return array(
'limit' => 'How many links to return',
'offset' => 'When more results are available, use this to continue',
}
protected function getExamples() {
- return array (
- "Get a list of external links on the [[Main Page]]:",
- " api.php?action=query&prop=extlinks&titles=Main%20Page",
- );
+ return array(
+ 'Get a list of external links on the [[Main Page]]:',
+ ' api.php?action=query&prop=extlinks&titles=Main%20Page',
+ );
}
public function getVersion() {
<?php
-/*
+/**
* Created on July 6, 2007
*
* 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
if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ( 'ApiQueryBase.php' );
+ require_once( 'ApiQueryBase.php' );
}
/**
class ApiQueryImageInfo extends ApiQueryBase {
public function __construct( $query, $moduleName ) {
- parent :: __construct( $query, $moduleName, 'ii' );
+ parent::__construct( $query, $moduleName, 'ii' );
}
public function execute() {
$prop = array_flip( $params['prop'] );
- if ( $params['urlheight'] != - 1 && $params['urlwidth'] == - 1 )
- $this->dieUsage( "iiurlheight cannot be used without iiurlwidth", 'iiurlwidth' );
-
+ if ( $params['urlheight'] != - 1 && $params['urlwidth'] == - 1 ) {
+ $this->dieUsage( 'iiurlheight cannot be used without iiurlwidth', 'iiurlwidth' );
+ }
+
if ( $params['urlwidth'] != - 1 ) {
$scale = array();
$scale['width'] = $params['urlwidth'];
asort( $titles ); // Ensure the order is always the same
$skip = false;
- if ( !is_null( $params['continue'] ) )
- {
+ if ( !is_null( $params['continue'] ) ) {
$skip = true;
$cont = explode( '|', $params['continue'] );
- if ( count( $cont ) != 2 )
- $this->dieUsage( "Invalid continue param. You should pass the original " .
- "value returned by the previous query", "_badcontinue" );
+ if ( count( $cont ) != 2 ) {
+ $this->dieUsage( 'Invalid continue param. You should pass the original ' .
+ 'value returned by the previous query', '_badcontinue' );
+ }
$fromTitle = strval( $cont[0] );
$fromTimestamp = $cont[1];
// Filter out any titles before $fromTitle
- foreach ( $titles as $key => $title )
- if ( $title < $fromTitle )
+ foreach ( $titles as $key => $title ) {
+ if ( $title < $fromTitle ) {
unset( $titles[$key] );
- else
+ } else {
break;
+ }
+ }
}
$result = $this->getResult();
$images = RepoGroup::singleton()->findFiles( $titles );
foreach ( $images as $img ) {
// Skip redirects
- if ( $img->getOriginalTitle()->isRedirect() )
+ if ( $img->getOriginalTitle()->isRedirect() ) {
continue;
-
+ }
+
$start = $skip ? $fromTimestamp : $params['start'];
$pageId = $pageIds[NS_IMAGE][ $img->getOriginalTitle()->getDBkey() ];
array( 'query', 'pages', intval( $pageId ) ),
'imagerepository', $img->getRepoName()
);
- if ( !$fit )
- {
- if ( count( $pageIds[NS_IMAGE] ) == 1 )
+ if ( !$fit ) {
+ if ( count( $pageIds[NS_IMAGE] ) == 1 ) {
// The user is screwed. imageinfo can't be solely
// responsible for exceeding the limit in this case,
// so set a query-continue that just returns the same
// out-continued, the result will get through
$this->setContinueEnumParameter( 'start',
wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
- else
+ } else {
$this->setContinueEnumParameter( 'continue',
$this->getContinueStr( $img ) );
+ }
break;
}
// Get information about the current version first
// Check that the current version is within the start-end boundaries
$gotOne = false;
- if ( ( is_null( $start ) || $img->getTimestamp() <= $start ) &&
- ( is_null( $params['end'] ) || $img->getTimestamp() >= $params['end'] ) ) {
+ if (
+ ( is_null( $start ) || $img->getTimestamp() <= $start ) &&
+ ( is_null( $params['end'] ) || $img->getTimestamp() >= $params['end'] )
+ )
+ {
$gotOne = true;
$fit = $this->addPageSubItem( $pageId,
self::getInfo( $img, $prop, $result, $scale ) );
- if ( !$fit )
- {
- if ( count( $pageIds[NS_IMAGE] ) == 1 )
+ if ( !$fit ) {
+ if ( count( $pageIds[NS_IMAGE] ) == 1 ) {
// See the 'the user is screwed' comment above
$this->setContinueEnumParameter( 'start',
wfTimestamp( TS_ISO_8601, $img->getTimestamp() ) );
- else
+ } else {
$this->setContinueEnumParameter( 'continue',
$this->getContinueStr( $img ) );
+ }
break;
}
}
if ( ++$count > $params['limit'] ) {
// We've reached the extra one which shows that there are additional pages to be had. Stop here...
// Only set a query-continue if there was only one title
- if ( count( $pageIds[NS_FILE] ) == 1 )
- {
+ if ( count( $pageIds[NS_FILE] ) == 1 ) {
$this->setContinueEnumParameter( 'start',
wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
}
}
$fit = $this->addPageSubItem( $pageId,
self::getInfo( $oldie, $prop, $result ) );
- if ( !$fit )
- {
- if ( count( $pageIds[NS_IMAGE] ) == 1 )
+ if ( !$fit ) {
+ if ( count( $pageIds[NS_IMAGE] ) == 1 ) {
$this->setContinueEnumParameter( 'start',
wfTimestamp( TS_ISO_8601, $oldie->getTimestamp() ) );
- else
+ } else {
$this->setContinueEnumParameter( 'continue',
$this->getContinueStr( $oldie ) );
+ }
break;
}
}
- if ( !$fit )
+ if ( !$fit ) {
break;
+ }
$skip = false;
}
-
+
$data = $this->getResultData();
foreach ( $data['query']['pages'] as $pageid => $arr ) {
- if ( !isset( $arr['imagerepository'] ) )
+ if ( !isset( $arr['imagerepository'] ) ) {
$result->addValue(
array( 'query', 'pages', $pageid ),
'imagerepository', ''
);
- // The above can't fail because it doesn't increase the result size
+ }
+ // The above can't fail because it doesn't increase the result size
}
}
}
*/
static function getInfo( $file, $prop, $result, $scale = null ) {
$vals = array();
- if ( isset( $prop['timestamp'] ) )
+ if ( isset( $prop['timestamp'] ) ) {
$vals['timestamp'] = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
+ }
if ( isset( $prop['user'] ) ) {
$vals['user'] = $file->getUser();
- if ( !$file->getUser( 'id' ) )
+ if ( !$file->getUser( 'id' ) ) {
$vals['anon'] = '';
+ }
}
if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) {
$vals['size'] = intval( $file->getSize() );
if ( isset( $prop['url'] ) ) {
if ( !is_null( $scale ) && !$file->isOld() ) {
$mto = $file->transform( array( 'width' => $scale['width'], 'height' => $scale['height'] ) );
- if ( $mto && !$mto->isError() )
- {
+ if ( $mto && !$mto->isError() ) {
$vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
$vals['thumbwidth'] = intval( $mto->getWidth() );
$vals['thumbheight'] = intval( $mto->getHeight() );
$vals['url'] = $file->getFullURL();
$vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
}
- if ( isset( $prop['comment'] ) )
+ if ( isset( $prop['comment'] ) ) {
$vals['comment'] = $file->getDescription();
- if ( isset( $prop['sha1'] ) )
+ }
+ if ( isset( $prop['sha1'] ) ) {
$vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
+ }
if ( isset( $prop['metadata'] ) ) {
$metadata = $file->getMetadata();
$vals['metadata'] = $metadata ? self::processMetaData( unserialize( $metadata ), $result ) : null;
}
- if ( isset( $prop['mime'] ) )
+ if ( isset( $prop['mime'] ) ) {
$vals['mime'] = $file->getMimeType();
-
- if ( isset( $prop['archivename'] ) && $file->isOld() )
+ }
+
+ if ( isset( $prop['archivename'] ) && $file->isOld() ) {
$vals['archivename'] = $file->getArchiveName();
-
- if ( isset( $prop['bitdepth'] ) )
+ }
+
+ if ( isset( $prop['bitdepth'] ) ) {
$vals['bitdepth'] = $file->getBitDepth();
+ }
return $vals;
}
-
- public static function processMetaData( $metadata, $result )
- {
+
+ public static function processMetaData( $metadata, $result ) {
$retval = array();
if ( is_array( $metadata ) ) {
- foreach ( $metadata as $key => $value )
- {
+ foreach ( $metadata as $key => $value ) {
$r = array( 'name' => $key );
- if ( is_array( $value ) )
+ if ( is_array( $value ) ) {
$r['value'] = self::processMetaData( $value, $result );
- else
+ } else {
$r['value'] = $value;
+ }
$retval[] = $r;
}
}
return $retval;
}
- private function getContinueStr( $img )
- {
+ private function getContinueStr( $img ) {
return $img->getOriginalTitle()->getText() .
'|' . $img->getTimestamp();
}
public function getAllowedParams() {
- return array (
- 'prop' => array (
- ApiBase :: PARAM_ISMULTI => true,
- ApiBase :: PARAM_DFLT => 'timestamp|user',
- ApiBase :: PARAM_TYPE => self::getPropertyNames()
+ return array(
+ 'prop' => array(
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_DFLT => 'timestamp|user',
+ ApiBase::PARAM_TYPE => self::getPropertyNames()
),
'limit' => array(
- ApiBase :: PARAM_TYPE => 'limit',
- ApiBase :: PARAM_DFLT => 1,
- ApiBase :: PARAM_MIN => 1,
- ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
- ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_DFLT => 1,
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
),
'start' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'end' => array(
- ApiBase :: PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp'
),
'urlwidth' => array(
- ApiBase :: PARAM_TYPE => 'integer',
- ApiBase :: PARAM_DFLT => - 1
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_DFLT => -1
),
'urlheight' => array(
- ApiBase :: PARAM_TYPE => 'integer',
- ApiBase :: PARAM_DFLT => - 1
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_DFLT => -1
),
'continue' => null,
);
}
-
+
/**
* Returns all possible parameters to iiprop
*/
public static function getPropertyNames() {
- return array (
- 'timestamp',
- 'user',
- 'comment',
- 'url',
- 'size',
- 'dimensions', // For backwards compatibility with Allimages
- 'sha1',
- 'mime',
- 'metadata',
- 'archivename',
- 'bitdepth',
- );
+ return array(
+ 'timestamp',
+ 'user',
+ 'comment',
+ 'url',
+ 'size',
+ 'dimensions', // For backwards compatibility with Allimages
+ 'sha1',
+ 'mime',
+ 'metadata',
+ 'archivename',
+ 'bitdepth',
+ );
}
public function getParamDescription() {
- return array (
+ return array(
'prop' => 'What image information to get.',
'limit' => 'How many image revisions to return',
'start' => 'Timestamp to start listing from',
}
public function getDescription() {
- return array (
+ return array(
'Returns image information and upload history'
);
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'code' => 'iiurlwidth', 'info' => 'iiurlheight cannot be used without iiurlwidth' ),
}
protected function getExamples() {
- return array (
+ return array(
'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=20071231235959&iiprop=timestamp|user|url',
);