MediaWiki  1.28.1
ApiParamInfo.php
Go to the documentation of this file.
1 <?php
30 class ApiParamInfo extends ApiBase {
31 
32  private $helpFormat;
33  private $context;
34 
35  public function __construct( ApiMain $main, $action ) {
36  parent::__construct( $main, $action );
37  }
38 
39  public function execute() {
40  // Get parameters
41  $params = $this->extractRequestParams();
42 
43  $this->helpFormat = $params['helpformat'];
44  $this->context = new RequestContext;
45  $this->context->setUser( new User ); // anon to avoid caching issues
46  $this->context->setLanguage( $this->getMain()->getLanguage() );
47 
48  if ( is_array( $params['modules'] ) ) {
49  $modules = [];
50  foreach ( $params['modules'] as $path ) {
51  if ( $path === '*' || $path === '**' ) {
52  $path = "main+$path";
53  }
54  if ( substr( $path, -2 ) === '+*' || substr( $path, -2 ) === ' *' ) {
55  $submodules = true;
56  $path = substr( $path, 0, -2 );
57  $recursive = false;
58  } elseif ( substr( $path, -3 ) === '+**' || substr( $path, -3 ) === ' **' ) {
59  $submodules = true;
60  $path = substr( $path, 0, -3 );
61  $recursive = true;
62  } else {
63  $submodules = false;
64  }
65 
66  if ( $submodules ) {
67  try {
68  $module = $this->getModuleFromPath( $path );
69  } catch ( UsageException $ex ) {
70  $this->setWarning( $ex->getMessage() );
71  }
72  $submodules = $this->listAllSubmodules( $module, $recursive );
73  if ( $submodules ) {
74  $modules = array_merge( $modules, $submodules );
75  } else {
76  $this->setWarning( "Module $path has no submodules" );
77  }
78  } else {
79  $modules[] = $path;
80  }
81  }
82  } else {
83  $modules = [];
84  }
85 
86  if ( is_array( $params['querymodules'] ) ) {
87  $queryModules = $params['querymodules'];
88  foreach ( $queryModules as $m ) {
89  $modules[] = 'query+' . $m;
90  }
91  } else {
92  $queryModules = [];
93  }
94 
95  if ( is_array( $params['formatmodules'] ) ) {
96  $formatModules = $params['formatmodules'];
97  foreach ( $formatModules as $m ) {
98  $modules[] = $m;
99  }
100  } else {
101  $formatModules = [];
102  }
103 
104  $modules = array_unique( $modules );
105 
106  $res = [];
107 
108  foreach ( $modules as $m ) {
109  try {
110  $module = $this->getModuleFromPath( $m );
111  } catch ( UsageException $ex ) {
112  $this->setWarning( $ex->getMessage() );
113  continue;
114  }
115  $key = 'modules';
116 
117  // Back compat
118  $isBCQuery = false;
119  if ( $module->getParent() && $module->getParent()->getModuleName() == 'query' &&
120  in_array( $module->getModuleName(), $queryModules )
121  ) {
122  $isBCQuery = true;
123  $key = 'querymodules';
124  }
125  if ( in_array( $module->getModuleName(), $formatModules ) ) {
126  $key = 'formatmodules';
127  }
128 
129  $item = $this->getModuleInfo( $module );
130  if ( $isBCQuery ) {
131  $item['querytype'] = $item['group'];
132  }
133  $res[$key][] = $item;
134  }
135 
136  $result = $this->getResult();
137  $result->addValue( [ $this->getModuleName() ], 'helpformat', $this->helpFormat );
138 
139  foreach ( $res as $key => $stuff ) {
140  ApiResult::setIndexedTagName( $res[$key], 'module' );
141  }
142 
143  if ( $params['mainmodule'] ) {
144  $res['mainmodule'] = $this->getModuleInfo( $this->getMain() );
145  }
146 
147  if ( $params['pagesetmodule'] ) {
148  $pageSet = new ApiPageSet( $this->getMain()->getModuleManager()->getModule( 'query' ) );
149  $res['pagesetmodule'] = $this->getModuleInfo( $pageSet );
150  unset( $res['pagesetmodule']['name'] );
151  unset( $res['pagesetmodule']['path'] );
152  unset( $res['pagesetmodule']['group'] );
153  }
154 
155  $result->addValue( null, $this->getModuleName(), $res );
156  }
157 
164  private function listAllSubmodules( ApiBase $module, $recursive ) {
165  $manager = $module->getModuleManager();
166  if ( $manager ) {
167  $paths = [];
168  $names = $manager->getNames();
169  sort( $names );
170  foreach ( $names as $name ) {
171  $submodule = $manager->getModule( $name );
172  $paths[] = $submodule->getModulePath();
173  if ( $recursive && $submodule->getModuleManager() ) {
174  $paths = array_merge( $paths, $this->listAllSubmodules( $submodule, $recursive ) );
175  }
176  }
177  }
178  return $paths;
179  }
180 
187  protected function formatHelpMessages( array &$res, $key, array $msgs, $joinLists = false ) {
188  switch ( $this->helpFormat ) {
189  case 'none':
190  break;
191 
192  case 'wikitext':
193  $ret = [];
194  foreach ( $msgs as $m ) {
195  $ret[] = $m->setContext( $this->context )->text();
196  }
197  $res[$key] = implode( "\n\n", $ret );
198  if ( $joinLists ) {
199  $res[$key] = preg_replace( '!^(([*#:;])[^\n]*)\n\n(?=\2)!m', "$1\n", $res[$key] );
200  }
201  break;
202 
203  case 'html':
204  $ret = [];
205  foreach ( $msgs as $m ) {
206  $ret[] = $m->setContext( $this->context )->parseAsBlock();
207  }
208  $ret = implode( "\n", $ret );
209  if ( $joinLists ) {
210  $ret = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $ret );
211  }
212  $res[$key] = Parser::stripOuterParagraph( $ret );
213  break;
214 
215  case 'raw':
216  $res[$key] = [];
217  foreach ( $msgs as $m ) {
218  $a = [
219  'key' => $m->getKey(),
220  'params' => $m->getParams(),
221  ];
222  ApiResult::setIndexedTagName( $a['params'], 'param' );
223  if ( $m instanceof ApiHelpParamValueMessage ) {
224  $a['forvalue'] = $m->getParamValue();
225  }
226  $res[$key][] = $a;
227  }
228  ApiResult::setIndexedTagName( $res[$key], 'msg' );
229  break;
230  }
231  }
232 
237  private function getModuleInfo( $module ) {
238  $ret = [];
239  $path = $module->getModulePath();
240 
241  $ret['name'] = $module->getModuleName();
242  $ret['classname'] = get_class( $module );
243  $ret['path'] = $path;
244  if ( !$module->isMain() ) {
245  $ret['group'] = $module->getParent()->getModuleManager()->getModuleGroup(
246  $module->getModuleName()
247  );
248  }
249  $ret['prefix'] = $module->getModulePrefix();
250 
251  $sourceInfo = $module->getModuleSourceInfo();
252  if ( $sourceInfo ) {
253  $ret['source'] = $sourceInfo['name'];
254  if ( isset( $sourceInfo['namemsg'] ) ) {
255  $ret['sourcename'] = $this->context->msg( $sourceInfo['namemsg'] )->text();
256  } else {
257  $ret['sourcename'] = $ret['source'];
258  }
259 
260  $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] )->getFullURL();
261  if ( isset( $sourceInfo['license-name'] ) ) {
262  $ret['licensetag'] = $sourceInfo['license-name'];
263  $ret['licenselink'] = (string)$link;
264  } elseif ( SpecialVersion::getExtLicenseFileName( dirname( $sourceInfo['path'] ) ) ) {
265  $ret['licenselink'] = (string)$link;
266  }
267  }
268 
269  $this->formatHelpMessages( $ret, 'description', $module->getFinalDescription() );
270 
271  foreach ( $module->getHelpFlags() as $flag ) {
272  $ret[$flag] = true;
273  }
274 
275  $ret['helpurls'] = (array)$module->getHelpUrls();
276  if ( isset( $ret['helpurls'][0] ) && $ret['helpurls'][0] === false ) {
277  $ret['helpurls'] = [];
278  }
279  ApiResult::setIndexedTagName( $ret['helpurls'], 'helpurl' );
280 
281  if ( $this->helpFormat !== 'none' ) {
282  $ret['examples'] = [];
283  $examples = $module->getExamplesMessages();
284  foreach ( $examples as $qs => $msg ) {
285  $item = [
286  'query' => $qs
287  ];
288  $msg = ApiBase::makeMessage( $msg, $this->context, [
289  $module->getModulePrefix(),
290  $module->getModuleName(),
291  $module->getModulePath()
292  ] );
293  $this->formatHelpMessages( $item, 'description', [ $msg ] );
294  if ( isset( $item['description'] ) ) {
295  if ( is_array( $item['description'] ) ) {
296  $item['description'] = $item['description'][0];
297  } else {
298  ApiResult::setSubelementsList( $item, 'description' );
299  }
300  }
301  $ret['examples'][] = $item;
302  }
303  ApiResult::setIndexedTagName( $ret['examples'], 'example' );
304  }
305 
306  $ret['parameters'] = [];
307  $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
308  $paramDesc = $module->getFinalParamDescription();
309  foreach ( $params as $name => $settings ) {
310  if ( !is_array( $settings ) ) {
311  $settings = [ ApiBase::PARAM_DFLT => $settings ];
312  }
313 
314  $item = [
315  'name' => $name
316  ];
317  if ( isset( $paramDesc[$name] ) ) {
318  $this->formatHelpMessages( $item, 'description', $paramDesc[$name], true );
319  }
320 
321  $item['required'] = !empty( $settings[ApiBase::PARAM_REQUIRED] );
322 
323  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
324  $item['deprecated'] = true;
325  }
326 
327  if ( $name === 'token' && $module->needsToken() ) {
328  $item['tokentype'] = $module->needsToken();
329  }
330 
331  if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
332  $dflt = isset( $settings[ApiBase::PARAM_DFLT] )
333  ? $settings[ApiBase::PARAM_DFLT]
334  : null;
335  if ( is_bool( $dflt ) ) {
336  $settings[ApiBase::PARAM_TYPE] = 'boolean';
337  } elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
338  $settings[ApiBase::PARAM_TYPE] = 'string';
339  } elseif ( is_int( $dflt ) ) {
340  $settings[ApiBase::PARAM_TYPE] = 'integer';
341  }
342  }
343 
344  if ( isset( $settings[ApiBase::PARAM_DFLT] ) ) {
345  switch ( $settings[ApiBase::PARAM_TYPE] ) {
346  case 'boolean':
347  $item['default'] = (bool)$settings[ApiBase::PARAM_DFLT];
348  break;
349  case 'string':
350  case 'text':
351  case 'password':
352  $item['default'] = strval( $settings[ApiBase::PARAM_DFLT] );
353  break;
354  case 'integer':
355  case 'limit':
356  $item['default'] = intval( $settings[ApiBase::PARAM_DFLT] );
357  break;
358  case 'timestamp':
359  $item['default'] = wfTimestamp( TS_ISO_8601, $settings[ApiBase::PARAM_DFLT] );
360  break;
361  default:
362  $item['default'] = $settings[ApiBase::PARAM_DFLT];
363  break;
364  }
365  }
366 
367  $item['multi'] = !empty( $settings[ApiBase::PARAM_ISMULTI] );
368  if ( $item['multi'] ) {
369  $item['limit'] = $this->getMain()->canApiHighLimits() ?
372  $item['lowlimit'] = ApiBase::LIMIT_SML1;
373  $item['highlimit'] = ApiBase::LIMIT_SML2;
374  }
375 
376  if ( !empty( $settings[ApiBase::PARAM_ALLOW_DUPLICATES] ) ) {
377  $item['allowsduplicates'] = true;
378  }
379 
380  if ( isset( $settings[ApiBase::PARAM_TYPE] ) ) {
381  if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
382  if ( isset( $settings[ApiBase::PARAM_SUBMODULE_MAP] ) ) {
383  ksort( $settings[ApiBase::PARAM_SUBMODULE_MAP] );
384  $item['type'] = array_keys( $settings[ApiBase::PARAM_SUBMODULE_MAP] );
385  $item['submodules'] = $settings[ApiBase::PARAM_SUBMODULE_MAP];
386  } else {
387  $item['type'] = $module->getModuleManager()->getNames( $name );
388  sort( $item['type'] );
389  $prefix = $module->isMain()
390  ? '' : ( $module->getModulePath() . '+' );
391  $item['submodules'] = [];
392  foreach ( $item['type'] as $v ) {
393  $item['submodules'][$v] = $prefix . $v;
394  }
395  }
396  if ( isset( $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX] ) ) {
397  $item['submoduleparamprefix'] = $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX];
398  }
399  } elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
400  $item['type'] = ChangeTags::listExplicitlyDefinedTags();
401  } else {
402  $item['type'] = $settings[ApiBase::PARAM_TYPE];
403  }
404  if ( is_array( $item['type'] ) ) {
405  // To prevent sparse arrays from being serialized to JSON as objects
406  $item['type'] = array_values( $item['type'] );
407  ApiResult::setIndexedTagName( $item['type'], 't' );
408  }
409  }
410  if ( isset( $settings[ApiBase::PARAM_MAX] ) ) {
411  $item['max'] = $settings[ApiBase::PARAM_MAX];
412  }
413  if ( isset( $settings[ApiBase::PARAM_MAX2] ) ) {
414  $item['highmax'] = $settings[ApiBase::PARAM_MAX2];
415  }
416  if ( isset( $settings[ApiBase::PARAM_MIN] ) ) {
417  $item['min'] = $settings[ApiBase::PARAM_MIN];
418  }
419  if ( !empty( $settings[ApiBase::PARAM_RANGE_ENFORCE] ) ) {
420  $item['enforcerange'] = true;
421  }
422 
423  if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
424  $item['info'] = [];
425  foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
426  $tag = array_shift( $i );
427  $info = [
428  'name' => $tag,
429  ];
430  if ( count( $i ) ) {
431  $info['values'] = $i;
432  ApiResult::setIndexedTagName( $info['values'], 'v' );
433  }
434  $this->formatHelpMessages( $info, 'text', [
435  $this->context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
436  ->numParams( count( $i ) )
437  ->params( $this->context->getLanguage()->commaList( $i ) )
438  ->params( $module->getModulePrefix() )
439  ] );
440  ApiResult::setSubelementsList( $info, 'text' );
441  $item['info'][] = $info;
442  }
443  ApiResult::setIndexedTagName( $item['info'], 'i' );
444  }
445 
446  $ret['parameters'][] = $item;
447  }
448  ApiResult::setIndexedTagName( $ret['parameters'], 'param' );
449 
450  $dynamicParams = $module->dynamicParameterDocumentation();
451  if ( $dynamicParams !== null ) {
452  if ( $this->helpFormat === 'none' ) {
453  $ret['dynamicparameters'] = true;
454  } else {
455  $dynamicParams = ApiBase::makeMessage( $dynamicParams, $this->context, [
456  $module->getModulePrefix(),
457  $module->getModuleName(),
458  $module->getModulePath()
459  ] );
460  $this->formatHelpMessages( $ret, 'dynamicparameters', [ $dynamicParams ] );
461  }
462  }
463 
464  return $ret;
465  }
466 
467  public function isReadMode() {
468  return false;
469  }
470 
471  public function getAllowedParams() {
472  // back compat
473  $querymodules = $this->getMain()->getModuleManager()
474  ->getModule( 'query' )->getModuleManager()->getNames();
475  sort( $querymodules );
476  $formatmodules = $this->getMain()->getModuleManager()->getNames( 'format' );
477  sort( $formatmodules );
478 
479  return [
480  'modules' => [
481  ApiBase::PARAM_ISMULTI => true,
482  ],
483  'helpformat' => [
484  ApiBase::PARAM_DFLT => 'none',
485  ApiBase::PARAM_TYPE => [ 'html', 'wikitext', 'raw', 'none' ],
486  ],
487 
488  'querymodules' => [
490  ApiBase::PARAM_ISMULTI => true,
491  ApiBase::PARAM_TYPE => $querymodules,
492  ],
493  'mainmodule' => [
495  ],
496  'pagesetmodule' => [
498  ],
499  'formatmodules' => [
501  ApiBase::PARAM_ISMULTI => true,
502  ApiBase::PARAM_TYPE => $formatmodules,
503  ]
504  ];
505  }
506 
507  protected function getExamplesMessages() {
508  return [
509  'action=paraminfo&modules=parse|phpfm|query%2Ballpages|query%2Bsiteinfo'
510  => 'apihelp-paraminfo-example-1',
511  'action=paraminfo&modules=query%2B*'
512  => 'apihelp-paraminfo-example-2',
513  ];
514  }
515 
516  public function getHelpUrls() {
517  return 'https://www.mediawiki.org/wiki/API:Parameter_information';
518  }
519 }
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
Definition: ApiBase.php:88
getModuleInfo($module)
the array() calling protocol came about after MediaWiki 1.4rc1.
getResult()
Get the result object.
Definition: ApiBase.php:584
getLanguage()
Get the Language object.
Message subclass that prepends wikitext for API help.
Group all the pieces relevant to the context of a request into one instance.
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:41
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
Definition: hooks.txt:1936
__construct(ApiMain $main, $action)
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...
Definition: SpecialPage.php:82
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:50
getMain()
Get the main module.
Definition: ApiBase.php:480
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
Definition: ApiBase.php:197
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:91
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition: ApiBase.php:112
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:142
extractRequestParams($parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user...
Definition: ApiBase.php:685
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
Definition: hooks.txt:177
static makeMessage($msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1522
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
Definition: defines.php:28
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:618
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 '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. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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:Associative array mapping language codes to prefixed links of the form"language:title".&$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!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
Definition: hooks.txt:1934
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2889
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
$modules
const PARAM_SUBMODULE_PARAM_PREFIX
(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBa...
Definition: ApiBase.php:172
static stripOuterParagraph($html)
Strip outer.
Definition: Parser.php:6031
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
Definition: ApiBase.php:118
$res
Definition: database.txt:21
formatHelpMessages(array &$res, $key, array $msgs, $joinLists=false)
const LIMIT_SML2
Slow query, apihighlimits limit.
Definition: ApiBase.php:190
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
Definition: ApiBase.php:165
$params
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:43
static getExtLicenseFileName($extDir)
Obtains the full path of an extensions copying or license file if one exists.
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:464
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
Definition: hooks.txt:1007
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right, for PARAM_TYPE 'limit'.
Definition: ApiBase.php:97
setWarning($warning)
Set warning section for this module.
Definition: ApiBase.php:1554
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
Definition: distributors.txt:9
static setSubelementsList(array &$arr, $names)
Causes the elements with the specified names to be output as subelements rather than attributes...
Definition: ApiResult.php:567
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:188
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
Definition: ApiBase.php:254
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
Definition: injection.txt:35
setUser(User $u)
Set the User object.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:53
This abstract class implements many basic API functions, and is the base of all API classes...
Definition: ApiBase.php:39
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:106
listAllSubmodules(ApiBase $module, $recursive)
List all submodules of a module.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:100
const PARAM_ALLOW_DUPLICATES
(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
Definition: ApiBase.php:103
getModuleFromPath($path)
Get a module from its module path.
Definition: ApiBase.php:546
This exception will be thrown when dieUsage is called to stop module execution.
Definition: ApiMain.php:1860
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:300