Go to the documentation of this file.
32 parent::__construct( $main, $action );
39 $this->helpFormat =
$params[
'helpformat'];
44 if ( is_array(
$params[
'modules'] ) ) {
50 if ( substr(
$path, -2 ) ===
'+*' || substr(
$path, -2 ) ===
' *' ) {
54 } elseif ( substr(
$path, -3 ) ===
'+**' || substr(
$path, -3 ) ===
' **' ) {
75 $this->
addWarning( [
'apierror-badmodule-nosubmodules', $path ],
'badmodule' );
85 if ( is_array(
$params[
'querymodules'] ) ) {
86 $queryModules =
$params[
'querymodules'];
87 foreach ( $queryModules
as $m ) {
94 if ( is_array(
$params[
'formatmodules'] ) ) {
95 $formatModules =
$params[
'formatmodules'];
96 foreach ( $formatModules
as $m ) {
120 if ( $module->getParent() && $module->getParent()->getModuleName() ==
'query' &&
121 in_array( $module->getModuleName(), $queryModules )
124 $key =
'querymodules';
126 if ( in_array( $module->getModuleName(), $formatModules ) ) {
127 $key =
'formatmodules';
132 $item[
'querytype'] = $item[
'group'];
134 $res[$key][] = $item;
140 foreach (
$res as $key => $stuff ) {
148 if (
$params[
'pagesetmodule'] ) {
151 unset(
$res[
'pagesetmodule'][
'name'] );
152 unset(
$res[
'pagesetmodule'][
'path'] );
153 unset(
$res[
'pagesetmodule'][
'group'] );
169 $names = $manager->getNames();
172 $submodule = $manager->getModule(
$name );
173 $paths[] = $submodule->getModulePath();
174 if ( $recursive && $submodule->getModuleManager() ) {
175 $paths = array_merge( $paths, $this->
listAllSubmodules( $submodule, $recursive ) );
189 switch ( $this->helpFormat ) {
195 foreach ( $msgs
as $m ) {
196 $ret[] = $m->setContext( $this->context )->text();
198 $res[$key] = implode(
"\n\n",
$ret );
200 $res[$key] = preg_replace(
'!^(([*#:;])[^\n]*)\n\n(?=\2)!m',
"$1\n",
$res[$key] );
206 foreach ( $msgs
as $m ) {
207 $ret[] = $m->setContext( $this->context )->parseAsBlock();
211 $ret = preg_replace(
'!\s*</([oud]l)>\s*<\1>\s*!',
"\n",
$ret );
213 $res[$key] = Parser::stripOuterParagraph(
$ret );
218 foreach ( $msgs
as $m ) {
220 'key' => $m->getKey(),
221 'params' => $m->getParams(),
225 $a[
'forvalue'] = $m->getParamValue();
240 $path = $module->getModulePath();
242 $ret[
'name'] = $module->getModuleName();
243 $ret[
'classname'] = get_class( $module );
245 if ( !$module->isMain() ) {
246 $ret[
'group'] = $module->getParent()->getModuleManager()->getModuleGroup(
247 $module->getModuleName()
250 $ret[
'prefix'] = $module->getModulePrefix();
252 $sourceInfo = $module->getModuleSourceInfo();
254 $ret[
'source'] = $sourceInfo[
'name'];
255 if ( isset( $sourceInfo[
'namemsg'] ) ) {
256 $ret[
'sourcename'] = $this->context->msg( $sourceInfo[
'namemsg'] )->text();
258 $ret[
'sourcename'] =
$ret[
'source'];
262 if ( isset( $sourceInfo[
'license-name'] ) ) {
263 $ret[
'licensetag'] = $sourceInfo[
'license-name'];
272 foreach ( $module->getHelpFlags()
as $flag ) {
276 $ret[
'helpurls'] = (
array)$module->getHelpUrls();
277 if ( isset(
$ret[
'helpurls'][0] ) &&
$ret[
'helpurls'][0] ===
false ) {
278 $ret[
'helpurls'] = [];
282 if ( $this->helpFormat !==
'none' ) {
283 $ret[
'examples'] = [];
284 $examples = $module->getExamplesMessages();
285 foreach ( $examples
as $qs => $msg ) {
290 $module->getModulePrefix(),
291 $module->getModuleName(),
292 $module->getModulePath()
295 if ( isset( $item[
'description'] ) ) {
296 if ( is_array( $item[
'description'] ) ) {
297 $item[
'description'] = $item[
'description'][0];
302 $ret[
'examples'][] = $item;
307 $ret[
'parameters'] = [];
308 $ret[
'templatedparameters'] = [];
310 $paramDesc = $module->getFinalParamDescription();
313 if ( !is_array( $settings ) ) {
327 if ( isset( $paramDesc[
$name] ) ) {
334 $item[
'deprecated'] =
true;
337 if (
$name ===
'token' && $module->needsToken() ) {
338 $item[
'tokentype'] = $module->needsToken();
343 if ( is_bool( $dflt ) ) {
345 } elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
347 } elseif ( is_int( $dflt ) ) {
376 if ( $item[
'multi'] ) {
383 $item[
'limit'] = $this->
getMain()->canApiHighLimits()
389 $item[
'allowsduplicates'] =
true;
399 $item[
'type'] = $module->getModuleManager()->getNames(
$name );
400 sort( $item[
'type'] );
401 $prefix = $module->isMain()
402 ?
'' : ( $module->getModulePath() .
'+' );
403 $item[
'submodules'] = [];
404 foreach ( $item[
'type']
as $v ) {
405 $item[
'submodules'][$v] = $prefix . $v;
412 $deprecatedSubmodules = [];
413 foreach ( $item[
'submodules']
as $v => $submodulePath ) {
416 if ( $submod && $submod->isDeprecated() ) {
417 $deprecatedSubmodules[] = $v;
423 if ( $deprecatedSubmodules ) {
424 $item[
'type'] = array_merge(
425 array_diff( $item[
'type'], $deprecatedSubmodules ),
426 $deprecatedSubmodules
428 $item[
'deprecatedvalues'] = $deprecatedSubmodules;
435 if ( is_array( $item[
'type'] ) ) {
437 $item[
'type'] = array_values( $item[
'type'] );
442 if ( $item[
'type'] ===
'namespace' ) {
449 if ( $allowAll && $item[
'multi'] &&
450 ( is_array( $item[
'type'] ) || $item[
'type'] ===
'namespace' ) ) {
451 $item[
'allspecifier'] = $allSpecifier;
454 if ( $item[
'type'] ===
'namespace' &&
473 $item[
'enforcerange'] =
true;
475 if ( isset( $settings[self::PARAM_MAX_BYTES] ) ) {
478 if ( isset( $settings[self::PARAM_MAX_CHARS] ) ) {
483 if ( is_array( $item[
'type'] ) ) {
484 $deprecatedValues = array_intersect( $deprecatedValues, $item[
'type'] );
486 if ( $deprecatedValues ) {
487 $item[
'deprecatedvalues'] = array_values( $deprecatedValues );
495 $tag = array_shift( $i );
500 $info[
'values'] = $i;
504 $this->context->msg(
"apihelp-{$path}-paraminfo-{$tag}" )
505 ->numParams(
count( $i ) )
506 ->params( $this->context->getLanguage()->commaList( $i ) )
507 ->params( $module->getModulePrefix() )
510 $item[
'info'][] = $info;
516 $ret[$key][] = $item;
521 $dynamicParams = $module->dynamicParameterDocumentation();
522 if ( $dynamicParams !==
null ) {
523 if ( $this->helpFormat ===
'none' ) {
524 $ret[
'dynamicparameters'] =
true;
527 $module->getModulePrefix(),
528 $module->getModuleName(),
529 $module->getModulePath()
544 $querymodules = $this->
getMain()->getModuleManager()
545 ->getModule(
'query' )->getModuleManager()->getNames();
546 sort( $querymodules );
547 $formatmodules = $this->
getMain()->getModuleManager()->getNames(
'format' );
548 sort( $formatmodules );
580 'action=paraminfo&modules=parse|phpfm|query%2Ballpages|query%2Bsiteinfo'
581 =>
'apihelp-paraminfo-example-1',
582 'action=paraminfo&modules=query%2B*'
583 =>
'apihelp-paraminfo-example-2',
588 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parameter_information';
getStatusValue()
Fetch the error status.
This is the main API class, used for both external and internal processing.
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
Exception used to abort API execution with an error.
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
const PARAM_REQUIRED
(boolean) Is the parameter required?
listAllSubmodules(ApiBase $module, $recursive)
List all submodules of a module.
const PARAM_ALL
(boolean|string) When PARAM_TYPE has a defined set of values and PARAM_ISMULTI is true,...
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
__construct(ApiMain $main, $action)
const PARAM_ISMULTI_LIMIT1
(integer) Maximum number of values, for normal users.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
const PARAM_ALLOW_DUPLICATES
(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
This class contains a list of pages that the client has requested.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
This abstract class implements many basic API functions, and is the base of all API classes.
getModuleFromPath( $path)
Get a module from its module path.
const PARAM_ISMULTI_LIMIT2
(integer) Maximum number of values, for users with the apihighimits right.
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Group all the pieces relevant to the context of a request into one instance.
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
static getExtLicenseFileName( $extDir)
Obtains the full path of an extensions copying or license file if one exists.
Allows to change the fields on the form that will be generated $name
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
const LIMIT_SML2
Slow query, apihighlimits limit.
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
isReadMode()
Indicates whether this module requires read rights.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
formatHelpMessages(array &$res, $key, array $msgs, $joinLists=false)
const PARAM_TEMPLATE_VARS
(array) Indicate that this is a templated parameter, and specify replacements.
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
getExamplesMessages()
Returns usage examples for this module.
getMain()
Get the main module.
const PARAM_MAX_CHARS
(integer) Maximum length of a string in characters (unicode codepoints).
const PARAM_SUBMODULE_PARAM_PREFIX
(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBa...
const PARAM_MAX_BYTES
(integer) Maximum length of a string in bytes (in UTF-8 encoding).
Message subclass that prepends wikitext for API help.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static setSubelementsList(array &$arr, $names)
Causes the elements with the specified names to be output as subelements rather than attributes.
getHelpUrls()
Return links to more detailed help pages about the module.
const LIMIT_SML1
Slow query, standard limit.