[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/api/ -> ApiBase.php (summary)

Created on Sep 5, 2006 Copyright © 2006, 2010 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"

File Size: 2378 lines (74 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 77 functions

  __construct()
  getModuleManager()
  getCustomPrinter()
  getDescription()
  getExamples()
  getHelpUrls()
  getAllowedParams()
  getParamDescription()
  shouldCheckMaxlag()
  isReadMode()
  isWriteMode()
  mustBePosted()
  needsToken()
  getWebUITokenSalt()
  getModuleName()
  getModulePrefix()
  getMain()
  isMain()
  getResult()
  getResultData()
  getDB()
  getFinalDescription()
  getFinalParams()
  getFinalParamDescription()
  encodeParamName()
  extractRequestParams()
  getParameter()
  requireOnlyOneParameter()
  requireMaxOneParameter()
  requireAtLeastOneParameter()
  parameterNotEmpty()
  getTitleOrPageId()
  getWatchlistValue()
  getParameterFromSettings()
  parseMultiValue()
  validateLimit()
  validateTimestamp()
  validateToken()
  validateUser()
  setWatch()
  truncateArray()
  getWatchlistUser()
  setWarning()
  warnOrDie()
  dieUsage()
  getErrorFromStatus()
  dieStatus()
  dieReadOnly()
  dieUsageMsg()
  dieUsageMsgOrDebug()
  dieContinueUsageIf()
  parseMsg()
  dieDebug()
  makeHelpMsg()
  indentExampleText()
  makeHelpArrayToString()
  makeHelpMsgParameters()
  getModuleProfileName()
  profileIn()
  profileOut()
  safeProfileOut()
  getProfileTime()
  profileDBIn()
  profileDBOut()
  getProfileDBTime()
  logFeatureUsage()
  getVersion()
  getResultProperties()
  getFinalResultProperties()
  addTokenProperties()
  getRequireOnlyOneParameterErrorMessages()
  getRequireMaxOneParameterErrorMessages()
  getRequireAtLeastOneParameterErrorMessages()
  getTitleOrPageIdErrorMessage()
  getPossibleErrors()
  getFinalPossibleErrors()
  parseErrors()

Functions
Functions that are not part of a class:

__construct( ApiMain $mainModule, $moduleName, $modulePrefix = '' )   X-Ref

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

getModuleManager()   X-Ref
Get the module manager, or null if this module has no sub-modules

return: ApiModuleManager

getCustomPrinter()   X-Ref
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.

return: mixed Instance of a derived class of ApiFormatBase, or null

getDescription()   X-Ref
Returns the description string for this module

return: string|array

getExamples()   X-Ref
Returns usage examples for this module. Return false if no examples are available.

return: bool|string|array

getHelpUrls()   X-Ref

return: bool|string|array Returns a false if the module has no help URL,

getAllowedParams( )   X-Ref
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.

Some derived classes may choose to handle an integer $flags parameter
in the overriding methods. Callers of this method can pass zero or
more OR-ed flags like GET_VALUES_FOR_HELP.

return: array|bool

getParamDescription()   X-Ref
Returns an array of parameter descriptions.
Don't call this function directly: use getFinalParamDescription() to
allow hooks to modify descriptions as needed.

return: array|bool False on no parameter descriptions

shouldCheckMaxlag()   X-Ref
Indicates if this module needs maxlag to be checked

return: bool

isReadMode()   X-Ref
Indicates whether this module requires read rights

return: bool

isWriteMode()   X-Ref
Indicates whether this module requires write mode

return: bool

mustBePosted()   X-Ref
Indicates whether this module must be called with a POST request

return: bool

needsToken()   X-Ref
Returns the token type this module requires in order to execute.

Modules are strongly encouraged to use the core 'csrf' type unless they
have specialized security needs. If the token type is not one of the
core types, you must use the ApiQueryTokensRegisterTypes hook to
register it.

Returning a non-falsey value here will cause self::getFinalParams() to
return a required string 'token' parameter and
self::getFinalParamDescription() to ensure there is standardized
documentation for it. Also, self::mustBePosted() must return true when
tokens are used.

In previous versions of MediaWiki, true was a valid return value.
Returning true will generate errors indicating that the API module needs
updating.

return: string|false

getWebUITokenSalt( array $params )   X-Ref
Fetch the salt used in the Web UI corresponding to this module.

Only override this if the Web UI uses a token with a non-constant salt.

param: array $params All supplied parameters for the module
return: string|array|null

getModuleName()   X-Ref
Get the name of the module being executed by this instance

return: string

getModulePrefix()   X-Ref
Get parameter prefix (usually two letters or an empty string).

return: string

getMain()   X-Ref
Get the main module

return: ApiMain

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

return: bool

getResult()   X-Ref
Get the result object

return: ApiResult

getResultData()   X-Ref
Get the result data array (read-only)

return: array

getDB()   X-Ref
Gets a default slave database connection object

return: DatabaseBase

getFinalDescription()   X-Ref
Get final module description, after hooks have had a chance to tweak it as
needed.

return: array|bool False on no parameters

getFinalParams( $flags = 0 )   X-Ref
Get final list of parameters, after hooks have had a chance to
tweak it as needed.

param: int $flags Zero or more flags like GET_VALUES_FOR_HELP
return: array|bool False on no parameters

getFinalParamDescription()   X-Ref
Get final parameter descriptions, after hooks have had a chance to tweak it as
needed.

return: array|bool False on no parameter descriptions

encodeParamName( $paramName )   X-Ref
This method mangles parameter name based on the prefix supplied to the constructor.
Override this method to change parameter name during runtime

param: string $paramName Parameter name
return: string Prefixed parameter name

extractRequestParams( $parseLimit = true )   X-Ref
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.

param: bool $parseLimit True by default
return: array

getParameter( $paramName, $parseLimit = true )   X-Ref
Get a value for the given parameter

param: string $paramName Parameter name
param: bool $parseLimit See extractRequestParams()
return: mixed Parameter value

requireOnlyOneParameter( $params, $required )   X-Ref
Die if none or more than one of a certain set of parameters is set and not false.

param: array $params User provided set of parameters, as from $this->extractRequestParams()
param: string $required,... Names of parameters of which exactly one must be set

requireMaxOneParameter( $params, $required )   X-Ref
Die if more than one of a certain set of parameters is set and not false.

param: array $params User provided set of parameters, as from $this->extractRequestParams()
param: string $required,... Names of parameters of which at most one must be set

requireAtLeastOneParameter( $params, $required )   X-Ref
Die if none of a certain set of parameters is set and not false.

param: array $params User provided set of parameters, as from $this->extractRequestParams()
param: string $required,... Names of parameters of which at least one must be set

parameterNotEmpty( $x )   X-Ref
Callback function used in requireOnlyOneParameter to check whether required parameters are set

param: object $x Parameter to check is not null/false
return: bool

getTitleOrPageId( $params, $load = false )   X-Ref
Get a WikiPage object from a title or pageid param, if possible.
Can die, if no param is set or if the title or page id is not valid.

param: array $params
param: bool|string $load Whether load the object's state from the database:
return: WikiPage

getWatchlistValue( $watchlist, $titleObj, $userOption = null )   X-Ref
Return true if we're to watch the page, false if not, null if no change.

param: string $watchlist Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
param: Title $titleObj The page under consideration
param: string $userOption The user option to consider when $watchlist=preferences.
return: bool

getParameterFromSettings( $paramName, $paramSettings, $parseLimit )   X-Ref
Using the settings determine the value for the given parameter

param: string $paramName Parameter name
param: array|mixed $paramSettings Default value or an array of settings
param: bool $parseLimit Parse limit?
return: mixed Parameter value

parseMultiValue( $valueName, $value, $allowMultiple, $allowedValues )   X-Ref
Return an array of values that were given in a 'a|b|c' notation,
after it optionally validates them against the list allowed values.

param: string $valueName The name of the parameter (for error
param: mixed $value The value being parsed
param: bool $allowMultiple Can $value contain more than one value
param: string[]|null $allowedValues An array of values to check against. If
return: string|string[] (allowMultiple ? an_array_of_values : a_single_value)

validateLimit( $paramName, &$value, $min, $max, $botMax = null, $enforceLimits = false )   X-Ref
Validate the value against the minimum and user/bot maximum limits.
Prints usage info on failure.

param: string $paramName Parameter name
param: int $value Parameter value
param: int|null $min Minimum value
param: int|null $max Maximum value for users
param: int $botMax Maximum value for sysops/bots
param: bool $enforceLimits Whether to enforce (die) if value is outside limits

validateTimestamp( $value, $encParamName )   X-Ref
Validate and normalize of parameters of type 'timestamp'

param: string $value Parameter value
param: string $encParamName Parameter name
return: string Validated and normalized parameter

validateToken( $token, array $params )   X-Ref
Validate the supplied token.

param: string $token Supplied token
param: array $params All supplied parameters for the module
return: bool

validateUser( $value, $encParamName )   X-Ref
Validate and normalize of parameters of type 'user'

param: string $value Parameter value
param: string $encParamName Parameter name
return: string Validated and normalized parameter

setWatch( $watch, $titleObj, $userOption = null )   X-Ref
Set a watch (or unwatch) based the based on a watchlist parameter.

param: string $watch Valid values: 'watch', 'unwatch', 'preferences', 'nochange'
param: Title $titleObj The article's title to change
param: string $userOption The user option to consider when $watch=preferences

truncateArray( &$arr, $limit )   X-Ref
Truncate an array to a certain length.

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

getWatchlistUser( $params )   X-Ref
Gets the user for whom to get the watchlist

param: array $params
return: User

setWarning( $warning )   X-Ref
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

param: string $warning Warning message

warnOrDie( $msg, $enforceLimits = false )   X-Ref
Adds a warning to the output, else dies

param: string $msg Message to show as a warning, or error message if dying
param: bool $enforceLimits Whether this is an enforce (die)

dieUsage( $description, $errorCode, $httpRespCode = 0, $extradata = null )   X-Ref
Throw a UsageException, which will (if uncaught) call the main module's
error handler and die with an error message.

param: string $description One-line human-readable description of the
param: string $errorCode Brief, arbitrary, stable string to allow easy
param: int $httpRespCode HTTP response code
param: array $extradata Data to add to the "<error>" element; array in ApiResult format

getErrorFromStatus( $status )   X-Ref
Get error (as code, string) from a Status object.

param: Status $status
return: array Array of code and error string

dieStatus( $status )   X-Ref
Throw a UsageException based on the errors in the Status object.

param: Status $status

dieReadOnly()   X-Ref
Helper function for readonly errors


dieUsageMsg( $error )   X-Ref
Output the error message related to a certain array

param: array|string $error Element of a getUserPermissionsErrors()-style array

dieUsageMsgOrDebug( $error )   X-Ref
Will only set a warning instead of failing if the global $wgDebugAPI
is set to true. Otherwise behaves exactly as dieUsageMsg().

param: array|string $error Element of a getUserPermissionsErrors()-style array

dieContinueUsageIf( $condition )   X-Ref
Die with the $prefix.'badcontinue' error. This call is common enough to
make it into the base method.

param: bool $condition Will only die if this value is true

parseMsg( $error )   X-Ref
Return the error message related to a certain array

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

dieDebug( $method, $message )   X-Ref
Internal code errors should be reported with this method

param: string $method Method or function name
param: string $message Error message

makeHelpMsg()   X-Ref
Generates help message for this module, or false if there is no description

return: string|bool

indentExampleText( $item )   X-Ref

param: string $item
return: string

makeHelpArrayToString( $prefix, $title, $input )   X-Ref

param: string $prefix Text to split output items
param: string $title What is being output
param: string|array $input
return: string

makeHelpMsgParameters()   X-Ref
Generates the parameter descriptions for this module, to be displayed in the
module's help.

return: string|bool

getModuleProfileName( $db = false )   X-Ref
Get the name of the module as shown in the profiler log

param: DatabaseBase|bool $db
return: string

profileIn()   X-Ref
Start module profiling


profileOut()   X-Ref
End module profiling


safeProfileOut()   X-Ref
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.


getProfileTime()   X-Ref
Total time the module was executed

return: float

profileDBIn()   X-Ref
Start module profiling


profileDBOut()   X-Ref
End database profiling


getProfileDBTime()   X-Ref
Total time the module used the database

return: float

logFeatureUsage( $feature )   X-Ref
Write logging information for API features to a debug log, for usage
analysis.

param: string $feature Feature being used.

getVersion()   X-Ref
Formerly returned a string that identifies the version of the extending
class. Typically included the class name, the svn revision, timestamp,
and last author. Usually done with SVN's Id keyword

return: string

getResultProperties()   X-Ref
Formerly used to fetch a list of possible properites in the result,
somehow organized with respect to the prop parameter that causes them to
be returned. The specific semantics of the return value was never
specified. Since this was never possible to be accurately updated, it
has been removed.

return: array|bool

getFinalResultProperties()   X-Ref

return: array|bool

addTokenProperties( &$props, $tokenFunctions )   X-Ref


getRequireOnlyOneParameterErrorMessages( $params )   X-Ref

return: array

getRequireMaxOneParameterErrorMessages( $params )   X-Ref

return: array

getRequireAtLeastOneParameterErrorMessages( $params )   X-Ref

return: array

getTitleOrPageIdErrorMessage()   X-Ref

return: array

getPossibleErrors()   X-Ref
This formerly attempted to return a list of all possible errors returned
by the module. However, this was impossible to maintain in many cases
since errors could come from other areas of MediaWiki and in some cases
from arbitrary extension hooks. Since a partial list claiming to be
comprehensive is unlikely to be useful, it was removed.

return: array

getFinalPossibleErrors()   X-Ref

return: array

parseErrors( $errors )   X-Ref

return: array



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1