ApiBase Class Reference
[API]

Created on Sep 5, 2006. More...

Inherited by ApiBlock, ApiDelete, ApiDisabled, ApiEditPage, ApiEmailUser, ApiExpandTemplates, ApiFeedWatchlist, ApiFormatBase, ApiHelp, ApiImport, ApiLogin, ApiLogout, ApiMain, ApiMove, ApiOpenSearch, ApiParamInfo, ApiParse, ApiPatrol, ApiProtect, ApiPurge, ApiQuery, ApiQueryBase, ApiResult, ApiRollback, ApiUnblock, ApiUndelete, ApiUpload, ApiUserrights, ApiWatch, and MockApi.

List of all members.

Public Member Functions

 __construct ($mainModule, $moduleName, $modulePrefix= '')
 Constructor.
 execute ()
 Evaluates the parameters, performs the requested query, and sets up the result.
 getVersion ()
 Returns a string that identifies the version of the extending class.
 getModuleName ()
 Get the name of the module being executed by this instance.
 getModulePrefix ()
 Get parameter prefix (usually two letters or an empty string).
 getModuleProfileName ($db=false)
 Get the name of the module as shown in the profiler log.
 getMain ()
 Get the main module.
 isMain ()
 Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.
 getResult ()
 Get the result object.
 getResultData ()
 Get the result data array (read-only).
 setWarning ($warning)
 Set warning section for this module.
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.
 makeHelpMsg ()
 Generates help message for this module, or false if there is no description.
 makeHelpMsgParameters ()
 Generates the parameter descriptions for this module, to be displayed in the module's help.
 makeHelpMsg_callback ($matches)
 Callback for preg_replace_callback() call in makeHelpMsg().
 getFinalParams ()
 Get final list of parameters, after hooks have had a chance to tweak it as needed.
 getFinalParamDescription ()
 Get final description, after hooks have had a chance to tweak it as needed.
 encodeParamName ($paramName)
 This method mangles parameter name based on the prefix supplied to the constructor.
 extractRequestParams ($parseLimit=true)
 Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default.
 requireOnlyOneParameter ($params)
 Die if none or more than one of a certain set of parameters is set and not false.
 validateLimit ($paramName, &$value, $min, $max, $botMax=null)
 Validate the value against the minimum and user/bot maximum limits.
 dieUsage ($description, $errorCode, $httpRespCode=0, $extradata=null)
 Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an error message.
 dieReadOnly ()
 Helper function for readonly errors.
 dieUsageMsg ($error)
 Output the error message related to a certain array.
 parseMsg ($error)
 Return the error message related to a certain array.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 isReadMode ()
 Indicates whether this module requires read rights.
 isWriteMode ()
 Indicates whether this module requires write mode.
 mustBePosted ()
 Indicates whether this module must be called with a POST request.
 needsToken ()
 Returns whether this module requires a Token to execute.
 getTokenSalt ()
 Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token.
 getPossibleErrors ()
 Returns a list of all possible errors returned by the module.
 parseErrors ($errors)
 Parses a list of errors into a standardised format.
 profileIn ()
 Start module profiling.
 profileOut ()
 End module profiling.
 safeProfileOut ()
 When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in.
 getProfileTime ()
 Total time the module was executed.
 profileDBIn ()
 Start module profiling.
 profileDBOut ()
 End database profiling.
 getProfileDBTime ()
 Total time the module used the database.

Static Public Member Functions

static getValidNamespaces ()
 Returns an array of the namespaces (by integer id) that exist on the wiki.
static truncateArray (&$arr, $limit)
 Truncate an array to a certain length.
static debugPrint ($value, $name= 'unknown', $backtrace=false)
 Debugging function that prints a value and an optional backtrace.
static getBaseVersion ()
 Returns a string that identifies the version of this class.

Public Attributes

const PARAM_DFLT = 0
const PARAM_ISMULTI = 1
const PARAM_TYPE = 2
const PARAM_MAX = 3
const PARAM_MAX2 = 4
const PARAM_MIN = 5
const PARAM_ALLOW_DUPLICATES = 6
const PARAM_DEPRECATED = 7
const LIMIT_BIG1 = 500
const LIMIT_BIG2 = 5000
const LIMIT_SML1 = 50
const LIMIT_SML2 = 500

Static Public Attributes

static $messageMap
 Array that maps message keys to error messages.

Protected Member Functions

 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.
 getParamDescription ()
 Returns an array of parameter descriptions.
 getParameter ($paramName, $parseLimit=true)
 Get a value for the given parameter.
 getParameterFromSettings ($paramName, $paramSettings, $parseLimit)
 Using the settings determine the value for the given parameter.
 parseMultiValue ($valueName, $value, $allowMultiple, $allowedValues)
 Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values.

Static Protected Member Functions

static dieDebug ($method, $message)
 Internal code errors should be reported with this method.

Private Attributes

 $mMainModule
 $mModuleName
 $mModulePrefix
 $mParamCache = array()
 $mTimeIn = 0
 Profiling: total module execution time.
 $mModuleTime = 0
 $mDBTimeIn = 0
 Profiling: database execution time.
 $mDBTime = 0


Detailed Description

Created on Sep 5, 2006.

API for MediaWiki 1.8+

Copyright © 2006, 2010 Yuri Astrakhan <Firstname><Lastname>.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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/copyleft/gpl.html This abstract class implements many basic API functions, and is the base of all API classes. The class functions are divided into several areas of functionality:

Module parameters: Derived classes can define getAllowedParams() to specify which parameters to expect,h ow to parse and validate them.

Profiling: various methods to allow keeping tabs on various tasks and their time costs

Self-documentation: code to allow the API to document its own state

Definition at line 41 of file ApiBase.php.


Constructor & Destructor Documentation

ApiBase::__construct ( mainModule,
moduleName,
modulePrefix = '' 
)

Constructor.

Parameters:
$mainModule ApiMain object
$moduleName string Name of this module
$modulePrefix string Prefix to use for parameter names

Reimplemented in ApiQueryBase, and ApiQueryGeneratorBase.

Definition at line 68 of file ApiBase.php.


Member Function Documentation

static ApiBase::debugPrint ( value,
name = 'unknown',
backtrace = false 
) [static]

Debugging function that prints a value and an optional backtrace.

Parameters:
$value mixed Value to print
$name string Description of the printed value
$backtrace bool If true, print a backtrace

Definition at line 1181 of file ApiBase.php.

References print, and wfBacktrace().

static ApiBase::dieDebug ( method,
message 
) [static, protected]

ApiBase::dieReadOnly (  ) 

Helper function for readonly errors.

Definition at line 935 of file ApiBase.php.

References dieUsage(), parseMsg(), and wfReadOnlyReason().

Referenced by ApiEditPage::execute(), and ApiMain::executeAction().

ApiBase::dieUsage ( description,
errorCode,
httpRespCode = 0,
extradata = null 
)

Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an error message.

Parameters:
$description string One-line human-readable description of the error condition, e.g., "The API requires a valid action parameter"
$errorCode string Brief, arbitrary, stable string to allow easy automated identification of the error, e.g., 'unknown_action'
$httpRespCode int HTTP response code
$extradata array Data to add to the <error> element; array in ApiResult format

Definition at line 792 of file ApiBase.php.

References encodeParamName(), and wfProfileClose().

Referenced by ApiQuerySiteinfo::appendDbReplLagInfo(), ApiMain::createPrinterByName(), dieReadOnly(), dieUsageMsg(), ApiWatch::execute(), ApiUpload::execute(), ApiQueryContributions::execute(), ApiQueryRevisions::execute(), ApiQueryRecentChanges::execute(), ApiQueryLogEvents::execute(), ApiQueryLangLinks::execute(), ApiQueryInfo::execute(), ApiQueryImageInfo::execute(), ApiQueryDeletedrevs::execute(), ApiQueryBlocks::execute(), ApiParse::execute(), ApiPageSet::execute(), ApiHelp::execute(), ApiEditPage::execute(), ApiDisabled::execute(), ApiMain::executeAction(), ApiQueryAllpages::executeGenerator(), ApiQueryAllimages::executeGenerator(), ApiQueryRevisions::extractRowInfo(), getParameterFromSettings(), ApiQuery::newGenerator(), ApiQueryBacklinks::parseContinueParam(), parseMultiValue(), ApiUpload::performUpload(), ApiQueryContributions::prepareQuery(), ApiQueryContributions::prepareUsername(), ApiQueryBlocks::prepareUsername(), ApiQueryBacklinks::processContinue(), requireOnlyOneParameter(), ApiQueryWatchlistRaw::run(), ApiQueryWatchlist::run(), ApiQuerySearch::run(), ApiQueryLinks::run(), ApiQueryImages::run(), ApiQueryExtLinksUsage::run(), ApiQueryDuplicateFiles::run(), ApiQueryCategoryMembers::run(), ApiQueryCategories::run(), ApiQueryAllpages::run(), ApiQueryAllLinks::run(), ApiQueryAllimages::run(), and ApiQueryCategoryMembers::setContinuation().

ApiBase::dieUsageMsg ( error  ) 

ApiBase::encodeParamName ( paramName  ) 

This method mangles parameter name based on the prefix supplied to the constructor.

Override this method to change parameter name during runtime

Parameters:
$paramName string Parameter name
Returns:
string Prefixed parameter name

Reimplemented in ApiQueryGeneratorBase.

Definition at line 462 of file ApiBase.php.

Referenced by dieUsage(), getParameterFromSettings(), makeHelpMsgParameters(), ApiQueryBase::setContinueEnumParameter(), and validateLimit().

ApiBase::execute (  )  [abstract]

Evaluates the parameters, performs the requested query, and sets up the result.

Concrete implementations of ApiBase must override this method to provide whatever functionality their module offers. Implementations must not produce any output on their own and are not expected to handle any errors.

The execute() method will be invoked directly by ApiMain immediately before the result of the module is output. Aside from the constructor, implementations should assume that no other methods will be called externally on the module before the result is processed.

The result data should be stored in the ApiResult object available through getResult().

Reimplemented in ApiBlock, ApiDelete, ApiDisabled, ApiEditPage, ApiEmailUser, ApiExpandTemplates, ApiFeedWatchlist, ApiFormatFeedWrapper, ApiFormatDbg, ApiFormatJson, ApiFormatPhp, ApiFormatRaw, ApiFormatTxt, ApiFormatWddx, ApiFormatXml, ApiFormatYaml, ApiHelp, ApiImport, ApiLogin, ApiLogout, ApiMain, ApiMove, ApiOpenSearch, ApiPageSet, ApiParamInfo, ApiParse, ApiPatrol, ApiProtect, ApiPurge, ApiQuery, ApiQueryAllCategories, ApiQueryAllimages, ApiQueryAllLinks, ApiQueryAllmessages, ApiQueryAllpages, ApiQueryAllUsers, ApiQueryBacklinks, ApiQueryBlocks, ApiQueryCategories, ApiQueryCategoryInfo, ApiQueryCategoryMembers, ApiQueryDeletedrevs, ApiQueryDisabled, ApiQueryDuplicateFiles, ApiQueryExternalLinks, ApiQueryExtLinksUsage, ApiQueryImageInfo, ApiQueryImages, ApiQueryInfo, ApiQueryLangLinks, ApiQueryLinks, ApiQueryLogEvents, ApiQueryProtectedTitles, ApiQueryRandom, ApiQueryRecentChanges, ApiQueryRevisions, ApiQuerySearch, ApiQuerySiteinfo, ApiQueryTags, ApiQueryContributions, ApiQueryUserInfo, ApiQueryUsers, ApiQueryWatchlist, ApiQueryWatchlistRaw, ApiResult, ApiRollback, ApiUnblock, ApiUndelete, ApiUpload, ApiUserrights, ApiWatch, and MockApi.

ApiBase::extractRequestParams ( parseLimit = true  ) 

Using getAllowedParams(), this function makes an array of the values provided by the user, with key being the name of the variable, and value - validated value from user or default.

limits will not be parsed if $parseLimit is set to false; use this when the max limit is not definitive yet, e.g. when getting revisions.

Parameters:
$parseLimit Boolean: true by default
Returns:
array

Definition at line 475 of file ApiBase.php.

References getFinalParams(), and getParameterFromSettings().

Referenced by ApiWatch::execute(), ApiUserrights::execute(), ApiUpload::execute(), ApiUndelete::execute(), ApiUnblock::execute(), ApiRollback::execute(), ApiQueryUsers::execute(), ApiQueryUserInfo::execute(), ApiQueryContributions::execute(), ApiQueryTags::execute(), ApiQuerySiteinfo::execute(), ApiQueryRevisions::execute(), ApiQueryRecentChanges::execute(), ApiQueryLogEvents::execute(), ApiQueryLangLinks::execute(), ApiQueryInfo::execute(), ApiQueryImageInfo::execute(), ApiQueryExternalLinks::execute(), ApiQueryDeletedrevs::execute(), ApiQueryCategoryInfo::execute(), ApiQueryBlocks::execute(), ApiQueryAllUsers::execute(), ApiQueryAllmessages::execute(), ApiQuery::execute(), ApiPurge::execute(), ApiProtect::execute(), ApiPatrol::execute(), ApiParse::execute(), ApiParamInfo::execute(), ApiPageSet::execute(), ApiOpenSearch::execute(), ApiMove::execute(), ApiLogin::execute(), ApiImport::execute(), ApiFormatXml::execute(), ApiFormatJson::execute(), ApiFeedWatchlist::execute(), ApiExpandTemplates::execute(), ApiEmailUser::execute(), ApiEditPage::execute(), ApiDelete::execute(), ApiBlock::execute(), ApiMain::executeAction(), ApiFormatJson::getMimeType(), ApiUserrights::getTokenSalt(), ApiQueryWatchlistRaw::run(), ApiQueryWatchlist::run(), ApiQuerySearch::run(), ApiQueryRandom::run(), ApiQueryProtectedTitles::run(), ApiQueryLinks::run(), ApiQueryImages::run(), ApiQueryExtLinksUsage::run(), ApiQueryDuplicateFiles::run(), ApiQueryCategoryMembers::run(), ApiQueryCategories::run(), ApiQueryBacklinks::run(), ApiQueryAllpages::run(), ApiQueryAllLinks::run(), ApiQueryAllimages::run(), and ApiQueryAllCategories::run().

ApiBase::getAllowedParams (  )  [protected]

static ApiBase::getBaseVersion (  )  [static]

Returns a string that identifies the version of this class.

Returns:
string

Reimplemented in ApiFormatBase, and ApiQueryBase.

Definition at line 1194 of file ApiBase.php.

Referenced by ApiMain::getVersion().

ApiBase::getCustomPrinter (  ) 

If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.

A value of null means the default format will be used.

Returns:
mixed instance of a derived class of ApiFormatBase, or null

Reimplemented in ApiFeedWatchlist, ApiOpenSearch, and ApiQuery.

Definition at line 204 of file ApiBase.php.

ApiBase::getDescription (  )  [protected]

ApiBase::getExamples (  )  [protected]

ApiBase::getFinalParamDescription (  ) 

Get final description, after hooks have had a chance to tweak it as needed.

Returns:
array

Definition at line 450 of file ApiBase.php.

References getParamDescription(), and wfRunHooks().

Referenced by makeHelpMsgParameters().

ApiBase::getFinalParams (  ) 

Get final list of parameters, after hooks have had a chance to tweak it as needed.

Returns:
array

Definition at line 439 of file ApiBase.php.

References getAllowedParams(), and wfRunHooks().

Referenced by extractRequestParams(), getParameter(), and makeHelpMsgParameters().

ApiBase::getMain (  ) 

ApiBase::getModuleName (  ) 

Get the name of the module being executed by this instance.

Returns:
string

Definition at line 108 of file ApiBase.php.

Referenced by ApiQueryBase::addPageSubItem(), ApiQueryBase::addPageSubItems(), ApiQueryTags::doTag(), ApiWatch::execute(), ApiUserrights::execute(), ApiUpload::execute(), ApiUndelete::execute(), ApiUnblock::execute(), ApiRollback::execute(), ApiQueryUsers::execute(), ApiQueryUserInfo::execute(), ApiQueryContributions::execute(), ApiQueryTags::execute(), ApiQueryRevisions::execute(), ApiQueryRecentChanges::execute(), ApiQueryLogEvents::execute(), ApiQueryDeletedrevs::execute(), ApiQueryBlocks::execute(), ApiQueryAllUsers::execute(), ApiQueryAllmessages::execute(), ApiPurge::execute(), ApiProtect::execute(), ApiPatrol::execute(), ApiParse::execute(), ApiParamInfo::execute(), ApiMove::execute(), ApiImport::execute(), ApiExpandTemplates::execute(), ApiEmailUser::execute(), ApiEditPage::execute(), ApiDelete::execute(), ApiBlock::execute(), ApiQueryBacklinks::getAllowedParams(), ApiQueryBacklinks::getDescription(), ApiQueryBacklinks::getExamples(), ApiFormatBase::getExamples(), ApiQueryBacklinks::getParamDescription(), getParameterFromSettings(), ApiQueryAllLinks::getPossibleErrors(), getPossibleErrors(), ApiMain::makeHelpMsg(), ApiQueryWatchlistRaw::run(), ApiQueryWatchlist::run(), ApiQuerySearch::run(), ApiQueryRandom::run(), ApiQueryProtectedTitles::run(), ApiQueryExtLinksUsage::run(), ApiQueryCategoryMembers::run(), ApiQueryBacklinks::run(), ApiQueryAllpages::run(), ApiQueryAllLinks::run(), ApiQueryAllimages::run(), ApiQueryAllCategories::run(), ApiQueryRandom::runQuery(), ApiQueryBase::setContinueEnumParameter(), and setWarning().

ApiBase::getModulePrefix (  ) 

Get parameter prefix (usually two letters or an empty string).

Returns:
string

Definition at line 116 of file ApiBase.php.

Referenced by ApiQueryBase::addPageSubItem(), ApiQueryBase::addPageSubItems(), ApiQueryProtectedTitles::run(), and ApiQueryExtLinksUsage::run().

ApiBase::getModuleProfileName ( db = false  ) 

Get the name of the module as shown in the profiler log.

Returns:
string

Definition at line 124 of file ApiBase.php.

Referenced by profileDBIn(), profileDBOut(), profileIn(), and profileOut().

ApiBase::getParamDescription (  )  [protected]

ApiBase::getParameter ( paramName,
parseLimit = true 
) [protected]

Get a value for the given parameter.

Parameters:
$paramName string Parameter name
$parseLimit bool see extractRequestParams()
Returns:
mixed Parameter value

Definition at line 498 of file ApiBase.php.

References getFinalParams(), and getParameterFromSettings().

Referenced by ApiMain::executeAction(), ApiQuery::getCustomPrinter(), ApiMain::sendCacheHeaders(), and ApiMain::substituteResultWithError().

ApiBase::getParameterFromSettings ( paramName,
paramSettings,
parseLimit 
) [protected]

Using the settings determine the value for the given parameter.

Parameters:
$paramName String: parameter name
$paramSettings Mixed: default value or an array of settings using PARAM_* constants.
$parseLimit Boolean: parse limit?
Returns:
mixed Parameter value

Definition at line 552 of file ApiBase.php.

References $title, dieDebug(), dieUsage(), encodeParamName(), getMain(), getModuleName(), getResult(), getValidNamespaces(), Title::makeTitleSafe(), parseMultiValue(), setWarning(), validateLimit(), and wfTimestamp().

Referenced by extractRequestParams(), and getParameter().

ApiBase::getPossibleErrors (  ) 

ApiBase::getProfileDBTime (  ) 

Total time the module used the database.

Returns:
float

Definition at line 1168 of file ApiBase.php.

References dieDebug().

ApiBase::getProfileTime (  ) 

Total time the module was executed.

Returns:
float

Definition at line 1119 of file ApiBase.php.

References dieDebug().

ApiBase::getResult (  ) 

Get the result object.

Returns:
ApiResult

Reimplemented in ApiMain.

Definition at line 153 of file ApiBase.php.

References dieDebug(), getMain(), and isMain().

Referenced by ApiQueryBase::addPageSubItem(), ApiQueryBase::addPageSubItems(), ApiQuerySiteinfo::appendDbReplLagInfo(), ApiQuerySiteinfo::appendExtensions(), ApiQuerySiteinfo::appendFileExtensions(), ApiQuerySiteinfo::appendGeneralInfo(), ApiQuerySiteinfo::appendInterwikiMap(), ApiQuerySiteinfo::appendLanguages(), ApiQuerySiteinfo::appendMagicWords(), ApiQuerySiteinfo::appendNamespaceAliases(), ApiQuerySiteinfo::appendNamespaces(), ApiQuerySiteinfo::appendRightsInfo(), ApiQuerySiteinfo::appendSpecialPageAliases(), ApiQuerySiteinfo::appendStatistics(), ApiQuerySiteinfo::appendUserGroups(), ApiWatch::execute(), ApiUserrights::execute(), ApiUpload::execute(), ApiUndelete::execute(), ApiUnblock::execute(), ApiRollback::execute(), ApiQueryUsers::execute(), ApiQueryUserInfo::execute(), ApiQueryContributions::execute(), ApiQueryTags::execute(), ApiQueryRevisions::execute(), ApiQueryRecentChanges::execute(), ApiQueryLogEvents::execute(), ApiQueryInfo::execute(), ApiQueryImageInfo::execute(), ApiQueryDeletedrevs::execute(), ApiQueryBlocks::execute(), ApiQueryAllUsers::execute(), ApiQueryAllmessages::execute(), ApiPurge::execute(), ApiProtect::execute(), ApiPatrol::execute(), ApiParse::execute(), ApiParamInfo::execute(), ApiOpenSearch::execute(), ApiMove::execute(), ApiLogin::execute(), ApiImport::execute(), ApiFeedWatchlist::execute(), ApiExpandTemplates::execute(), ApiEmailUser::execute(), ApiEditPage::execute(), ApiDelete::execute(), ApiBlock::execute(), ApiQueryInfo::extractPageInfo(), ApiQueryBacklinks::extractRedirRowInfo(), ApiQueryContributions::extractRowInfo(), ApiQueryRevisions::extractRowInfo(), ApiQueryRecentChanges::extractRowInfo(), ApiQueryLogEvents::extractRowInfo(), ApiParse::formatCategoryLinks(), ApiParse::formatHeadItems(), ApiParse::formatLangLinks(), ApiParse::formatLinks(), ApiParamInfo::getClassInfo(), ApiQueryUserInfo::getCurrentUserInfo(), getParameterFromSettings(), getResultData(), ApiQuery::outputGeneralPageInfo(), ApiUpload::performUpload(), ApiQueryWatchlistRaw::run(), ApiQueryWatchlist::run(), ApiQuerySearch::run(), ApiQueryRandom::run(), ApiQueryProtectedTitles::run(), ApiQueryExtLinksUsage::run(), ApiQueryCategoryMembers::run(), ApiQueryBacklinks::run(), ApiQueryAllpages::run(), ApiQueryAllLinks::run(), ApiQueryAllimages::run(), ApiQueryAllCategories::run(), ApiQueryRandom::runQuery(), ApiQueryBase::setContinueEnumParameter(), ApiParse::setIndexedTagNames(), and setWarning().

ApiBase::getResultData (  ) 

ApiBase::getTokenSalt (  ) 

Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token.

Returns:
bool

Reimplemented in ApiBlock, ApiDelete, ApiEditPage, ApiEmailUser, ApiImport, ApiMove, ApiPatrol, ApiProtect, ApiUnblock, ApiUndelete, ApiUpload, and ApiUserrights.

Definition at line 1020 of file ApiBase.php.

static ApiBase::getValidNamespaces (  )  [static]

Returns an array of the namespaces (by integer id) that exist on the wiki.

Used primarily in help documentation.

Returns:
array

Definition at line 527 of file ApiBase.php.

References $wgContLang.

Referenced by getParameterFromSettings(), and makeHelpMsgParameters().

ApiBase::getVersion (  )  [abstract]

ApiBase::isMain (  ) 

Returns true if this module is the main module ($this === $this->mMainModule), false otherwise.

Returns:
bool

Definition at line 145 of file ApiBase.php.

Referenced by getResult().

ApiBase::isReadMode (  ) 

Indicates whether this module requires read rights.

Returns:
bool

Reimplemented in ApiDisabled, ApiHelp, ApiLogin, ApiLogout, ApiMain, and ApiParamInfo.

Definition at line 989 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

ApiBase::isWriteMode (  ) 

Indicates whether this module requires write mode.

Returns:
bool

Reimplemented in ApiBlock, ApiDelete, ApiEditPage, ApiEmailUser, ApiImport, ApiMove, ApiPatrol, ApiProtect, ApiPurge, ApiRollback, ApiUnblock, ApiUndelete, ApiUpload, ApiUserrights, and ApiWatch.

Definition at line 996 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

ApiBase::makeHelpMsg (  ) 

Generates help message for this module, or false if there is no description.

Returns:
mixed string or false

Reimplemented in ApiMain, and ApiQuery.

Definition at line 212 of file ApiBase.php.

References $msg, getDescription(), getExamples(), getMain(), getVersion(), isReadMode(), isWriteMode(), makeHelpMsgParameters(), and mustBePosted().

ApiBase::makeHelpMsg_callback ( matches  ) 

Callback for preg_replace_callback() call in makeHelpMsg().

Replaces a source file name with a link to ViewVC

Definition at line 368 of file ApiBase.php.

References $path, $wgAutoloadClasses, and $wgAutoloadLocalClasses.

ApiBase::makeHelpMsgParameters (  ) 

Generates the parameter descriptions for this module, to be displayed in the module's help.

Returns:
string

Reimplemented in ApiQuery.

Definition at line 285 of file ApiBase.php.

References $msg, $t, encodeParamName(), getFinalParamDescription(), getFinalParams(), and getValidNamespaces().

Referenced by makeHelpMsg().

ApiBase::mustBePosted (  ) 

Indicates whether this module must be called with a POST request.

Returns:
bool

Reimplemented in ApiBlock, ApiDelete, ApiEditPage, ApiEmailUser, ApiImport, ApiLogin, ApiMove, ApiProtect, ApiPurge, ApiRollback, ApiUnblock, ApiUndelete, ApiUpload, and ApiUserrights.

Definition at line 1004 of file ApiBase.php.

Referenced by getPossibleErrors(), and makeHelpMsg().

ApiBase::needsToken (  ) 

Returns whether this module requires a Token to execute.

Returns:
bool

Reimplemented in ApiBlock, ApiDelete, ApiEditPage, ApiEmailUser, ApiImport, ApiMove, ApiPatrol, ApiProtect, ApiUnblock, ApiUndelete, ApiUpload, and ApiUserrights.

Definition at line 1012 of file ApiBase.php.

Referenced by getPossibleErrors().

ApiBase::parseErrors ( errors  ) 

Parses a list of errors into a standardised format.

Parameters:
$errors array List of errors. Items can be in the for array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
Returns:
array Parsed list of errors with items in the form array( 'code' => ..., 'info' => ... )

Definition at line 1057 of file ApiBase.php.

References parseMsg().

Referenced by ApiParamInfo::getClassInfo().

ApiBase::parseMsg ( error  ) 

Return the error message related to a certain array.

Parameters:
$error array Element of a getUserPermissionsErrors()-style array
Returns:
array('code' => code, 'info' => info)

Definition at line 955 of file ApiBase.php.

References wfMsgReplaceArgs().

Referenced by dieReadOnly(), dieUsageMsg(), ApiMove::execute(), ApiMove::moveSubpages(), and parseErrors().

ApiBase::parseMultiValue ( valueName,
value,
allowMultiple,
allowedValues 
) [protected]

Return an array of values that were given in a 'a|b|c' notation, after it optionally validates them against the list allowed values.

Parameters:
$valueName string The name of the parameter (for error reporting)
$value mixed The value being parsed
$allowMultiple bool Can $value contain more than one value separated by '|'?
$allowedValues mixed An array of values to check against. If null, all values are accepted.
Returns:
mixed (allowMultiple ? an_array_of_values : a_single_value)

Definition at line 693 of file ApiBase.php.

References $s, dieUsage(), and setWarning().

Referenced by getParameterFromSettings().

ApiBase::profileDBIn (  ) 

ApiBase::profileDBOut (  ) 

ApiBase::profileIn (  ) 

ApiBase::profileOut (  ) 

ApiBase::requireOnlyOneParameter ( params  ) 

Die if none or more than one of a certain set of parameters is set and not false.

Parameters:
$params array of parameter names

Definition at line 508 of file ApiBase.php.

References dieUsage().

Referenced by ApiUpload::execute(), ApiMove::execute(), and ApiDelete::execute().

ApiBase::safeProfileOut (  ) 

When modules crash, sometimes it is needed to do a profileOut() regardless of the profiling state the module was in.

This method does such cleanup.

Definition at line 1106 of file ApiBase.php.

References profileDBOut(), and profileOut().

ApiBase::setWarning ( warning  ) 

Set warning section for this module.

Users should monitor this section to notice any changes in API. Multiple calls to this function will result in the warning messages being separated by newlines

Parameters:
$warning string Warning message

Definition at line 177 of file ApiBase.php.

References $msg, getModuleName(), getResult(), and ApiResult::setContent().

Referenced by ApiFormatXml::addXslt(), ApiQueryUsers::execute(), ApiQueryRevisions::execute(), ApiQueryDisabled::execute(), ApiPageSet::execute(), ApiQueryInfo::extractPageInfo(), ApiQueryRevisions::extractRowInfo(), ApiQueryRecentChanges::extractRowInfo(), getParameterFromSettings(), parseMultiValue(), ApiPageSet::processTitlesArray(), ApiQueryCategories::run(), and validateLimit().

ApiBase::shouldCheckMaxlag (  ) 

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented in ApiHelp, and ApiQuery.

Definition at line 981 of file ApiBase.php.

static ApiBase::truncateArray ( &$  arr,
limit 
) [static]

Truncate an array to a certain length.

Parameters:
$arr array Array to truncate
$limit int Maximum length
Returns:
bool True if the array was truncated, false otherwise

Definition at line 772 of file ApiBase.php.

ApiBase::validateLimit ( paramName,
&$  value,
min,
max,
botMax = null 
)

Validate the value against the minimum and user/bot maximum limits.

Prints usage info on failure.

Parameters:
$paramName string Parameter name
$value int Parameter value
$min int Minimum value
$max int Maximum value for users
$botMax int Maximum value for sysops/bots

Definition at line 740 of file ApiBase.php.

References encodeParamName(), getMain(), and setWarning().

Referenced by ApiQueryRevisions::execute(), ApiQueryDeletedrevs::execute(), and getParameterFromSettings().


Member Data Documentation

ApiBase::$mDBTime = 0 [private]

Definition at line 1129 of file ApiBase.php.

ApiBase::$mDBTimeIn = 0 [private]

Profiling: database execution time.

Definition at line 1129 of file ApiBase.php.

ApiBase::$messageMap [static]

Array that maps message keys to error messages.

$1 and friends are replaced.

Definition at line 800 of file ApiBase.php.

ApiBase::$mMainModule [private]

Definition at line 59 of file ApiBase.php.

ApiBase::$mModuleName [private]

Definition at line 59 of file ApiBase.php.

ApiBase::$mModulePrefix [private]

Definition at line 59 of file ApiBase.php.

ApiBase::$mModuleTime = 0 [private]

Definition at line 1073 of file ApiBase.php.

ApiBase::$mParamCache = array() [private]

Definition at line 60 of file ApiBase.php.

ApiBase::$mTimeIn = 0 [private]

Profiling: total module execution time.

Definition at line 1073 of file ApiBase.php.

const ApiBase::LIMIT_BIG1 = 500

const ApiBase::LIMIT_BIG2 = 5000

const ApiBase::LIMIT_SML1 = 50

const ApiBase::LIMIT_SML2 = 500

Definition at line 51 of file ApiBase.php.

Referenced by ApiProtect::getAllowedParams(), and ApiParamInfo::getClassInfo().

Definition at line 52 of file ApiBase.php.

Referenced by ApiEditPage::getAllowedParams(), and ApiParamInfo::getClassInfo().

Definition at line 45 of file ApiBase.php.

Referenced by ApiUserrights::getAllowedParams(), ApiUpload::getAllowedParams(), ApiQueryWatchlistRaw::getAllowedParams(), ApiQueryWatchlist::getAllowedParams(), ApiQueryUsers::getAllowedParams(), ApiQueryUserInfo::getAllowedParams(), ApiQueryContributions::getAllowedParams(), ApiQueryTags::getAllowedParams(), ApiQuerySiteinfo::getAllowedParams(), ApiQuerySearch::getAllowedParams(), ApiQueryRevisions::getAllowedParams(), ApiQueryRecentChanges::getAllowedParams(), ApiQueryRandom::getAllowedParams(), ApiQueryProtectedTitles::getAllowedParams(), ApiQueryLogEvents::getAllowedParams(), ApiQueryLinks::getAllowedParams(), ApiQueryLangLinks::getAllowedParams(), ApiQueryInfo::getAllowedParams(), ApiQueryImages::getAllowedParams(), ApiQueryImageInfo::getAllowedParams(), ApiQueryExtLinksUsage::getAllowedParams(), ApiQueryExternalLinks::getAllowedParams(), ApiQueryDuplicateFiles::getAllowedParams(), ApiQueryDeletedrevs::getAllowedParams(), ApiQueryCategoryMembers::getAllowedParams(), ApiQueryCategories::getAllowedParams(), ApiQueryBlocks::getAllowedParams(), ApiQueryBacklinks::getAllowedParams(), ApiQueryAllUsers::getAllowedParams(), ApiQueryAllpages::getAllowedParams(), ApiQueryAllmessages::getAllowedParams(), ApiQueryAllLinks::getAllowedParams(), ApiQueryAllimages::getAllowedParams(), ApiQueryAllCategories::getAllowedParams(), ApiProtect::getAllowedParams(), ApiParse::getAllowedParams(), ApiOpenSearch::getAllowedParams(), ApiMain::getAllowedParams(), ApiFeedWatchlist::getAllowedParams(), ApiExpandTemplates::getAllowedParams(), ApiEditPage::getAllowedParams(), and ApiParamInfo::getClassInfo().

const ApiBase::PARAM_MAX = 3

const ApiBase::PARAM_MIN = 5

Definition at line 47 of file ApiBase.php.

Referenced by ApiUserrights::getAllowedParams(), ApiQueryWatchlistRaw::getAllowedParams(), ApiQueryWatchlist::getAllowedParams(), ApiQueryUsers::getAllowedParams(), ApiQueryUserInfo::getAllowedParams(), ApiQueryContributions::getAllowedParams(), ApiQueryTags::getAllowedParams(), ApiQuerySiteinfo::getAllowedParams(), ApiQuerySearch::getAllowedParams(), ApiQueryRevisions::getAllowedParams(), ApiQueryRecentChanges::getAllowedParams(), ApiQueryRandom::getAllowedParams(), ApiQueryProtectedTitles::getAllowedParams(), ApiQueryLogEvents::getAllowedParams(), ApiQueryLinks::getAllowedParams(), ApiQueryLangLinks::getAllowedParams(), ApiQueryInfo::getAllowedParams(), ApiQueryImages::getAllowedParams(), ApiQueryImageInfo::getAllowedParams(), ApiQueryExtLinksUsage::getAllowedParams(), ApiQueryExternalLinks::getAllowedParams(), ApiQueryDuplicateFiles::getAllowedParams(), ApiQueryDeletedrevs::getAllowedParams(), ApiQueryCategoryMembers::getAllowedParams(), ApiQueryCategories::getAllowedParams(), ApiQueryBlocks::getAllowedParams(), ApiQueryBacklinks::getAllowedParams(), ApiQueryAllUsers::getAllowedParams(), ApiQueryAllpages::getAllowedParams(), ApiQueryAllmessages::getAllowedParams(), ApiQueryAllLinks::getAllowedParams(), ApiQueryAllimages::getAllowedParams(), ApiQueryAllCategories::getAllowedParams(), ApiQuery::getAllowedParams(), ApiPatrol::getAllowedParams(), ApiParse::getAllowedParams(), ApiPageSet::getAllowedParams(), ApiOpenSearch::getAllowedParams(), ApiMove::getAllowedParams(), ApiMain::getAllowedParams(), ApiImport::getAllowedParams(), ApiFeedWatchlist::getAllowedParams(), ApiEditPage::getAllowedParams(), ApiDelete::getAllowedParams(), and ApiParamInfo::getClassInfo().


The documentation for this class was generated from the following file:

Generated on Sat Apr 30 22:57:30 2011 for MediaWiki by  doxygen 1.5.9