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 = $module->getParent()->getModuleManager()->getModuleGroup( $name ) .
285  "=$name";
286  if ( $module->getModulePrefix() !== '' ) {
287  $headerContent .= ' ' .
288  $context->msg( 'parentheses', $module->getModulePrefix() )->parse();
289  }
290  // Module names are always in English and not localized,
291  // so English language and direction must be set explicitly,
292  // otherwise parentheses will get broken in RTL wikis
293  $headerAttr = [
294  'class' => 'apihelp-header apihelp-module-name',
295  'dir' => 'ltr',
296  'lang' => 'en',
297  ];
298  }
299 
300  $headerAttr['id'] = $anchor;
301 
302  $haveModules[$anchor] = [
303  'toclevel' => count( $tocnumber ),
304  'level' => $level,
305  'anchor' => $anchor,
306  'line' => $headerContent,
307  'number' => implode( '.', $tocnumber ),
308  'index' => false,
309  ];
310  if ( empty( $options['noheader'] ) ) {
311  $help['header'] .= Html::element(
312  'h' . min( 6, $level ),
313  $headerAttr,
314  $headerContent
315  );
316  }
317  } else {
318  $haveModules[$path] = true;
319  }
320 
321  $links = [];
322  $any = false;
323  for ( $m = $module; $m !== null; $m = $m->getParent() ) {
324  $name = $m->getModuleName();
325  if ( $name === 'main_int' ) {
326  $name = 'main';
327  }
328 
329  if ( count( $modules ) === 1 && $m === $modules[0] &&
330  !( !empty( $options['submodules'] ) && $m->getModuleManager() )
331  ) {
332  $link = Html::element( 'b', [ 'dir' => 'ltr', 'lang' => 'en' ], $name );
333  } else {
334  $link = SpecialPage::getTitleFor( 'ApiHelp', $m->getModulePath() )->getLocalURL();
335  $link = Html::element( 'a',
336  [ 'href' => $link, 'class' => 'apihelp-linktrail', 'dir' => 'ltr', 'lang' => 'en' ],
337  $name
338  );
339  $any = true;
340  }
341  array_unshift( $links, $link );
342  }
343  if ( $any ) {
344  $help['header'] .= self::wrap(
345  $context->msg( 'parentheses' )
346  ->rawParams( $context->getLanguage()->pipeList( $links ) ),
347  'apihelp-linktrail', 'div'
348  );
349  }
350 
351  $flags = $module->getHelpFlags();
352  $help['flags'] .= Html::openElement( 'div',
353  [ 'class' => 'apihelp-block apihelp-flags' ] );
354  $msg = $context->msg( 'api-help-flags' );
355  if ( !$msg->isDisabled() ) {
356  $help['flags'] .= self::wrap(
357  $msg->numParams( count( $flags ) ), 'apihelp-block-head', 'div'
358  );
359  }
360  $help['flags'] .= Html::openElement( 'ul' );
361  foreach ( $flags as $flag ) {
362  $help['flags'] .= Html::rawElement( 'li', null,
363  self::wrap( $context->msg( "api-help-flag-$flag" ), "apihelp-flag-$flag" )
364  );
365  }
366  $sourceInfo = $module->getModuleSourceInfo();
367  if ( $sourceInfo ) {
368  if ( isset( $sourceInfo['namemsg'] ) ) {
369  $extname = $context->msg( $sourceInfo['namemsg'] )->text();
370  } else {
371  // Probably English, so wrap it.
372  $extname = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['name'] );
373  }
374  $help['flags'] .= Html::rawElement( 'li', null,
375  self::wrap(
376  $context->msg( 'api-help-source', $extname, $sourceInfo['name'] ),
377  'apihelp-source'
378  )
379  );
380 
381  $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] );
382  if ( isset( $sourceInfo['license-name'] ) ) {
383  $msg = $context->msg( 'api-help-license', $link,
384  Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['license-name'] )
385  );
386  } elseif ( ExtensionInfo::getLicenseFileNames( dirname( $sourceInfo['path'] ) ) ) {
387  $msg = $context->msg( 'api-help-license-noname', $link );
388  } else {
389  $msg = $context->msg( 'api-help-license-unknown' );
390  }
391  $help['flags'] .= Html::rawElement( 'li', null,
392  self::wrap( $msg, 'apihelp-license' )
393  );
394  } else {
395  $help['flags'] .= Html::rawElement( 'li', null,
396  self::wrap( $context->msg( 'api-help-source-unknown' ), 'apihelp-source' )
397  );
398  $help['flags'] .= Html::rawElement( 'li', null,
399  self::wrap( $context->msg( 'api-help-license-unknown' ), 'apihelp-license' )
400  );
401  }
402  $help['flags'] .= Html::closeElement( 'ul' );
403  $help['flags'] .= Html::closeElement( 'div' );
404 
405  foreach ( $module->getFinalDescription() as $msg ) {
406  $msg->setContext( $context );
407  $help['description'] .= $msg->parseAsBlock();
408  }
409 
410  $urls = $module->getHelpUrls();
411  if ( $urls ) {
412  if ( !is_array( $urls ) ) {
413  $urls = [ $urls ];
414  }
415  $help['help-urls'] .= Html::openElement( 'div',
416  [ 'class' => 'apihelp-block apihelp-help-urls' ]
417  );
418  $msg = $context->msg( 'api-help-help-urls' );
419  if ( !$msg->isDisabled() ) {
420  $help['help-urls'] .= self::wrap(
421  $msg->numParams( count( $urls ) ), 'apihelp-block-head', 'div'
422  );
423  }
424  $help['help-urls'] .= Html::openElement( 'ul' );
425  foreach ( $urls as $url ) {
426  $help['help-urls'] .= Html::rawElement( 'li', null,
427  Html::element( 'a', [ 'href' => $url, 'dir' => 'ltr' ], $url )
428  );
429  }
430  $help['help-urls'] .= Html::closeElement( 'ul' );
431  $help['help-urls'] .= Html::closeElement( 'div' );
432  }
433 
434  $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
435  $dynamicParams = $module->dynamicParameterDocumentation();
436  $groups = [];
437  if ( $params || $dynamicParams !== null ) {
438  $help['parameters'] .= Html::openElement( 'div',
439  [ 'class' => 'apihelp-block apihelp-parameters' ]
440  );
441  $msg = $context->msg( 'api-help-parameters' );
442  if ( !$msg->isDisabled() ) {
443  $help['parameters'] .= self::wrap(
444  $msg->numParams( count( $params ) ), 'apihelp-block-head', 'div'
445  );
446  }
447  $help['parameters'] .= Html::openElement( 'dl' );
448 
449  $descriptions = $module->getFinalParamDescription();
450 
451  foreach ( $params as $name => $settings ) {
452  $settings = $paramValidator->normalizeSettings( $settings );
453 
454  if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
455  $groups[] = $name;
456  }
457 
458  $help['parameters'] .= Html::rawElement( 'dt', null,
459  Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $module->encodeParamName( $name ) )
460  );
461 
462  // Add description
463  $description = [];
464  if ( isset( $descriptions[$name] ) ) {
465  foreach ( $descriptions[$name] as $msg ) {
466  $msg->setContext( $context );
467  $description[] = $msg->parseAsBlock();
468  }
469  }
470  if ( !array_filter( $description ) ) {
471  $description = [ self::wrap(
472  $context->msg( 'api-help-param-no-description' ),
473  'apihelp-empty'
474  ) ];
475  }
476 
477  // Add "deprecated" flag
478  if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
479  $help['parameters'] .= Html::openElement( 'dd',
480  [ 'class' => 'info' ] );
481  $help['parameters'] .= self::wrap(
482  $context->msg( 'api-help-param-deprecated' ),
483  'apihelp-deprecated', 'strong'
484  );
485  $help['parameters'] .= Html::closeElement( 'dd' );
486  }
487 
488  if ( $description ) {
489  $description = implode( '', $description );
490  $description = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $description );
491  $help['parameters'] .= Html::rawElement( 'dd',
492  [ 'class' => 'description' ], $description );
493  }
494 
495  // Add usage info
496  $info = [];
497  $paramHelp = $paramValidator->getHelpInfo( $module, $name, $settings, [] );
498 
499  unset( $paramHelp[ParamValidator::PARAM_DEPRECATED] );
500 
501  if ( isset( $paramHelp[ParamValidator::PARAM_REQUIRED] ) ) {
502  $paramHelp[ParamValidator::PARAM_REQUIRED]->setContext( $context );
503  $info[] = $paramHelp[ParamValidator::PARAM_REQUIRED];
504  unset( $paramHelp[ParamValidator::PARAM_REQUIRED] );
505  }
506 
507  // Custom info?
508  if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
509  foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
510  $tag = array_shift( $i );
511  $info[] = $context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
512  ->numParams( count( $i ) )
513  ->params( $context->getLanguage()->commaList( $i ) )
514  ->params( $module->getModulePrefix() )
515  ->parse();
516  }
517  }
518 
519  // Templated?
520  if ( !empty( $settings[ApiBase::PARAM_TEMPLATE_VARS] ) ) {
521  $vars = [];
522  $msg = 'api-help-param-templated-var-first';
523  foreach ( $settings[ApiBase::PARAM_TEMPLATE_VARS] as $k => $v ) {
524  $vars[] = $context->msg( $msg, $k, $module->encodeParamName( $v ) );
525  $msg = 'api-help-param-templated-var';
526  }
527  $info[] = $context->msg( 'api-help-param-templated' )
528  ->numParams( count( $vars ) )
529  ->params( Message::listParam( $vars ) )
530  ->parse();
531  }
532 
533  // Type documentation
534  foreach ( $paramHelp as $m ) {
535  $m->setContext( $context );
536  $info[] = $m;
537  }
538 
539  foreach ( $info as $i ) {
540  $help['parameters'] .= Html::rawElement( 'dd', [ 'class' => 'info' ], $i );
541  }
542  }
543 
544  if ( $dynamicParams !== null ) {
545  $dynamicParams = ApiBase::makeMessage( $dynamicParams, $context, [
546  $module->getModulePrefix(),
547  $module->getModuleName(),
548  $module->getModulePath()
549  ] );
550  $help['parameters'] .= Html::element( 'dt', null, '*' );
551  $help['parameters'] .= Html::rawElement( 'dd',
552  [ 'class' => 'description' ], $dynamicParams->parse() );
553  }
554 
555  $help['parameters'] .= Html::closeElement( 'dl' );
556  $help['parameters'] .= Html::closeElement( 'div' );
557  }
558 
559  $examples = $module->getExamplesMessages();
560  if ( $examples ) {
561  $help['examples'] .= Html::openElement( 'div',
562  [ 'class' => 'apihelp-block apihelp-examples' ] );
563  $msg = $context->msg( 'api-help-examples' );
564  if ( !$msg->isDisabled() ) {
565  $help['examples'] .= self::wrap(
566  $msg->numParams( count( $examples ) ), 'apihelp-block-head', 'div'
567  );
568  }
569 
570  $help['examples'] .= Html::openElement( 'dl' );
571  foreach ( $examples as $qs => $msg ) {
572  $msg = ApiBase::makeMessage( $msg, $context, [
573  $module->getModulePrefix(),
574  $module->getModuleName(),
575  $module->getModulePath()
576  ] );
577 
578  $link = wfAppendQuery( wfScript( 'api' ), $qs );
579  $sandbox = SpecialPage::getTitleFor( 'ApiSandbox' )->getLocalURL() . '#' . $qs;
580  $help['examples'] .= Html::rawElement( 'dt', null, $msg->parse() );
581  $help['examples'] .= Html::rawElement( 'dd', null,
582  Html::element( 'a', [ 'href' => $link, 'dir' => 'ltr' ], "api.php?$qs" ) . ' ' .
583  Html::rawElement( 'a', [ 'href' => $sandbox ],
584  $context->msg( 'api-help-open-in-apisandbox' )->parse() )
585  );
586  }
587  $help['examples'] .= Html::closeElement( 'dl' );
588  $help['examples'] .= Html::closeElement( 'div' );
589  }
590 
591  $subtocnumber = $tocnumber;
592  $subtocnumber[$level + 1] = 0;
593  $suboptions = [
594  'submodules' => $options['recursivesubmodules'],
595  'headerlevel' => $level + 1,
596  'tocnumber' => &$subtocnumber,
597  'noheader' => false,
598  ] + $options;
599 
600  if ( $options['submodules'] && $module->getModuleManager() ) {
601  $manager = $module->getModuleManager();
602  $submodules = [];
603  foreach ( $groups as $group ) {
604  $names = $manager->getNames( $group );
605  sort( $names );
606  foreach ( $names as $name ) {
607  $submodules[] = $manager->getModule( $name );
608  }
609  }
610  $help['submodules'] .= self::getHelpInternal(
611  $context,
612  $submodules,
613  $suboptions,
614  $haveModules
615  );
616  }
617 
618  $module->modifyHelp( $help, $suboptions, $haveModules );
619 
620  $module->getHookRunner()->onAPIHelpModifyOutput( $module, $help,
621  $suboptions, $haveModules );
622 
623  $out .= implode( "\n", $help );
624  }
625 
626  return $out;
627  }
628 
629  public function shouldCheckMaxlag() {
630  return false;
631  }
632 
633  public function isReadMode() {
634  return false;
635  }
636 
637  public function getCustomPrinter() {
638  $params = $this->extractRequestParams();
639  if ( $params['wrap'] ) {
640  return null;
641  }
642 
643  $main = $this->getMain();
644  $errorPrinter = $main->createPrinterByName( $main->getParameter( 'format' ) );
645  return new ApiFormatRaw( $main, $errorPrinter );
646  }
647 
648  public function getAllowedParams() {
649  return [
650  'modules' => [
651  ApiBase::PARAM_DFLT => 'main',
652  ApiBase::PARAM_ISMULTI => true,
653  ],
654  'submodules' => false,
655  'recursivesubmodules' => false,
656  'wrap' => false,
657  'toc' => false,
658  ];
659  }
660 
661  protected function getExamplesMessages() {
662  return [
663  'action=help'
664  => 'apihelp-help-example-main',
665  'action=help&modules=query&submodules=1'
666  => 'apihelp-help-example-submodules',
667  'action=help&recursivesubmodules=1'
668  => 'apihelp-help-example-recursive',
669  'action=help&modules=help'
670  => 'apihelp-help-example-help',
671  'action=help&modules=query+info|query+categorymembers'
672  => 'apihelp-help-example-query',
673  ];
674  }
675 
676  public function getHelpUrls() {
677  return [
678  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page',
679  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:FAQ',
680  'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Quick_start_guide',
681  ];
682  }
683 }
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:37
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:328
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:45
Linker\generateTOC
static generateTOC( $tree, Language $lang=null)
Generate a table of contents from a section tree.
Definition: Linker.php:1764
ApiHelp\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiHelp.php:661
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:165
true
return true
Definition: router.php:90
ApiHelp\isReadMode
isReadMode()
Indicates whether this module requires read rights Stable to override.
Definition: ApiHelp.php:633
ApiBase\PARAM_TYPE
const PARAM_TYPE
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:70
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:564
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:106
ApiBase\makeMessage
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition: ApiBase.php:1164
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:1112
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:52
ApiBase\getModuleFromPath
getModuleFromPath( $path)
Get a module from its module path.
Definition: ApiBase.php:526
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:143
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:438
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:318
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:75
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:31
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:2515
ApiBase\getModulePath
getModulePath()
Get the path to this module.
Definition: ApiBase.php:508
$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:713
ApiHelp\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiHelp.php:676
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:47
ApiHelp\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiHelp.php:648
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:177
Message\parse
parse()
Fully parse the text from wikitext to HTML.
Definition: Message.php:927
ApiBase\PARAM_HELP_MSG_INFO
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition: ApiBase.php:123
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
ApiBase\PARAM_TEMPLATE_VARS
const PARAM_TEMPLATE_VARS
(array) Indicate that this is a templated parameter, and specify replacements.
Definition: ApiBase.php:157
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
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:68
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:443
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Inverse of IntegerDef::PARAM_IGNORE_RANGE
Definition: ApiBase.php:69
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 Stable to override.
Definition: ApiHelp.php:629
$help
$help
Definition: mcc.php:32
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:459
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:637
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: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