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