MediaWiki  1.29.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 ( ApiUsageException $ex ) {
70  foreach ( $ex->getStatusValue()->getErrors() as $error ) {
71  $this->addWarning( $error );
72  }
73  continue;
74  }
75  $submodules = $this->listAllSubmodules( $module, $recursive );
76  if ( $submodules ) {
77  $modules = array_merge( $modules, $submodules );
78  } else {
79  $this->addWarning( [ 'apierror-badmodule-nosubmodules', $path ], 'badmodule' );
80  }
81  } else {
82  $modules[] = $path;
83  }
84  }
85  } else {
86  $modules = [];
87  }
88 
89  if ( is_array( $params['querymodules'] ) ) {
90  $queryModules = $params['querymodules'];
91  foreach ( $queryModules as $m ) {
92  $modules[] = 'query+' . $m;
93  }
94  } else {
95  $queryModules = [];
96  }
97 
98  if ( is_array( $params['formatmodules'] ) ) {
99  $formatModules = $params['formatmodules'];
100  foreach ( $formatModules as $m ) {
101  $modules[] = $m;
102  }
103  } else {
104  $formatModules = [];
105  }
106 
107  $modules = array_unique( $modules );
108 
109  $res = [];
110 
111  foreach ( $modules as $m ) {
112  try {
113  $module = $this->getModuleFromPath( $m );
114  } catch ( ApiUsageException $ex ) {
115  foreach ( $ex->getStatusValue()->getErrors() as $error ) {
116  $this->addWarning( $error );
117  }
118  continue;
119  }
120  $key = 'modules';
121 
122  // Back compat
123  $isBCQuery = false;
124  if ( $module->getParent() && $module->getParent()->getModuleName() == 'query' &&
125  in_array( $module->getModuleName(), $queryModules )
126  ) {
127  $isBCQuery = true;
128  $key = 'querymodules';
129  }
130  if ( in_array( $module->getModuleName(), $formatModules ) ) {
131  $key = 'formatmodules';
132  }
133 
134  $item = $this->getModuleInfo( $module );
135  if ( $isBCQuery ) {
136  $item['querytype'] = $item['group'];
137  }
138  $res[$key][] = $item;
139  }
140 
141  $result = $this->getResult();
142  $result->addValue( [ $this->getModuleName() ], 'helpformat', $this->helpFormat );
143 
144  foreach ( $res as $key => $stuff ) {
145  ApiResult::setIndexedTagName( $res[$key], 'module' );
146  }
147 
148  if ( $params['mainmodule'] ) {
149  $res['mainmodule'] = $this->getModuleInfo( $this->getMain() );
150  }
151 
152  if ( $params['pagesetmodule'] ) {
153  $pageSet = new ApiPageSet( $this->getMain()->getModuleManager()->getModule( 'query' ) );
154  $res['pagesetmodule'] = $this->getModuleInfo( $pageSet );
155  unset( $res['pagesetmodule']['name'] );
156  unset( $res['pagesetmodule']['path'] );
157  unset( $res['pagesetmodule']['group'] );
158  }
159 
160  $result->addValue( null, $this->getModuleName(), $res );
161  }
162 
169  private function listAllSubmodules( ApiBase $module, $recursive ) {
170  $manager = $module->getModuleManager();
171  if ( $manager ) {
172  $paths = [];
173  $names = $manager->getNames();
174  sort( $names );
175  foreach ( $names as $name ) {
176  $submodule = $manager->getModule( $name );
177  $paths[] = $submodule->getModulePath();
178  if ( $recursive && $submodule->getModuleManager() ) {
179  $paths = array_merge( $paths, $this->listAllSubmodules( $submodule, $recursive ) );
180  }
181  }
182  }
183  return $paths;
184  }
185 
192  protected function formatHelpMessages( array &$res, $key, array $msgs, $joinLists = false ) {
193  switch ( $this->helpFormat ) {
194  case 'none':
195  break;
196 
197  case 'wikitext':
198  $ret = [];
199  foreach ( $msgs as $m ) {
200  $ret[] = $m->setContext( $this->context )->text();
201  }
202  $res[$key] = implode( "\n\n", $ret );
203  if ( $joinLists ) {
204  $res[$key] = preg_replace( '!^(([*#:;])[^\n]*)\n\n(?=\2)!m', "$1\n", $res[$key] );
205  }
206  break;
207 
208  case 'html':
209  $ret = [];
210  foreach ( $msgs as $m ) {
211  $ret[] = $m->setContext( $this->context )->parseAsBlock();
212  }
213  $ret = implode( "\n", $ret );
214  if ( $joinLists ) {
215  $ret = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $ret );
216  }
217  $res[$key] = Parser::stripOuterParagraph( $ret );
218  break;
219 
220  case 'raw':
221  $res[$key] = [];
222  foreach ( $msgs as $m ) {
223  $a = [
224  'key' => $m->getKey(),
225  'params' => $m->getParams(),
226  ];
227  ApiResult::setIndexedTagName( $a['params'], 'param' );
228  if ( $m instanceof ApiHelpParamValueMessage ) {
229  $a['forvalue'] = $m->getParamValue();
230  }
231  $res[$key][] = $a;
232  }
233  ApiResult::setIndexedTagName( $res[$key], 'msg' );
234  break;
235  }
236  }
237 
242  private function getModuleInfo( $module ) {
243  $ret = [];
244  $path = $module->getModulePath();
245 
246  $ret['name'] = $module->getModuleName();
247  $ret['classname'] = get_class( $module );
248  $ret['path'] = $path;
249  if ( !$module->isMain() ) {
250  $ret['group'] = $module->getParent()->getModuleManager()->getModuleGroup(
251  $module->getModuleName()
252  );
253  }
254  $ret['prefix'] = $module->getModulePrefix();
255 
256  $sourceInfo = $module->getModuleSourceInfo();
257  if ( $sourceInfo ) {
258  $ret['source'] = $sourceInfo['name'];
259  if ( isset( $sourceInfo['namemsg'] ) ) {
260  $ret['sourcename'] = $this->context->msg( $sourceInfo['namemsg'] )->text();
261  } else {
262  $ret['sourcename'] = $ret['source'];
263  }
264 
265  $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] )->getFullURL();
266  if ( isset( $sourceInfo['license-name'] ) ) {
267  $ret['licensetag'] = $sourceInfo['license-name'];
268  $ret['licenselink'] = (string)$link;
269  } elseif ( SpecialVersion::getExtLicenseFileName( dirname( $sourceInfo['path'] ) ) ) {
270  $ret['licenselink'] = (string)$link;
271  }
272  }
273 
274  $this->formatHelpMessages( $ret, 'description', $module->getFinalDescription() );
275 
276  foreach ( $module->getHelpFlags() as $flag ) {
277  $ret[$flag] = true;
278  }
279 
280  $ret['helpurls'] = (array)$module->getHelpUrls();
281  if ( isset( $ret['helpurls'][0] ) && $ret['helpurls'][0] === false ) {
282  $ret['helpurls'] = [];
283  }
284  ApiResult::setIndexedTagName( $ret['helpurls'], 'helpurl' );
285 
286  if ( $this->helpFormat !== 'none' ) {
287  $ret['examples'] = [];
288  $examples = $module->getExamplesMessages();
289  foreach ( $examples as $qs => $msg ) {
290  $item = [
291  'query' => $qs
292  ];
293  $msg = ApiBase::makeMessage( $msg, $this->context, [
294  $module->getModulePrefix(),
295  $module->getModuleName(),
296  $module->getModulePath()
297  ] );
298  $this->formatHelpMessages( $item, 'description', [ $msg ] );
299  if ( isset( $item['description'] ) ) {
300  if ( is_array( $item['description'] ) ) {
301  $item['description'] = $item['description'][0];
302  } else {
303  ApiResult::setSubelementsList( $item, 'description' );
304  }
305  }
306  $ret['examples'][] = $item;
307  }
308  ApiResult::setIndexedTagName( $ret['examples'], 'example' );
309  }
310 
311  $ret['parameters'] = [];
312  $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
313  $paramDesc = $module->getFinalParamDescription();
314  foreach ( $params as $name => $settings ) {
315  if ( !is_array( $settings ) ) {
316  $settings = [ ApiBase::PARAM_DFLT => $settings ];
317  }
318 
319  $item = [
320  'name' => $name
321  ];
322  if ( isset( $paramDesc[$name] ) ) {
323  $this->formatHelpMessages( $item, 'description', $paramDesc[$name], true );
324  }
325 
326  $item['required'] = !empty( $settings[ApiBase::PARAM_REQUIRED] );
327 
328  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
329  $item['deprecated'] = true;
330  }
331 
332  if ( $name === 'token' && $module->needsToken() ) {
333  $item['tokentype'] = $module->needsToken();
334  }
335 
336  if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
337  $dflt = isset( $settings[ApiBase::PARAM_DFLT] )
338  ? $settings[ApiBase::PARAM_DFLT]
339  : null;
340  if ( is_bool( $dflt ) ) {
341  $settings[ApiBase::PARAM_TYPE] = 'boolean';
342  } elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
343  $settings[ApiBase::PARAM_TYPE] = 'string';
344  } elseif ( is_int( $dflt ) ) {
345  $settings[ApiBase::PARAM_TYPE] = 'integer';
346  }
347  }
348 
349  if ( isset( $settings[ApiBase::PARAM_DFLT] ) ) {
350  switch ( $settings[ApiBase::PARAM_TYPE] ) {
351  case 'boolean':
352  $item['default'] = (bool)$settings[ApiBase::PARAM_DFLT];
353  break;
354  case 'string':
355  case 'text':
356  case 'password':
357  $item['default'] = strval( $settings[ApiBase::PARAM_DFLT] );
358  break;
359  case 'integer':
360  case 'limit':
361  $item['default'] = intval( $settings[ApiBase::PARAM_DFLT] );
362  break;
363  case 'timestamp':
364  $item['default'] = wfTimestamp( TS_ISO_8601, $settings[ApiBase::PARAM_DFLT] );
365  break;
366  default:
367  $item['default'] = $settings[ApiBase::PARAM_DFLT];
368  break;
369  }
370  }
371 
372  $item['multi'] = !empty( $settings[ApiBase::PARAM_ISMULTI] );
373  if ( $item['multi'] ) {
374  $item['limit'] = $this->getMain()->canApiHighLimits() ?
377  $item['lowlimit'] = ApiBase::LIMIT_SML1;
378  $item['highlimit'] = ApiBase::LIMIT_SML2;
379  }
380 
381  if ( !empty( $settings[ApiBase::PARAM_ALLOW_DUPLICATES] ) ) {
382  $item['allowsduplicates'] = true;
383  }
384 
385  if ( isset( $settings[ApiBase::PARAM_TYPE] ) ) {
386  if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
387  if ( isset( $settings[ApiBase::PARAM_SUBMODULE_MAP] ) ) {
388  ksort( $settings[ApiBase::PARAM_SUBMODULE_MAP] );
389  $item['type'] = array_keys( $settings[ApiBase::PARAM_SUBMODULE_MAP] );
390  $item['submodules'] = $settings[ApiBase::PARAM_SUBMODULE_MAP];
391  } else {
392  $item['type'] = $module->getModuleManager()->getNames( $name );
393  sort( $item['type'] );
394  $prefix = $module->isMain()
395  ? '' : ( $module->getModulePath() . '+' );
396  $item['submodules'] = [];
397  foreach ( $item['type'] as $v ) {
398  $item['submodules'][$v] = $prefix . $v;
399  }
400  }
401  if ( isset( $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX] ) ) {
402  $item['submoduleparamprefix'] = $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX];
403  }
404  } elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
405  $item['type'] = ChangeTags::listExplicitlyDefinedTags();
406  } else {
407  $item['type'] = $settings[ApiBase::PARAM_TYPE];
408  }
409  if ( is_array( $item['type'] ) ) {
410  // To prevent sparse arrays from being serialized to JSON as objects
411  $item['type'] = array_values( $item['type'] );
412  ApiResult::setIndexedTagName( $item['type'], 't' );
413  }
414 
415  // Add 'allspecifier' if applicable
416  if ( $item['type'] === 'namespace' ) {
417  $allowAll = true;
418  $allSpecifier = ApiBase::ALL_DEFAULT_STRING;
419  } else {
420  $allowAll = isset( $settings[ApiBase::PARAM_ALL] )
421  ? $settings[ApiBase::PARAM_ALL]
422  : false;
423  $allSpecifier = ( is_string( $allowAll ) ? $allowAll : ApiBase::ALL_DEFAULT_STRING );
424  }
425  if ( $allowAll && $item['multi'] &&
426  ( is_array( $item['type'] ) || $item['type'] === 'namespace' ) ) {
427  $item['allspecifier'] = $allSpecifier;
428  }
429 
430  if ( $item['type'] === 'namespace' &&
431  isset( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
432  is_array( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] )
433  ) {
434  $item['extranamespaces'] = $settings[ApiBase::PARAM_EXTRA_NAMESPACES];
435  ApiResult::setArrayType( $item['extranamespaces'], 'array' );
436  ApiResult::setIndexedTagName( $item['extranamespaces'], 'ns' );
437  }
438  }
439  if ( isset( $settings[ApiBase::PARAM_MAX] ) ) {
440  $item['max'] = $settings[ApiBase::PARAM_MAX];
441  }
442  if ( isset( $settings[ApiBase::PARAM_MAX2] ) ) {
443  $item['highmax'] = $settings[ApiBase::PARAM_MAX2];
444  }
445  if ( isset( $settings[ApiBase::PARAM_MIN] ) ) {
446  $item['min'] = $settings[ApiBase::PARAM_MIN];
447  }
448  if ( !empty( $settings[ApiBase::PARAM_RANGE_ENFORCE] ) ) {
449  $item['enforcerange'] = true;
450  }
451 
452  if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
453  $item['info'] = [];
454  foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
455  $tag = array_shift( $i );
456  $info = [
457  'name' => $tag,
458  ];
459  if ( count( $i ) ) {
460  $info['values'] = $i;
461  ApiResult::setIndexedTagName( $info['values'], 'v' );
462  }
463  $this->formatHelpMessages( $info, 'text', [
464  $this->context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
465  ->numParams( count( $i ) )
466  ->params( $this->context->getLanguage()->commaList( $i ) )
467  ->params( $module->getModulePrefix() )
468  ] );
469  ApiResult::setSubelementsList( $info, 'text' );
470  $item['info'][] = $info;
471  }
472  ApiResult::setIndexedTagName( $item['info'], 'i' );
473  }
474 
475  $ret['parameters'][] = $item;
476  }
477  ApiResult::setIndexedTagName( $ret['parameters'], 'param' );
478 
479  $dynamicParams = $module->dynamicParameterDocumentation();
480  if ( $dynamicParams !== null ) {
481  if ( $this->helpFormat === 'none' ) {
482  $ret['dynamicparameters'] = true;
483  } else {
484  $dynamicParams = ApiBase::makeMessage( $dynamicParams, $this->context, [
485  $module->getModulePrefix(),
486  $module->getModuleName(),
487  $module->getModulePath()
488  ] );
489  $this->formatHelpMessages( $ret, 'dynamicparameters', [ $dynamicParams ] );
490  }
491  }
492 
493  return $ret;
494  }
495 
496  public function isReadMode() {
497  return false;
498  }
499 
500  public function getAllowedParams() {
501  // back compat
502  $querymodules = $this->getMain()->getModuleManager()
503  ->getModule( 'query' )->getModuleManager()->getNames();
504  sort( $querymodules );
505  $formatmodules = $this->getMain()->getModuleManager()->getNames( 'format' );
506  sort( $formatmodules );
507 
508  return [
509  'modules' => [
510  ApiBase::PARAM_ISMULTI => true,
511  ],
512  'helpformat' => [
513  ApiBase::PARAM_DFLT => 'none',
514  ApiBase::PARAM_TYPE => [ 'html', 'wikitext', 'raw', 'none' ],
515  ],
516 
517  'querymodules' => [
519  ApiBase::PARAM_ISMULTI => true,
520  ApiBase::PARAM_TYPE => $querymodules,
521  ],
522  'mainmodule' => [
524  ],
525  'pagesetmodule' => [
527  ],
528  'formatmodules' => [
530  ApiBase::PARAM_ISMULTI => true,
531  ApiBase::PARAM_TYPE => $formatmodules,
532  ]
533  ];
534  }
535 
536  protected function getExamplesMessages() {
537  return [
538  'action=paraminfo&modules=parse|phpfm|query%2Ballpages|query%2Bsiteinfo'
539  => 'apihelp-paraminfo-example-1',
540  'action=paraminfo&modules=query%2B*'
541  => 'apihelp-paraminfo-example-2',
542  ];
543  }
544 
545  public function getHelpUrls() {
546  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parameter_information';
547  }
548 }
ApiParamInfo\getModuleInfo
getModuleInfo( $module)
Definition: ApiParamInfo.php:242
ApiUsageException\getStatusValue
getStatusValue()
Fetch the error status.
Definition: ApiUsageException.php:176
ApiParamInfo
Definition: ApiParamInfo.php:30
ApiParamInfo\$context
$context
Definition: ApiParamInfo.php:33
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:45
ApiBase\PARAM_SUBMODULE_MAP
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
Definition: ApiBase.php:168
ApiUsageException
Exception used to abort API execution with an error.
Definition: ApiUsageException.php:98
ApiParamInfo\$helpFormat
$helpFormat
Definition: ApiParamInfo.php:32
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1720
ApiBase\PARAM_REQUIRED
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition: ApiBase.php:115
ApiParamInfo\listAllSubmodules
listAllSubmodules(ApiBase $module, $recursive)
List all submodules of a module.
Definition: ApiParamInfo.php:169
RequestContext\setUser
setUser(User $u)
Set the User object.
Definition: RequestContext.php:281
captcha-old.count
count
Definition: captcha-old.py:225
ApiBase\PARAM_ALL
const PARAM_ALL
(boolean|string) When PARAM_TYPE has a defined set of values and PARAM_ISMULTI is true,...
Definition: ApiBase.php:183
$result
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: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! 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:1954
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
ApiBase\PARAM_TYPE
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition: ApiBase.php:91
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:610
$params
$params
Definition: styleTest.css.php:40
ApiParamInfo\__construct
__construct(ApiMain $main, $action)
Definition: ApiParamInfo.php:35
ApiParamInfo\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiParamInfo.php:500
SpecialPage\getTitleFor
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
ApiBase\makeMessage
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1642
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
ApiBase\PARAM_ALLOW_DUPLICATES
const PARAM_ALLOW_DUPLICATES
(boolean) Allow the same value to be set more than once when PARAM_ISMULTI is true?
Definition: ApiBase.php:106
ApiPageSet
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:44
php
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
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:41
ApiBase\getModuleFromPath
getModuleFromPath( $path)
Get a module from its module path.
Definition: ApiBase.php:572
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:109
ApiBase\PARAM_MIN
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:103
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
$tag
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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:1028
$modules
$modules
Definition: HTMLFormElement.php:12
ApiParamInfo\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiParamInfo.php:39
ApiBase\PARAM_MAX
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:94
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:33
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
Definition: ApiBase.php:189
ApiBase\ALL_DEFAULT_STRING
const ALL_DEFAULT_STRING
Definition: ApiBase.php:200
string
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
SpecialVersion\getExtLicenseFileName
static getExtLicenseFileName( $extDir)
Obtains the full path of an extensions copying or license file if one exists.
Definition: SpecialVersion.php:1042
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
Definition: ChangeTags.php:1212
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:718
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
ApiBase\LIMIT_SML2
const LIMIT_SML2
Slow query, apihighlimits limit.
Definition: ApiBase.php:209
ApiBase\GET_VALUES_FOR_HELP
const GET_VALUES_FOR_HELP
getAllowedParams() flag: When set, the result could take longer to generate, but should be more thoro...
Definition: ApiBase.php:216
ApiParamInfo\isReadMode
isReadMode()
Indicates whether this module requires read rights.
Definition: ApiParamInfo.php:496
$ret
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:1956
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:145
ApiBase\PARAM_RANGE_ENFORCE
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
Definition: ApiBase.php:121
ApiParamInfo\formatHelpMessages
formatHelpMessages(array &$res, $key, array $msgs, $joinLists=false)
Definition: ApiParamInfo.php:192
ApiBase\getModuleManager
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
Definition: ApiBase.php:273
$path
$path
Definition: NoLocalSettings.php:26
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:52
as
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
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:490
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:55
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
ApiBase\PARAM_MAX2
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition: ApiBase.php:100
ApiParamInfo\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiParamInfo.php:536
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:506
ApiBase\PARAM_SUBMODULE_PARAM_PREFIX
const PARAM_SUBMODULE_PARAM_PREFIX
(string) When PARAM_TYPE is 'submodule', used to indicate the 'g' prefix added by ApiQueryGeneratorBa...
Definition: ApiBase.php:175
ApiHelpParamValueMessage
Message subclass that prepends wikitext for API help.
Definition: ApiHelpParamValueMessage.php:36
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
ApiResult\setSubelementsList
static setSubelementsList(array &$arr, $names)
Causes the elements with the specified names to be output as subelements rather than attributes.
Definition: ApiResult.php:565
ApiParamInfo\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiParamInfo.php:545
ApiBase\LIMIT_SML1
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:207
array
the array() calling protocol came about after MediaWiki 1.4rc1.