MediaWiki REL1_37
ApiHelp.php
Go to the documentation of this file.
1<?php
23use HtmlFormatter\HtmlFormatter;
27
34class 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', null,
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', null,
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', null,
410 self::wrap( $msg, 'apihelp-license' )
411 );
412 } else {
413 $help['flags'] .= Html::rawElement( 'li', null,
414 self::wrap( $context->msg( 'api-help-source-unknown' ), 'apihelp-source' )
415 );
416 $help['flags'] .= Html::rawElement( 'li', null,
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', null,
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', null,
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', null, '*' );
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', null, $msg->parse() );
599 $help['examples'] .= Html::rawElement( 'dd', null,
600 Html::element( 'a', [
601 'href' => $link,
602 'dir' => 'ltr',
603 'rel' => 'nofollow',
604 ], "api.php?$qs" ) . ' ' .
605 Html::rawElement( 'a', [ 'href' => $sandbox ],
606 $context->msg( 'api-help-open-in-apisandbox' )->parse() )
607 );
608 }
609 $help['examples'] .= Html::closeElement( 'dl' );
610 $help['examples'] .= Html::closeElement( 'div' );
611 }
612
613 $subtocnumber = $tocnumber;
614 $subtocnumber[$level + 1] = 0;
615 $suboptions = [
616 'submodules' => $options['recursivesubmodules'],
617 'headerlevel' => $level + 1,
618 'tocnumber' => &$subtocnumber,
619 'noheader' => false,
620 ] + $options;
621
622 if ( $options['submodules'] && $module->getModuleManager() ) {
623 $manager = $module->getModuleManager();
624 $submodules = [];
625 foreach ( $groups as $group ) {
626 $names = $manager->getNames( $group );
627 sort( $names );
628 foreach ( $names as $name ) {
629 $submodules[] = $manager->getModule( $name );
630 }
631 }
632 $help['submodules'] .= self::getHelpInternal(
633 $context,
634 $submodules,
635 $suboptions,
636 $haveModules
637 );
638 }
639
640 $module->modifyHelp( $help, $suboptions, $haveModules );
641
642 $module->getHookRunner()->onAPIHelpModifyOutput( $module, $help,
643 $suboptions, $haveModules );
644
645 $out .= implode( "\n", $help );
646 }
647
648 return $out;
649 }
650
651 public function shouldCheckMaxlag() {
652 return false;
653 }
654
655 public function isReadMode() {
656 return false;
657 }
658
659 public function getCustomPrinter() {
660 $params = $this->extractRequestParams();
661 if ( $params['wrap'] ) {
662 return null;
663 }
664
665 $main = $this->getMain();
666 $errorPrinter = $main->createPrinterByName( $main->getParameter( 'format' ) );
667 return new ApiFormatRaw( $main, $errorPrinter );
668 }
669
670 public function getAllowedParams() {
671 return [
672 'modules' => [
673 ApiBase::PARAM_DFLT => 'main',
675 ],
676 'submodules' => false,
677 'recursivesubmodules' => false,
678 'wrap' => false,
679 'toc' => false,
680 ];
681 }
682
683 protected function getExamplesMessages() {
684 return [
685 'action=help'
686 => 'apihelp-help-example-main',
687 'action=help&modules=query&submodules=1'
688 => 'apihelp-help-example-submodules',
689 'action=help&recursivesubmodules=1'
690 => 'apihelp-help-example-recursive',
691 'action=help&modules=help'
692 => 'apihelp-help-example-help',
693 'action=help&modules=query+info|query+categorymembers'
694 => 'apihelp-help-example-query',
695 ];
696 }
697
698 public function getHelpUrls() {
699 return [
700 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page',
701 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:FAQ',
702 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Quick_start_guide',
703 ];
704 }
705}
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
This abstract class implements many basic API functions, and is the base of all API classes.
Definition ApiBase.php:55
const PARAM_DEPRECATED
Definition ApiBase.php:101
getModuleFromPath( $path)
Get a module from its module path.
Definition ApiBase.php:590
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition ApiBase.php:1216
getMain()
Get the main module.
Definition ApiBase.php:513
const PARAM_TYPE
Definition ApiBase.php:81
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition ApiBase.php:179
const PARAM_DFLT
Definition ApiBase.php:73
const PARAM_TEMPLATE_VARS
(array) Indicate that this is a templated parameter, and specify replacements.
Definition ApiBase.php:213
getResult()
Get the result object.
Definition ApiBase.php:628
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:764
getModulePath()
Get the path to this module.
Definition ApiBase.php:572
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
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:497
const PARAM_ISMULTI
Definition ApiBase.php:77
Formatter that spits out anything you like with any desired MIME type.
Class to output help for an API module.
Definition ApiHelp.php:34
static wrap(Message $msg, $class, $tag='span')
Wrap a message in HTML with a class.
Definition ApiHelp.php:245
isReadMode()
Indicates whether this module requires read rights.
Definition ApiHelp.php:655
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition ApiHelp.php:52
getExamplesMessages()
Returns usage examples for this module.
Definition ApiHelp.php:683
static fixHelpLinks( $html, $helptitle=null, $localModules=[])
Replace Special:ApiHelp links with links to api.php.
Definition ApiHelp.php:205
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition ApiHelp.php:670
getHelpUrls()
Return links to more detailed help pages about the module.
Definition ApiHelp.php:698
SkinFactory $skinFactory
Definition ApiHelp.php:36
static getHelpInternal(IContextSource $context, array $modules, array $options, &$haveModules)
Recursively-called function to actually construct the help.
Definition ApiHelp.php:260
static getHelp(IContextSource $context, $modules, array $options)
Generate help for the specified modules.
Definition ApiHelp.php:130
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked.
Definition ApiHelp.php:651
__construct(ApiMain $main, $action, SkinFactory $skinFactory)
Definition ApiHelp.php:43
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
Definition ApiHelp.php:659
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:49
IContextSource $context
getContext()
Get the base IContextSource object.
An IContextSource implementation which will inherit context from another source but allow individual ...
static generateTOC( $tree, Language $lang=null)
Generate a table of contents from a section tree.
Definition Linker.php:1934
MediaWikiServices is the service locator for the application scope of MediaWiki.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:138
static listParam(array $list, $type='text')
Definition Message.php:1211
parse()
Fully parse the text from wikitext to HTML.
Definition Message.php:997
This is one of the Core classes and should be read at least once by any new developers.
Factory class to create Skin objects.
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,...
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
Service for formatting and validating API parameters.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
msg( $key,... $params)
This is the method for getting translated interface messages.
$cache
Definition mcc.php:33
$help
Definition mcc.php:32
return true
Definition router.php:92