MediaWiki  master
ApiHelp.php
Go to the documentation of this file.
1 <?php
23 use HtmlFormatter\HtmlFormatter;
27 
34 class ApiHelp extends ApiBase {
35  public function execute() {
36  $params = $this->extractRequestParams();
37  $modules = [];
38 
39  foreach ( $params['modules'] as $path ) {
40  $modules[] = $this->getModuleFromPath( $path );
41  }
42 
43  // Get the help
44  $context = new DerivativeContext( $this->getMain()->getContext() );
45  $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
46  $context->setSkin( $skinFactory->makeSkin( 'apioutput' ) );
47  $context->setLanguage( $this->getMain()->getLanguage() );
48  $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) );
49  $out = new OutputPage( $context );
50  $out->setRobotPolicy( 'noindex,nofollow' );
51  $out->setCopyrightUrl( 'https://www.mediawiki.org/wiki/Special:MyLanguage/Copyright' );
52  $context->setOutput( $out );
53 
54  self::getHelp( $context, $modules, $params );
55 
56  // Grab the output from the skin
57  ob_start();
58  $context->getOutput()->output();
59  $html = ob_get_clean();
60 
61  $result = $this->getResult();
62  if ( $params['wrap'] ) {
63  $data = [
64  'mime' => 'text/html',
65  'filename' => 'api-help.html',
66  'help' => $html,
67  ];
68  ApiResult::setSubelementsList( $data, 'help' );
69  $result->addValue( null, $this->getModuleName(), $data );
70  } else {
71  // Show any errors at the top of the HTML
72  $transform = [
73  'Types' => [ 'AssocAsObject' => true ],
74  'Strip' => 'all',
75  ];
76  $errors = array_filter( [
77  'errors' => $this->getResult()->getResultData( [ 'errors' ], $transform ),
78  'warnings' => $this->getResult()->getResultData( [ 'warnings' ], $transform ),
79  ] );
80  if ( $errors ) {
81  $json = FormatJson::encode( $errors, true, FormatJson::UTF8_OK );
82  // Escape any "--", some parsers might interpret that as end-of-comment.
83  // The above already escaped any "<" and ">".
84  $json = str_replace( '--', '-\u002D', $json );
85  $html = "<!-- API warnings and errors:\n$json\n-->\n$html";
86  }
87 
88  $result->reset();
89  $result->addValue( null, 'text', $html, ApiResult::NO_SIZE_CHECK );
90  $result->addValue( null, 'mime', 'text/html', ApiResult::NO_SIZE_CHECK );
91  $result->addValue( null, 'filename', 'api-help.html', ApiResult::NO_SIZE_CHECK );
92  }
93  }
94 
114  public static function getHelp( IContextSource $context, $modules, array $options ) {
115  if ( !is_array( $modules ) ) {
116  $modules = [ $modules ];
117  }
118 
119  $out = $context->getOutput();
120  $out->addModuleStyles( [
121  'mediawiki.hlist',
122  'mediawiki.apipretty',
123  ] );
124  $out->setPageTitle( $context->msg( 'api-help-title' ) );
125 
126  $services = MediaWikiServices::getInstance();
127  $cache = $services->getMainWANObjectCache();
128  $cacheKey = null;
129  if ( count( $modules ) == 1 && $modules[0] instanceof ApiMain &&
130  $options['recursivesubmodules'] &&
131  $context->getLanguage()->equals( $services->getContentLanguage() )
132  ) {
133  $cacheHelpTimeout = $context->getConfig()->get( 'APICacheHelpTimeout' );
134  if ( $cacheHelpTimeout > 0 ) {
135  // Get help text from cache if present
136  $cacheKey = $cache->makeKey( 'apihelp', $modules[0]->getModulePath(),
137  (int)!empty( $options['toc'] ),
138  str_replace( ' ', '_', SpecialVersion::getVersion( 'nodb' ) ) );
139  $cached = $cache->get( $cacheKey );
140  if ( $cached ) {
141  $out->addHTML( $cached );
142  return;
143  }
144  }
145  }
146  if ( $out->getHTML() !== '' ) {
147  // Don't save to cache, there's someone else's content in the page
148  // already
149  $cacheKey = null;
150  }
151 
152  $options['recursivesubmodules'] = !empty( $options['recursivesubmodules'] );
153  $options['submodules'] = $options['recursivesubmodules'] || !empty( $options['submodules'] );
154 
155  // Prepend lead
156  if ( empty( $options['nolead'] ) ) {
157  $msg = $context->msg( 'api-help-lead' );
158  if ( !$msg->isDisabled() ) {
159  $out->addHTML( $msg->parseAsBlock() );
160  }
161  }
162 
163  $haveModules = [];
164  $html = self::getHelpInternal( $context, $modules, $options, $haveModules );
165  if ( !empty( $options['toc'] ) && $haveModules ) {
166  $out->addHTML( Linker::generateTOC( $haveModules, $context->getLanguage() ) );
167  }
168  $out->addHTML( $html );
169 
170  $helptitle = $options['helptitle'] ?? null;
171  $html = self::fixHelpLinks( $out->getHTML(), $helptitle, $haveModules );
172  $out->clearHTML();
173  $out->addHTML( $html );
174 
175  if ( $cacheKey !== null ) {
176  $cache->set( $cacheKey, $out->getHTML(), $cacheHelpTimeout );
177  }
178  }
179 
188  public static function fixHelpLinks( $html, $helptitle = null, $localModules = [] ) {
189  $formatter = new HtmlFormatter( $html );
190  $doc = $formatter->getDoc();
191  $xpath = new DOMXPath( $doc );
192  $nodes = $xpath->query( '//a[@href][not(contains(@class,\'apihelp-linktrail\'))]' );
194  foreach ( $nodes as $node ) {
195  $href = $node->getAttribute( 'href' );
196  do {
197  $old = $href;
198  $href = rawurldecode( $href );
199  } while ( $old !== $href );
200  if ( preg_match( '!Special:ApiHelp/([^&/|#]+)((?:#.*)?)!', $href, $m ) ) {
201  if ( isset( $localModules[$m[1]] ) ) {
202  $href = $m[2] === '' ? '#' . $m[1] : $m[2];
203  } elseif ( $helptitle !== null ) {
204  $href = Title::newFromText( str_replace( '$1', $m[1], $helptitle ) . $m[2] )
205  ->getFullURL();
206  } else {
207  $href = wfAppendQuery( wfScript( 'api' ), [
208  'action' => 'help',
209  'modules' => $m[1],
210  ] ) . $m[2];
211  }
212  $node->setAttribute( 'href', $href );
213  $node->removeAttribute( 'title' );
214  }
215  }
216 
217  return $formatter->getText();
218  }
219 
228  private static function wrap( Message $msg, $class, $tag = 'span' ) {
229  return Html::rawElement( $tag, [ 'class' => $class ],
230  $msg->parse()
231  );
232  }
233 
243  private static function getHelpInternal( IContextSource $context, array $modules,
244  array $options, &$haveModules
245  ) {
246  $out = '';
247 
248  $level = empty( $options['headerlevel'] ) ? 2 : $options['headerlevel'];
249  if ( empty( $options['tocnumber'] ) ) {
250  $tocnumber = [ 2 => 0 ];
251  } else {
252  $tocnumber = &$options['tocnumber'];
253  }
254 
255  foreach ( $modules as $module ) {
256  $paramValidator = $module->getMain()->getParamValidator();
257  $tocnumber[$level]++;
258  $path = $module->getModulePath();
259  $module->setContext( $context );
260  $help = [
261  'header' => '',
262  'flags' => '',
263  'description' => '',
264  'help-urls' => '',
265  'parameters' => '',
266  'examples' => '',
267  'submodules' => '',
268  ];
269 
270  if ( empty( $options['noheader'] ) || !empty( $options['toc'] ) ) {
271  $anchor = $path;
272  $i = 1;
273  while ( isset( $haveModules[$anchor] ) ) {
274  $anchor = $path . '|' . ++$i;
275  }
276 
277  if ( $module->isMain() ) {
278  $headerContent = $context->msg( 'api-help-main-header' )->parse();
279  $headerAttr = [
280  'class' => 'apihelp-header',
281  ];
282  } else {
283  $name = $module->getModuleName();
284  $headerContent = htmlspecialchars(
285  $module->getParent()->getModuleManager()->getModuleGroup( $name ) . "=$name"
286  );
287  if ( $module->getModulePrefix() !== '' ) {
288  $headerContent .= ' ' .
289  $context->msg( 'parentheses', $module->getModulePrefix() )->parse();
290  }
291  // Module names are always in English and not localized,
292  // so English language and direction must be set explicitly,
293  // otherwise parentheses will get broken in RTL wikis
294  $headerAttr = [
295  'class' => 'apihelp-header apihelp-module-name',
296  'dir' => 'ltr',
297  'lang' => 'en',
298  ];
299  }
300 
301  $headerAttr['id'] = $anchor;
302 
303  $haveModules[$anchor] = [
304  'toclevel' => count( $tocnumber ),
305  'level' => $level,
306  'anchor' => $anchor,
307  'line' => $headerContent,
308  'number' => implode( '.', $tocnumber ),
309  'index' => false,
310  ];
311  if ( empty( $options['noheader'] ) ) {
312  $help['header'] .= Html::rawElement(
313  'h' . min( 6, $level ),
314  $headerAttr,
315  $headerContent
316  );
317  }
318  } else {
319  $haveModules[$path] = true;
320  }
321 
322  $links = [];
323  $any = false;
324  for ( $m = $module; $m !== null; $m = $m->getParent() ) {
325  $name = $m->getModuleName();
326  if ( $name === 'main_int' ) {
327  $name = 'main';
328  }
329 
330  if ( count( $modules ) === 1 && $m === $modules[0] &&
331  !( !empty( $options['submodules'] ) && $m->getModuleManager() )
332  ) {
333  $link = Html::element( 'b', [ 'dir' => 'ltr', 'lang' => 'en' ], $name );
334  } else {
335  $link = SpecialPage::getTitleFor( 'ApiHelp', $m->getModulePath() )->getLocalURL();
336  $link = Html::element( 'a',
337  [ 'href' => $link, 'class' => 'apihelp-linktrail', 'dir' => 'ltr', 'lang' => 'en' ],
338  $name
339  );
340  $any = true;
341  }
342  array_unshift( $links, $link );
343  }
344  if ( $any ) {
345  $help['header'] .= self::wrap(
346  $context->msg( 'parentheses' )
347  ->rawParams( $context->getLanguage()->pipeList( $links ) ),
348  'apihelp-linktrail', 'div'
349  );
350  }
351 
352  $flags = $module->getHelpFlags();
353  $help['flags'] .= Html::openElement( 'div',
354  [ 'class' => 'apihelp-block apihelp-flags' ] );
355  $msg = $context->msg( 'api-help-flags' );
356  if ( !$msg->isDisabled() ) {
357  $help['flags'] .= self::wrap(
358  $msg->numParams( count( $flags ) ), 'apihelp-block-head', 'div'
359  );
360  }
361  $help['flags'] .= Html::openElement( 'ul' );
362  foreach ( $flags as $flag ) {
363  $help['flags'] .= Html::rawElement( 'li', null,
364  self::wrap( $context->msg( "api-help-flag-$flag" ), "apihelp-flag-$flag" )
365  );
366  }
367  $sourceInfo = $module->getModuleSourceInfo();
368  if ( $sourceInfo ) {
369  if ( isset( $sourceInfo['namemsg'] ) ) {
370  $extname = $context->msg( $sourceInfo['namemsg'] )->text();
371  } else {
372  // Probably English, so wrap it.
373  $extname = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['name'] );
374  }
375  $help['flags'] .= Html::rawElement( 'li', null,
376  self::wrap(
377  $context->msg( 'api-help-source', $extname, $sourceInfo['name'] ),
378  'apihelp-source'
379  )
380  );
381 
382  $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] );
383  if ( isset( $sourceInfo['license-name'] ) ) {
384  $msg = $context->msg( 'api-help-license', $link,
385  Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['license-name'] )
386  );
387  } elseif ( ExtensionInfo::getLicenseFileNames( dirname( $sourceInfo['path'] ) ) ) {
388  $msg = $context->msg( 'api-help-license-noname', $link );
389  } else {
390  $msg = $context->msg( 'api-help-license-unknown' );
391  }
392  $help['flags'] .= Html::rawElement( 'li', null,
393  self::wrap( $msg, 'apihelp-license' )
394  );
395  } else {
396  $help['flags'] .= Html::rawElement( 'li', null,
397  self::wrap( $context->msg( 'api-help-source-unknown' ), 'apihelp-source' )
398  );
399  $help['flags'] .= Html::rawElement( 'li', null,
400  self::wrap( $context->msg( 'api-help-license-unknown' ), 'apihelp-license' )
401  );
402  }
403  $help['flags'] .= Html::closeElement( 'ul' );
404  $help['flags'] .= Html::closeElement( 'div' );
405 
406  foreach ( $module->getFinalDescription() as $msg ) {
407  $msg->setContext( $context );
408  $help['description'] .= $msg->parseAsBlock();
409  }
410 
411  $urls = $module->getHelpUrls();
412  if ( $urls ) {
413  if ( !is_array( $urls ) ) {
414  $urls = [ $urls ];
415  }
416  $help['help-urls'] .= Html::openElement( 'div',
417  [ 'class' => 'apihelp-block apihelp-help-urls' ]
418  );
419  $msg = $context->msg( 'api-help-help-urls' );
420  if ( !$msg->isDisabled() ) {
421  $help['help-urls'] .= self::wrap(
422  $msg->numParams( count( $urls ) ), 'apihelp-block-head', 'div'
423  );
424  }
425  $help['help-urls'] .= Html::openElement( 'ul' );
426  foreach ( $urls as $url ) {
427  $help['help-urls'] .= Html::rawElement( 'li', null,
428  Html::element( 'a', [ 'href' => $url, 'dir' => 'ltr' ], $url )
429  );
430  }
431  $help['help-urls'] .= Html::closeElement( 'ul' );
432  $help['help-urls'] .= Html::closeElement( 'div' );
433  }
434 
435  $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
436  $dynamicParams = $module->dynamicParameterDocumentation();
437  $groups = [];
438  if ( $params || $dynamicParams !== null ) {
439  $help['parameters'] .= Html::openElement( 'div',
440  [ 'class' => 'apihelp-block apihelp-parameters' ]
441  );
442  $msg = $context->msg( 'api-help-parameters' );
443  if ( !$msg->isDisabled() ) {
444  $help['parameters'] .= self::wrap(
445  $msg->numParams( count( $params ) ), 'apihelp-block-head', 'div'
446  );
447  }
448  $help['parameters'] .= Html::openElement( 'dl' );
449 
450  $descriptions = $module->getFinalParamDescription();
451 
452  foreach ( $params as $name => $settings ) {
453  $settings = $paramValidator->normalizeSettings( $settings );
454 
455  if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
456  $groups[] = $name;
457  }
458 
459  $help['parameters'] .= Html::rawElement( 'dt', null,
460  Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $module->encodeParamName( $name ) )
461  );
462 
463  // Add description
464  $description = [];
465  if ( isset( $descriptions[$name] ) ) {
466  foreach ( $descriptions[$name] as $msg ) {
467  $msg->setContext( $context );
468  $description[] = $msg->parseAsBlock();
469  }
470  }
471  if ( !array_filter( $description ) ) {
472  $description = [ self::wrap(
473  $context->msg( 'api-help-param-no-description' ),
474  'apihelp-empty'
475  ) ];
476  }
477 
478  // Add "deprecated" flag
479  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
480  $help['parameters'] .= Html::openElement( 'dd',
481  [ 'class' => 'info' ] );
482  $help['parameters'] .= self::wrap(
483  $context->msg( 'api-help-param-deprecated' ),
484  'apihelp-deprecated', 'strong'
485  );
486  $help['parameters'] .= Html::closeElement( 'dd' );
487  }
488 
489  if ( $description ) {
490  $description = implode( '', $description );
491  $description = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $description );
492  $help['parameters'] .= Html::rawElement( 'dd',
493  [ 'class' => 'description' ], $description );
494  }
495 
496  // Add usage info
497  $info = [];
498  $paramHelp = $paramValidator->getHelpInfo( $module, $name, $settings, [] );
499 
500  unset( $paramHelp[ParamValidator::PARAM_DEPRECATED] );
501 
502  if ( isset( $paramHelp[ParamValidator::PARAM_REQUIRED] ) ) {
503  $paramHelp[ParamValidator::PARAM_REQUIRED]->setContext( $context );
504  $info[] = $paramHelp[ParamValidator::PARAM_REQUIRED];
505  unset( $paramHelp[ParamValidator::PARAM_REQUIRED] );
506  }
507 
508  // Custom info?
509  if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
510  foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
511  $tag = array_shift( $i );
512  $info[] = $context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
513  ->numParams( count( $i ) )
514  ->params( $context->getLanguage()->commaList( $i ) )
515  ->params( $module->getModulePrefix() )
516  ->parse();
517  }
518  }
519 
520  // Templated?
521  if ( !empty( $settings[ApiBase::PARAM_TEMPLATE_VARS] ) ) {
522  $vars = [];
523  $msg = 'api-help-param-templated-var-first';
524  foreach ( $settings[ApiBase::PARAM_TEMPLATE_VARS] as $k => $v ) {
525  $vars[] = $context->msg( $msg, $k, $module->encodeParamName( $v ) );
526  $msg = 'api-help-param-templated-var';
527  }
528  $info[] = $context->msg( 'api-help-param-templated' )
529  ->numParams( count( $vars ) )
530  ->params( Message::listParam( $vars ) )
531  ->parse();
532  }
533 
534  // Type documentation
535  foreach ( $paramHelp as $m ) {
536  $m->setContext( $context );
537  $info[] = $m;
538  }
539 
540  foreach ( $info as $i ) {
541  $help['parameters'] .= Html::rawElement( 'dd', [ 'class' => 'info' ], $i );
542  }
543  }
544 
545  if ( $dynamicParams !== null ) {
546  $dynamicParams = ApiBase::makeMessage( $dynamicParams, $context, [
547  $module->getModulePrefix(),
548  $module->getModuleName(),
549  $module->getModulePath()
550  ] );
551  $help['parameters'] .= Html::element( 'dt', null, '*' );
552  $help['parameters'] .= Html::rawElement( 'dd',
553  [ 'class' => 'description' ], $dynamicParams->parse() );
554  }
555 
556  $help['parameters'] .= Html::closeElement( 'dl' );
557  $help['parameters'] .= Html::closeElement( 'div' );
558  }
559 
560  $examples = $module->getExamplesMessages();
561  if ( $examples ) {
562  $help['examples'] .= Html::openElement( 'div',
563  [ 'class' => 'apihelp-block apihelp-examples' ] );
564  $msg = $context->msg( 'api-help-examples' );
565  if ( !$msg->isDisabled() ) {
566  $help['examples'] .= self::wrap(
567  $msg->numParams( count( $examples ) ), 'apihelp-block-head', 'div'
568  );
569  }
570 
571  $help['examples'] .= Html::openElement( 'dl' );
572  foreach ( $examples as $qs => $msg ) {
573  $msg = ApiBase::makeMessage( $msg, $context, [
574  $module->getModulePrefix(),
575  $module->getModuleName(),
576  $module->getModulePath()
577  ] );
578 
579  $link = wfAppendQuery( wfScript( 'api' ), $qs );
580  $sandbox = SpecialPage::getTitleFor( 'ApiSandbox' )->getLocalURL() . '#' . $qs;
581  $help['examples'] .= Html::rawElement( 'dt', null, $msg->parse() );
582  $help['examples'] .= Html::rawElement( 'dd', null,
583  Html::element( 'a', [ 'href' => $link, 'dir' => 'ltr' ], "api.php?$qs" ) . ' ' .
584  Html::rawElement( 'a', [ 'href' => $sandbox ],
585  $context->msg( 'api-help-open-in-apisandbox' )->parse() )
586  );
587  }
588  $help['examples'] .= Html::closeElement( 'dl' );
589  $help['examples'] .= Html::closeElement( 'div' );
590  }
591 
592  $subtocnumber = $tocnumber;
593  $subtocnumber[$level + 1] = 0;
594  $suboptions = [
595  'submodules' => $options['recursivesubmodules'],
596  'headerlevel' => $level + 1,
597  'tocnumber' => &$subtocnumber,
598  'noheader' => false,
599  ] + $options;
600 
601  if ( $options['submodules'] && $module->getModuleManager() ) {
602  $manager = $module->getModuleManager();
603  $submodules = [];
604  foreach ( $groups as $group ) {
605  $names = $manager->getNames( $group );
606  sort( $names );
607  foreach ( $names as $name ) {
608  $submodules[] = $manager->getModule( $name );
609  }
610  }
611  $help['submodules'] .= self::getHelpInternal(
612  $context,
613  $submodules,
614  $suboptions,
615  $haveModules
616  );
617  }
618 
619  $module->modifyHelp( $help, $suboptions, $haveModules );
620 
621  $module->getHookRunner()->onAPIHelpModifyOutput( $module, $help,
622  $suboptions, $haveModules );
623 
624  $out .= implode( "\n", $help );
625  }
626 
627  return $out;
628  }
629 
630  public function shouldCheckMaxlag() {
631  return false;
632  }
633 
634  public function isReadMode() {
635  return false;
636  }
637 
638  public function getCustomPrinter() {
639  $params = $this->extractRequestParams();
640  if ( $params['wrap'] ) {
641  return null;
642  }
643 
644  $main = $this->getMain();
645  $errorPrinter = $main->createPrinterByName( $main->getParameter( 'format' ) );
646  return new ApiFormatRaw( $main, $errorPrinter );
647  }
648 
649  public function getAllowedParams() {
650  return [
651  'modules' => [
652  ApiBase::PARAM_DFLT => 'main',
653  ApiBase::PARAM_ISMULTI => true,
654  ],
655  'submodules' => false,
656  'recursivesubmodules' => false,
657  'wrap' => false,
658  'toc' => false,
659  ];
660  }
661 
662  protected function getExamplesMessages() {
663  return [
664  'action=help'
665  => 'apihelp-help-example-main',
666  'action=help&modules=query&submodules=1'
667  => 'apihelp-help-example-submodules',
668  'action=help&recursivesubmodules=1'
669  => 'apihelp-help-example-recursive',
670  'action=help&modules=help'
671  => 'apihelp-help-example-help',
672  'action=help&modules=query+info|query+categorymembers'
673  => 'apihelp-help-example-query',
674  ];
675  }
676 
677  public function getHelpUrls() {
678  return [
679  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page',
680  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:FAQ',
681  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Quick_start_guide',
682  ];
683  }
684 }
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:48
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:38
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:363
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:46
Linker\generateTOC
static generateTOC( $tree, Language $lang=null)
Generate a table of contents from a section tree.
Definition: Linker.php:1752
ApiHelp\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiHelp.php:662
ApiHelp\wrap
static wrap(Message $msg, $class, $tag='span')
Wrap a message in HTML with a class.
Definition: ApiHelp.php:228
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:173
true
return true
Definition: router.php:90
ApiHelp\isReadMode
isReadMode()
Indicates whether this module requires read rights.
Definition: ApiHelp.php:634
ApiBase\PARAM_TYPE
const PARAM_TYPE
Definition: ApiBase.php:72
ApiHelp\getHelpInternal
static getHelpInternal(IContextSource $context, array $modules, array $options, &$haveModules)
Recursively-called function to actually construct the help.
Definition: ApiHelp.php:243
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:561
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:107
ApiBase\makeMessage
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1171
ApiResult\NO_SIZE_CHECK
const NO_SIZE_CHECK
For addValue() and similar functions, do not check size while adding a value Don't use this unless yo...
Definition: ApiResult.php:58
Message\listParam
static listParam(array $list, $type='text')
Definition: Message.php:1115
FormatJson\UTF8_OK
const UTF8_OK
Skip escaping most characters above U+007F for readability and compactness.
Definition: FormatJson.php:34
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:55
ApiBase\getModuleFromPath
getModuleFromPath( $path)
Get a module from its module path.
Definition: ApiBase.php:523
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:151
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:443
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:318
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
Definition: ApiBase.php:77
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:32
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:115
MessageLocalizer\msg
msg( $key,... $params)
This is the method for getting translated interface messages.
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:2534
ApiBase\getModulePath
getModulePath()
Get the path to this module.
Definition: ApiBase.php:505
$modules
$modules
Definition: HTMLFormElement.php:15
ApiFormatRaw
Formatter that spits out anything you like with any desired MIME type.
Definition: ApiFormatRaw.php:27
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:720
ApiHelp\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiHelp.php:677
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:50
ApiHelp\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiHelp.php:649
SpecialVersion\getVersion
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
Definition: SpecialVersion.php:322
ApiHelp\fixHelpLinks
static fixHelpLinks( $html, $helptitle=null, $localModules=[])
Replace Special:ApiHelp links with links to api.php.
Definition: ApiHelp.php:188
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:176
Message\parse
parse()
Fully parse the text from wikitext to HTML.
Definition: Message.php:929
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:122
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:57
ApiBase\PARAM_TEMPLATE_VARS
const PARAM_TEMPLATE_VARS
(array) Indicate that this is a templated parameter, and specify replacements.
Definition: ApiBase.php:156
ApiHelp\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiHelp.php:35
$cache
$cache
Definition: mcc.php:33
ApiHelp\getHelp
static getHelp(IContextSource $context, $modules, array $options)
Generate help for the specified modules.
Definition: ApiHelp.php:114
IContextSource\getConfig
getConfig()
Get the site configuration.
$path
$path
Definition: NoLocalSettings.php:25
ApiBase\PARAM_DFLT
const PARAM_DFLT
Definition: ApiBase.php:70
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:254
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:212
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:440
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
Definition: ApiBase.php:71
Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:161
ApiHelp\shouldCheckMaxlag
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked.
Definition: ApiHelp.php:630
$help
$help
Definition: mcc.php:32
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:456
ApiHelp\getCustomPrinter
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
Definition: ApiHelp.php:638
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:234
IContextSource\getOutput
getOutput()
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:556
MediaWiki\ExtensionInfo
Definition: ExtensionInfo.php:8
Wikimedia\ParamValidator\ParamValidator
Service for formatting and validating API parameters.
Definition: ParamValidator.php:42
IContextSource\getLanguage
getLanguage()
ApiHelp
Class to output help for an API module.
Definition: ApiHelp.php:34