MediaWiki  REL1_31
ApiParamInfo.php
Go to the documentation of this file.
1 <?php
26 class ApiParamInfo extends ApiBase {
27 
28  private $helpFormat;
29  private $context;
30 
31  public function __construct( ApiMain $main, $action ) {
32  parent::__construct( $main, $action );
33  }
34 
35  public function execute() {
36  // Get parameters
37  $params = $this->extractRequestParams();
38 
39  $this->helpFormat = $params['helpformat'];
40  $this->context = new RequestContext;
41  $this->context->setUser( new User ); // anon to avoid caching issues
42  $this->context->setLanguage( $this->getMain()->getLanguage() );
43 
44  if ( is_array( $params['modules'] ) ) {
45  $modules = [];
46  foreach ( $params['modules'] as $path ) {
47  if ( $path === '*' || $path === '**' ) {
48  $path = "main+$path";
49  }
50  if ( substr( $path, -2 ) === '+*' || substr( $path, -2 ) === ' *' ) {
51  $submodules = true;
52  $path = substr( $path, 0, -2 );
53  $recursive = false;
54  } elseif ( substr( $path, -3 ) === '+**' || substr( $path, -3 ) === ' **' ) {
55  $submodules = true;
56  $path = substr( $path, 0, -3 );
57  $recursive = true;
58  } else {
59  $submodules = false;
60  }
61 
62  if ( $submodules ) {
63  try {
64  $module = $this->getModuleFromPath( $path );
65  } catch ( ApiUsageException $ex ) {
66  foreach ( $ex->getStatusValue()->getErrors() as $error ) {
67  $this->addWarning( $error );
68  }
69  continue;
70  }
71  $submodules = $this->listAllSubmodules( $module, $recursive );
72  if ( $submodules ) {
73  $modules = array_merge( $modules, $submodules );
74  } else {
75  $this->addWarning( [ 'apierror-badmodule-nosubmodules', $path ], 'badmodule' );
76  }
77  } else {
78  $modules[] = $path;
79  }
80  }
81  } else {
82  $modules = [];
83  }
84 
85  if ( is_array( $params['querymodules'] ) ) {
86  $queryModules = $params['querymodules'];
87  foreach ( $queryModules as $m ) {
88  $modules[] = 'query+' . $m;
89  }
90  } else {
91  $queryModules = [];
92  }
93 
94  if ( is_array( $params['formatmodules'] ) ) {
95  $formatModules = $params['formatmodules'];
96  foreach ( $formatModules as $m ) {
97  $modules[] = $m;
98  }
99  } else {
100  $formatModules = [];
101  }
102 
103  $modules = array_unique( $modules );
104 
105  $res = [];
106 
107  foreach ( $modules as $m ) {
108  try {
109  $module = $this->getModuleFromPath( $m );
110  } catch ( ApiUsageException $ex ) {
111  foreach ( $ex->getStatusValue()->getErrors() as $error ) {
112  $this->addWarning( $error );
113  }
114  continue;
115  }
116  $key = 'modules';
117 
118  // Back compat
119  $isBCQuery = false;
120  if ( $module->getParent() && $module->getParent()->getModuleName() == 'query' &&
121  in_array( $module->getModuleName(), $queryModules )
122  ) {
123  $isBCQuery = true;
124  $key = 'querymodules';
125  }
126  if ( in_array( $module->getModuleName(), $formatModules ) ) {
127  $key = 'formatmodules';
128  }
129 
130  $item = $this->getModuleInfo( $module );
131  if ( $isBCQuery ) {
132  $item['querytype'] = $item['group'];
133  }
134  $res[$key][] = $item;
135  }
136 
137  $result = $this->getResult();
138  $result->addValue( [ $this->getModuleName() ], 'helpformat', $this->helpFormat );
139 
140  foreach ( $res as $key => $stuff ) {
141  ApiResult::setIndexedTagName( $res[$key], 'module' );
142  }
143 
144  if ( $params['mainmodule'] ) {
145  $res['mainmodule'] = $this->getModuleInfo( $this->getMain() );
146  }
147 
148  if ( $params['pagesetmodule'] ) {
149  $pageSet = new ApiPageSet( $this->getMain()->getModuleManager()->getModule( 'query' ) );
150  $res['pagesetmodule'] = $this->getModuleInfo( $pageSet );
151  unset( $res['pagesetmodule']['name'] );
152  unset( $res['pagesetmodule']['path'] );
153  unset( $res['pagesetmodule']['group'] );
154  }
155 
156  $result->addValue( null, $this->getModuleName(), $res );
157  }
158 
165  private function listAllSubmodules( ApiBase $module, $recursive ) {
166  $manager = $module->getModuleManager();
167  if ( $manager ) {
168  $paths = [];
169  $names = $manager->getNames();
170  sort( $names );
171  foreach ( $names as $name ) {
172  $submodule = $manager->getModule( $name );
173  $paths[] = $submodule->getModulePath();
174  if ( $recursive && $submodule->getModuleManager() ) {
175  $paths = array_merge( $paths, $this->listAllSubmodules( $submodule, $recursive ) );
176  }
177  }
178  }
179  return $paths;
180  }
181 
188  protected function formatHelpMessages( array &$res, $key, array $msgs, $joinLists = false ) {
189  switch ( $this->helpFormat ) {
190  case 'none':
191  break;
192 
193  case 'wikitext':
194  $ret = [];
195  foreach ( $msgs as $m ) {
196  $ret[] = $m->setContext( $this->context )->text();
197  }
198  $res[$key] = implode( "\n\n", $ret );
199  if ( $joinLists ) {
200  $res[$key] = preg_replace( '!^(([*#:;])[^\n]*)\n\n(?=\2)!m', "$1\n", $res[$key] );
201  }
202  break;
203 
204  case 'html':
205  $ret = [];
206  foreach ( $msgs as $m ) {
207  $ret[] = $m->setContext( $this->context )->parseAsBlock();
208  }
209  $ret = implode( "\n", $ret );
210  if ( $joinLists ) {
211  $ret = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $ret );
212  }
214  break;
215 
216  case 'raw':
217  $res[$key] = [];
218  foreach ( $msgs as $m ) {
219  $a = [
220  'key' => $m->getKey(),
221  'params' => $m->getParams(),
222  ];
223  ApiResult::setIndexedTagName( $a['params'], 'param' );
224  if ( $m instanceof ApiHelpParamValueMessage ) {
225  $a['forvalue'] = $m->getParamValue();
226  }
227  $res[$key][] = $a;
228  }
229  ApiResult::setIndexedTagName( $res[$key], 'msg' );
230  break;
231  }
232  }
233 
238  private function getModuleInfo( $module ) {
239  $ret = [];
240  $path = $module->getModulePath();
241 
242  $ret['name'] = $module->getModuleName();
243  $ret['classname'] = get_class( $module );
244  $ret['path'] = $path;
245  if ( !$module->isMain() ) {
246  $ret['group'] = $module->getParent()->getModuleManager()->getModuleGroup(
247  $module->getModuleName()
248  );
249  }
250  $ret['prefix'] = $module->getModulePrefix();
251 
252  $sourceInfo = $module->getModuleSourceInfo();
253  if ( $sourceInfo ) {
254  $ret['source'] = $sourceInfo['name'];
255  if ( isset( $sourceInfo['namemsg'] ) ) {
256  $ret['sourcename'] = $this->context->msg( $sourceInfo['namemsg'] )->text();
257  } else {
258  $ret['sourcename'] = $ret['source'];
259  }
260 
261  $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] )->getFullURL();
262  if ( isset( $sourceInfo['license-name'] ) ) {
263  $ret['licensetag'] = $sourceInfo['license-name'];
264  $ret['licenselink'] = (string)$link;
265  } elseif ( SpecialVersion::getExtLicenseFileName( dirname( $sourceInfo['path'] ) ) ) {
266  $ret['licenselink'] = (string)$link;
267  }
268  }
269 
270  $this->formatHelpMessages( $ret, 'description', $module->getFinalDescription() );
271 
272  foreach ( $module->getHelpFlags() as $flag ) {
273  $ret[$flag] = true;
274  }
275 
276  $ret['helpurls'] = (array)$module->getHelpUrls();
277  if ( isset( $ret['helpurls'][0] ) && $ret['helpurls'][0] === false ) {
278  $ret['helpurls'] = [];
279  }
280  ApiResult::setIndexedTagName( $ret['helpurls'], 'helpurl' );
281 
282  if ( $this->helpFormat !== 'none' ) {
283  $ret['examples'] = [];
284  $examples = $module->getExamplesMessages();
285  foreach ( $examples as $qs => $msg ) {
286  $item = [
287  'query' => $qs
288  ];
289  $msg = ApiBase::makeMessage( $msg, $this->context, [
290  $module->getModulePrefix(),
291  $module->getModuleName(),
292  $module->getModulePath()
293  ] );
294  $this->formatHelpMessages( $item, 'description', [ $msg ] );
295  if ( isset( $item['description'] ) ) {
296  if ( is_array( $item['description'] ) ) {
297  $item['description'] = $item['description'][0];
298  } else {
299  ApiResult::setSubelementsList( $item, 'description' );
300  }
301  }
302  $ret['examples'][] = $item;
303  }
304  ApiResult::setIndexedTagName( $ret['examples'], 'example' );
305  }
306 
307  $ret['parameters'] = [];
308  $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
309  $paramDesc = $module->getFinalParamDescription();
310  foreach ( $params as $name => $settings ) {
311  if ( !is_array( $settings ) ) {
312  $settings = [ ApiBase::PARAM_DFLT => $settings ];
313  }
314 
315  $item = [
316  'name' => $name
317  ];
318  if ( isset( $paramDesc[$name] ) ) {
319  $this->formatHelpMessages( $item, 'description', $paramDesc[$name], true );
320  }
321 
322  $item['required'] = !empty( $settings[ApiBase::PARAM_REQUIRED] );
323 
324  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
325  $item['deprecated'] = true;
326  }
327 
328  if ( $name === 'token' && $module->needsToken() ) {
329  $item['tokentype'] = $module->needsToken();
330  }
331 
332  if ( !isset( $settings[ApiBase::PARAM_TYPE] ) ) {
333  $dflt = isset( $settings[ApiBase::PARAM_DFLT] )
334  ? $settings[ApiBase::PARAM_DFLT]
335  : null;
336  if ( is_bool( $dflt ) ) {
337  $settings[ApiBase::PARAM_TYPE] = 'boolean';
338  } elseif ( is_string( $dflt ) || is_null( $dflt ) ) {
339  $settings[ApiBase::PARAM_TYPE] = 'string';
340  } elseif ( is_int( $dflt ) ) {
341  $settings[ApiBase::PARAM_TYPE] = 'integer';
342  }
343  }
344 
345  if ( isset( $settings[ApiBase::PARAM_DFLT] ) ) {
346  switch ( $settings[ApiBase::PARAM_TYPE] ) {
347  case 'boolean':
348  $item['default'] = (bool)$settings[ApiBase::PARAM_DFLT];
349  break;
350  case 'string':
351  case 'text':
352  case 'password':
353  $item['default'] = strval( $settings[ApiBase::PARAM_DFLT] );
354  break;
355  case 'integer':
356  case 'limit':
357  $item['default'] = intval( $settings[ApiBase::PARAM_DFLT] );
358  break;
359  case 'timestamp':
360  $item['default'] = wfTimestamp( TS_ISO_8601, $settings[ApiBase::PARAM_DFLT] );
361  break;
362  default:
363  $item['default'] = $settings[ApiBase::PARAM_DFLT];
364  break;
365  }
366  }
367 
368  $item['multi'] = !empty( $settings[ApiBase::PARAM_ISMULTI] );
369  if ( $item['multi'] ) {
370  $item['lowlimit'] = !empty( $settings[ApiBase::PARAM_ISMULTI_LIMIT1] )
371  ? $settings[ApiBase::PARAM_ISMULTI_LIMIT1]
373  $item['highlimit'] = !empty( $settings[ApiBase::PARAM_ISMULTI_LIMIT2] )
374  ? $settings[ApiBase::PARAM_ISMULTI_LIMIT2]
376  $item['limit'] = $this->getMain()->canApiHighLimits()
377  ? $item['highlimit']
378  : $item['lowlimit'];
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 
405  $deprecatedSubmodules = [];
406  foreach ( $item['submodules'] as $v => $submodulePath ) {
407  try {
408  $submod = $this->getModuleFromPath( $submodulePath );
409  if ( $submod && $submod->isDeprecated() ) {
410  $deprecatedSubmodules[] = $v;
411  }
412  } catch ( ApiUsageException $ex ) {
413  // Ignore
414  }
415  }
416  if ( $deprecatedSubmodules ) {
417  $item['type'] = array_merge(
418  array_diff( $item['type'], $deprecatedSubmodules ),
419  $deprecatedSubmodules
420  );
421  $item['deprecatedvalues'] = $deprecatedSubmodules;
422  }
423  } elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
424  $item['type'] = ChangeTags::listExplicitlyDefinedTags();
425  } else {
426  $item['type'] = $settings[ApiBase::PARAM_TYPE];
427  }
428  if ( is_array( $item['type'] ) ) {
429  // To prevent sparse arrays from being serialized to JSON as objects
430  $item['type'] = array_values( $item['type'] );
431  ApiResult::setIndexedTagName( $item['type'], 't' );
432  }
433 
434  // Add 'allspecifier' if applicable
435  if ( $item['type'] === 'namespace' ) {
436  $allowAll = true;
437  $allSpecifier = ApiBase::ALL_DEFAULT_STRING;
438  } else {
439  $allowAll = isset( $settings[ApiBase::PARAM_ALL] )
440  ? $settings[ApiBase::PARAM_ALL]
441  : false;
442  $allSpecifier = ( is_string( $allowAll ) ? $allowAll : ApiBase::ALL_DEFAULT_STRING );
443  }
444  if ( $allowAll && $item['multi'] &&
445  ( is_array( $item['type'] ) || $item['type'] === 'namespace' ) ) {
446  $item['allspecifier'] = $allSpecifier;
447  }
448 
449  if ( $item['type'] === 'namespace' &&
450  isset( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] ) &&
451  is_array( $settings[ApiBase::PARAM_EXTRA_NAMESPACES] )
452  ) {
453  $item['extranamespaces'] = $settings[ApiBase::PARAM_EXTRA_NAMESPACES];
454  ApiResult::setArrayType( $item['extranamespaces'], 'array' );
455  ApiResult::setIndexedTagName( $item['extranamespaces'], 'ns' );
456  }
457  }
458  if ( isset( $settings[ApiBase::PARAM_MAX] ) ) {
459  $item['max'] = $settings[ApiBase::PARAM_MAX];
460  }
461  if ( isset( $settings[ApiBase::PARAM_MAX2] ) ) {
462  $item['highmax'] = $settings[ApiBase::PARAM_MAX2];
463  }
464  if ( isset( $settings[ApiBase::PARAM_MIN] ) ) {
465  $item['min'] = $settings[ApiBase::PARAM_MIN];
466  }
467  if ( !empty( $settings[ApiBase::PARAM_RANGE_ENFORCE] ) ) {
468  $item['enforcerange'] = true;
469  }
470  if ( isset( $settings[self::PARAM_MAX_BYTES] ) ) {
471  $item['maxbytes'] = $settings[self::PARAM_MAX_BYTES];
472  }
473  if ( isset( $settings[self::PARAM_MAX_CHARS] ) ) {
474  $item['maxchars'] = $settings[self::PARAM_MAX_CHARS];
475  }
476  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED_VALUES] ) ) {
477  $deprecatedValues = array_keys( $settings[ApiBase::PARAM_DEPRECATED_VALUES] );
478  if ( is_array( $item['type'] ) ) {
479  $deprecatedValues = array_intersect( $deprecatedValues, $item['type'] );
480  }
481  if ( $deprecatedValues ) {
482  $item['deprecatedvalues'] = array_values( $deprecatedValues );
483  ApiResult::setIndexedTagName( $item['deprecatedvalues'], 'v' );
484  }
485  }
486 
487  if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
488  $item['info'] = [];
489  foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
490  $tag = array_shift( $i );
491  $info = [
492  'name' => $tag,
493  ];
494  if ( count( $i ) ) {
495  $info['values'] = $i;
496  ApiResult::setIndexedTagName( $info['values'], 'v' );
497  }
498  $this->formatHelpMessages( $info, 'text', [
499  $this->context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
500  ->numParams( count( $i ) )
501  ->params( $this->context->getLanguage()->commaList( $i ) )
502  ->params( $module->getModulePrefix() )
503  ] );
504  ApiResult::setSubelementsList( $info, 'text' );
505  $item['info'][] = $info;
506  }
507  ApiResult::setIndexedTagName( $item['info'], 'i' );
508  }
509 
510  $ret['parameters'][] = $item;
511  }
512  ApiResult::setIndexedTagName( $ret['parameters'], 'param' );
513 
514  $dynamicParams = $module->dynamicParameterDocumentation();
515  if ( $dynamicParams !== null ) {
516  if ( $this->helpFormat === 'none' ) {
517  $ret['dynamicparameters'] = true;
518  } else {
519  $dynamicParams = ApiBase::makeMessage( $dynamicParams, $this->context, [
520  $module->getModulePrefix(),
521  $module->getModuleName(),
522  $module->getModulePath()
523  ] );
524  $this->formatHelpMessages( $ret, 'dynamicparameters', [ $dynamicParams ] );
525  }
526  }
527 
528  return $ret;
529  }
530 
531  public function isReadMode() {
532  return false;
533  }
534 
535  public function getAllowedParams() {
536  // back compat
537  $querymodules = $this->getMain()->getModuleManager()
538  ->getModule( 'query' )->getModuleManager()->getNames();
539  sort( $querymodules );
540  $formatmodules = $this->getMain()->getModuleManager()->getNames( 'format' );
541  sort( $formatmodules );
542 
543  return [
544  'modules' => [
545  ApiBase::PARAM_ISMULTI => true,
546  ],
547  'helpformat' => [
548  ApiBase::PARAM_DFLT => 'none',
549  ApiBase::PARAM_TYPE => [ 'html', 'wikitext', 'raw', 'none' ],
550  ],
551 
552  'querymodules' => [
554  ApiBase::PARAM_ISMULTI => true,
555  ApiBase::PARAM_TYPE => $querymodules,
556  ],
557  'mainmodule' => [
559  ],
560  'pagesetmodule' => [
562  ],
563  'formatmodules' => [
565  ApiBase::PARAM_ISMULTI => true,
566  ApiBase::PARAM_TYPE => $formatmodules,
567  ]
568  ];
569  }
570 
571  protected function getExamplesMessages() {
572  return [
573  'action=paraminfo&modules=parse|phpfm|query%2Ballpages|query%2Bsiteinfo'
574  => 'apihelp-paraminfo-example-1',
575  'action=paraminfo&modules=query%2B*'
576  => 'apihelp-paraminfo-example-2',
577  ];
578  }
579 
580  public function getHelpUrls() {
581  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parameter_information';
582  }
583 }
ApiParamInfo\getModuleInfo
getModuleInfo( $module)
Definition: ApiParamInfo.php:238
ApiUsageException\getStatusValue
getStatusValue()
Fetch the error status.
Definition: ApiUsageException.php:181
ApiParamInfo
Definition: ApiParamInfo.php:26
ApiParamInfo\$context
$context
Definition: ApiParamInfo.php:29
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:43
ApiBase\PARAM_SUBMODULE_MAP
const PARAM_SUBMODULE_MAP
(string[]) When PARAM_TYPE is 'submodule', map parameter values to submodule paths.
Definition: ApiBase.php:165
ApiUsageException
Exception used to abort API execution with an error.
Definition: ApiUsageException.php:103
ApiParamInfo\$helpFormat
$helpFormat
Definition: ApiParamInfo.php:28
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1819
ApiBase\PARAM_REQUIRED
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition: ApiBase.php:111
ApiParamInfo\listAllSubmodules
listAllSubmodules(ApiBase $module, $recursive)
List all submodules of a module.
Definition: ApiParamInfo.php:165
array
the array() calling protocol came about after MediaWiki 1.4rc1.
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:181
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:180
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1980
$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:2005
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:87
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:641
$params
$params
Definition: styleTest.css.php:40
ApiParamInfo\__construct
__construct(ApiMain $main, $action)
Definition: ApiParamInfo.php:31
ApiBase\PARAM_ISMULTI_LIMIT1
const PARAM_ISMULTI_LIMIT1
(integer) Maximum number of values, for normal users.
Definition: ApiBase.php:208
ApiParamInfo\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiParamInfo.php:535
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:1741
$res
$res
Definition: database.txt:21
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:102
$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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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. '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:1993
ApiBase\PARAM_DEPRECATED_VALUES
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
Definition: ApiBase.php:202
ApiPageSet
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:40
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:37
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:37
ApiBase\getModuleFromPath
getModuleFromPath( $path)
Get a module from its module path.
Definition: ApiBase.php:603
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
ApiBase\PARAM_ISMULTI_LIMIT2
const PARAM_ISMULTI_LIMIT2
(integer) Maximum number of values, for users with the apihighimits right.
Definition: ApiBase.php:215
RequestContext\setUser
setUser(User $user)
Definition: RequestContext.php:258
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:105
ApiBase\PARAM_MIN
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:99
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
$modules
$modules
Definition: HTMLFormElement.php:12
ApiParamInfo\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiParamInfo.php:35
ApiBase\PARAM_MAX
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition: ApiBase.php:90
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3021
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:32
ApiBase\PARAM_EXTRA_NAMESPACES
const PARAM_EXTRA_NAMESPACES
(int[]) When PARAM_TYPE is 'namespace', include these as additional possible values.
Definition: ApiBase.php:186
ApiBase\ALL_DEFAULT_STRING
const ALL_DEFAULT_STRING
Definition: ApiBase.php:231
SpecialVersion\getExtLicenseFileName
static getExtLicenseFileName( $extDir)
Obtains the full path of an extensions copying or license file if one exists.
Definition: SpecialVersion.php:1048
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the valid_tag table of the database.
Definition: ChangeTags.php:1320
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:749
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:240
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:247
ApiParamInfo\isReadMode
isReadMode()
Indicates whether this module requires read rights.
Definition: ApiParamInfo.php:531
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:141
ApiBase\PARAM_RANGE_ENFORCE
const PARAM_RANGE_ENFORCE
(boolean) For PARAM_TYPE 'integer', enforce PARAM_MIN and PARAM_MAX?
Definition: ApiBase.php:117
ApiParamInfo\formatHelpMessages
formatHelpMessages(array &$res, $key, array $msgs, $joinLists=false)
Definition: ApiParamInfo.php:188
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Parser\stripOuterParagraph
static stripOuterParagraph( $html)
Strip outer.
Definition: Parser.php:6141
ApiBase\getModuleManager
getModuleManager()
Get the module manager, or null if this module has no sub-modules.
Definition: ApiBase.php:304
$path
$path
Definition: NoLocalSettings.php:25
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:48
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:22
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:521
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:51
ApiBase\PARAM_MAX2
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition: ApiBase.php:96
ApiParamInfo\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiParamInfo.php:571
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:537
ApiBase\PARAM_MAX_CHARS
const PARAM_MAX_CHARS
(integer) Maximum length of a string in characters (unicode codepoints).
Definition: ApiBase.php:227
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:172
ApiBase\PARAM_MAX_BYTES
const PARAM_MAX_BYTES
(integer) Maximum length of a string in bytes (in UTF-8 encoding).
Definition: ApiBase.php:221
ApiHelpParamValueMessage
Message subclass that prepends wikitext for API help.
Definition: ApiHelpParamValueMessage.php:32
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
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
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
ApiParamInfo\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiParamInfo.php:580
ApiBase\LIMIT_SML1
const LIMIT_SML1
Slow query, standard limit.
Definition: ApiBase.php:238