MediaWiki REL1_35
ApiHelp.php
Go to the documentation of this file.
1<?php
23use HtmlFormatter\HtmlFormatter;
27
34class 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 if ( !empty( $options['toc'] ) ) {
125 $out->addModuleStyles( 'mediawiki.toc.styles' );
126 }
127 $out->setPageTitle( $context->msg( 'api-help-title' ) );
128
129 $services = MediaWikiServices::getInstance();
130 $cache = $services->getMainWANObjectCache();
131 $cacheKey = null;
132 if ( count( $modules ) == 1 && $modules[0] instanceof ApiMain &&
133 $options['recursivesubmodules'] &&
134 $context->getLanguage()->equals( $services->getContentLanguage() )
135 ) {
136 $cacheHelpTimeout = $context->getConfig()->get( 'APICacheHelpTimeout' );
137 if ( $cacheHelpTimeout > 0 ) {
138 // Get help text from cache if present
139 $cacheKey = $cache->makeKey( 'apihelp', $modules[0]->getModulePath(),
140 (int)!empty( $options['toc'] ),
141 str_replace( ' ', '_', SpecialVersion::getVersion( 'nodb' ) ) );
142 $cached = $cache->get( $cacheKey );
143 if ( $cached ) {
144 $out->addHTML( $cached );
145 return;
146 }
147 }
148 }
149 if ( $out->getHTML() !== '' ) {
150 // Don't save to cache, there's someone else's content in the page
151 // already
152 $cacheKey = null;
153 }
154
155 $options['recursivesubmodules'] = !empty( $options['recursivesubmodules'] );
156 $options['submodules'] = $options['recursivesubmodules'] || !empty( $options['submodules'] );
157
158 // Prepend lead
159 if ( empty( $options['nolead'] ) ) {
160 $msg = $context->msg( 'api-help-lead' );
161 if ( !$msg->isDisabled() ) {
162 $out->addHTML( $msg->parseAsBlock() );
163 }
164 }
165
166 $haveModules = [];
167 $html = self::getHelpInternal( $context, $modules, $options, $haveModules );
168 if ( !empty( $options['toc'] ) && $haveModules ) {
169 $out->addHTML( Linker::generateTOC( $haveModules, $context->getLanguage() ) );
170 }
171 $out->addHTML( $html );
172
173 $helptitle = $options['helptitle'] ?? null;
174 $html = self::fixHelpLinks( $out->getHTML(), $helptitle, $haveModules );
175 $out->clearHTML();
176 $out->addHTML( $html );
177
178 if ( $cacheKey !== null ) {
179 $cache->set( $cacheKey, $out->getHTML(), $cacheHelpTimeout );
180 }
181 }
182
191 public static function fixHelpLinks( $html, $helptitle = null, $localModules = [] ) {
192 $formatter = new HtmlFormatter( $html );
193 $doc = $formatter->getDoc();
194 $xpath = new DOMXPath( $doc );
195 $nodes = $xpath->query( '//a[@href][not(contains(@class,\'apihelp-linktrail\'))]' );
197 foreach ( $nodes as $node ) {
198 $href = $node->getAttribute( 'href' );
199 do {
200 $old = $href;
201 $href = rawurldecode( $href );
202 } while ( $old !== $href );
203 if ( preg_match( '!Special:ApiHelp/([^&/|#]+)((?:#.*)?)!', $href, $m ) ) {
204 if ( isset( $localModules[$m[1]] ) ) {
205 $href = $m[2] === '' ? '#' . $m[1] : $m[2];
206 } elseif ( $helptitle !== null ) {
207 $href = Title::newFromText( str_replace( '$1', $m[1], $helptitle ) . $m[2] )
208 ->getFullURL();
209 } else {
210 $href = wfAppendQuery( wfScript( 'api' ), [
211 'action' => 'help',
212 'modules' => $m[1],
213 ] ) . $m[2];
214 }
215 $node->setAttribute( 'href', $href );
216 $node->removeAttribute( 'title' );
217 }
218 }
219
220 return $formatter->getText();
221 }
222
231 private static function wrap( Message $msg, $class, $tag = 'span' ) {
232 return Html::rawElement( $tag, [ 'class' => $class ],
233 $msg->parse()
234 );
235 }
236
246 private static function getHelpInternal( IContextSource $context, array $modules,
247 array $options, &$haveModules
248 ) {
249 $out = '';
250
251 $level = empty( $options['headerlevel'] ) ? 2 : $options['headerlevel'];
252 if ( empty( $options['tocnumber'] ) ) {
253 $tocnumber = [ 2 => 0 ];
254 } else {
255 $tocnumber = &$options['tocnumber'];
256 }
257
258 foreach ( $modules as $module ) {
259 $paramValidator = $module->getMain()->getParamValidator();
260 $tocnumber[$level]++;
261 $path = $module->getModulePath();
262 $module->setContext( $context );
263 $help = [
264 'header' => '',
265 'flags' => '',
266 'description' => '',
267 'help-urls' => '',
268 'parameters' => '',
269 'examples' => '',
270 'submodules' => '',
271 ];
272
273 if ( empty( $options['noheader'] ) || !empty( $options['toc'] ) ) {
274 $anchor = $path;
275 $i = 1;
276 while ( isset( $haveModules[$anchor] ) ) {
277 $anchor = $path . '|' . ++$i;
278 }
279
280 if ( $module->isMain() ) {
281 $headerContent = $context->msg( 'api-help-main-header' )->parse();
282 $headerAttr = [
283 'class' => 'apihelp-header',
284 ];
285 } else {
286 $name = $module->getModuleName();
287 $headerContent = $module->getParent()->getModuleManager()->getModuleGroup( $name ) .
288 "=$name";
289 if ( $module->getModulePrefix() !== '' ) {
290 $headerContent .= ' ' .
291 $context->msg( 'parentheses', $module->getModulePrefix() )->parse();
292 }
293 // Module names are always in English and not localized,
294 // so English language and direction must be set explicitly,
295 // otherwise parentheses will get broken in RTL wikis
296 $headerAttr = [
297 'class' => 'apihelp-header apihelp-module-name',
298 'dir' => 'ltr',
299 'lang' => 'en',
300 ];
301 }
302
303 $headerAttr['id'] = $anchor;
304
305 $haveModules[$anchor] = [
306 'toclevel' => count( $tocnumber ),
307 'level' => $level,
308 'anchor' => $anchor,
309 'line' => $headerContent,
310 'number' => implode( '.', $tocnumber ),
311 'index' => false,
312 ];
313 if ( empty( $options['noheader'] ) ) {
314 $help['header'] .= Html::element(
315 'h' . min( 6, $level ),
316 $headerAttr,
317 $headerContent
318 );
319 }
320 } else {
321 $haveModules[$path] = true;
322 }
323
324 $links = [];
325 $any = false;
326 for ( $m = $module; $m !== null; $m = $m->getParent() ) {
327 $name = $m->getModuleName();
328 if ( $name === 'main_int' ) {
329 $name = 'main';
330 }
331
332 if ( count( $modules ) === 1 && $m === $modules[0] &&
333 !( !empty( $options['submodules'] ) && $m->getModuleManager() )
334 ) {
335 $link = Html::element( 'b', [ 'dir' => 'ltr', 'lang' => 'en' ], $name );
336 } else {
337 $link = SpecialPage::getTitleFor( 'ApiHelp', $m->getModulePath() )->getLocalURL();
338 $link = Html::element( 'a',
339 [ 'href' => $link, 'class' => 'apihelp-linktrail', 'dir' => 'ltr', 'lang' => 'en' ],
340 $name
341 );
342 $any = true;
343 }
344 array_unshift( $links, $link );
345 }
346 if ( $any ) {
347 $help['header'] .= self::wrap(
348 $context->msg( 'parentheses' )
349 ->rawParams( $context->getLanguage()->pipeList( $links ) ),
350 'apihelp-linktrail', 'div'
351 );
352 }
353
354 $flags = $module->getHelpFlags();
355 $help['flags'] .= Html::openElement( 'div',
356 [ 'class' => 'apihelp-block apihelp-flags' ] );
357 $msg = $context->msg( 'api-help-flags' );
358 if ( !$msg->isDisabled() ) {
359 $help['flags'] .= self::wrap(
360 $msg->numParams( count( $flags ) ), 'apihelp-block-head', 'div'
361 );
362 }
363 $help['flags'] .= Html::openElement( 'ul' );
364 foreach ( $flags as $flag ) {
365 $help['flags'] .= Html::rawElement( 'li', null,
366 self::wrap( $context->msg( "api-help-flag-$flag" ), "apihelp-flag-$flag" )
367 );
368 }
369 $sourceInfo = $module->getModuleSourceInfo();
370 if ( $sourceInfo ) {
371 if ( isset( $sourceInfo['namemsg'] ) ) {
372 $extname = $context->msg( $sourceInfo['namemsg'] )->text();
373 } else {
374 // Probably English, so wrap it.
375 $extname = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['name'] );
376 }
377 $help['flags'] .= Html::rawElement( 'li', null,
378 self::wrap(
379 $context->msg( 'api-help-source', $extname, $sourceInfo['name'] ),
380 'apihelp-source'
381 )
382 );
383
384 $link = SpecialPage::getTitleFor( 'Version', 'License/' . $sourceInfo['name'] );
385 if ( isset( $sourceInfo['license-name'] ) ) {
386 $msg = $context->msg( 'api-help-license', $link,
387 Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $sourceInfo['license-name'] )
388 );
389 } elseif ( ExtensionInfo::getLicenseFileNames( dirname( $sourceInfo['path'] ) ) ) {
390 $msg = $context->msg( 'api-help-license-noname', $link );
391 } else {
392 $msg = $context->msg( 'api-help-license-unknown' );
393 }
394 $help['flags'] .= Html::rawElement( 'li', null,
395 self::wrap( $msg, 'apihelp-license' )
396 );
397 } else {
398 $help['flags'] .= Html::rawElement( 'li', null,
399 self::wrap( $context->msg( 'api-help-source-unknown' ), 'apihelp-source' )
400 );
401 $help['flags'] .= Html::rawElement( 'li', null,
402 self::wrap( $context->msg( 'api-help-license-unknown' ), 'apihelp-license' )
403 );
404 }
405 $help['flags'] .= Html::closeElement( 'ul' );
406 $help['flags'] .= Html::closeElement( 'div' );
407
408 foreach ( $module->getFinalDescription() as $msg ) {
409 $msg->setContext( $context );
410 $help['description'] .= $msg->parseAsBlock();
411 }
412
413 $urls = $module->getHelpUrls();
414 if ( $urls ) {
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 if ( !is_array( $urls ) ) {
425 $urls = [ $urls ];
426 }
427 $help['help-urls'] .= Html::openElement( 'ul' );
428 foreach ( $urls as $url ) {
429 $help['help-urls'] .= Html::rawElement( 'li', null,
430 Html::element( 'a', [ 'href' => $url, 'dir' => 'ltr' ], $url )
431 );
432 }
433 $help['help-urls'] .= Html::closeElement( 'ul' );
434 $help['help-urls'] .= Html::closeElement( 'div' );
435 }
436
437 $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
438 $dynamicParams = $module->dynamicParameterDocumentation();
439 $groups = [];
440 if ( $params || $dynamicParams !== null ) {
441 $help['parameters'] .= Html::openElement( 'div',
442 [ 'class' => 'apihelp-block apihelp-parameters' ]
443 );
444 $msg = $context->msg( 'api-help-parameters' );
445 if ( !$msg->isDisabled() ) {
446 $help['parameters'] .= self::wrap(
447 $msg->numParams( count( $params ) ), 'apihelp-block-head', 'div'
448 );
449 }
450 $help['parameters'] .= Html::openElement( 'dl' );
451
452 $descriptions = $module->getFinalParamDescription();
453
454 foreach ( $params as $name => $settings ) {
455 $settings = $paramValidator->normalizeSettings( $settings );
456
457 if ( $settings[ApiBase::PARAM_TYPE] === 'submodule' ) {
458 $groups[] = $name;
459 }
460
461 $help['parameters'] .= Html::rawElement( 'dt', null,
462 Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $module->encodeParamName( $name ) )
463 );
464
465 // Add description
466 $description = [];
467 if ( isset( $descriptions[$name] ) ) {
468 foreach ( $descriptions[$name] as $msg ) {
469 $msg->setContext( $context );
470 $description[] = $msg->parseAsBlock();
471 }
472 }
473 if ( !array_filter( $description ) ) {
474 $description = [ self::wrap(
475 $context->msg( 'api-help-param-no-description' ),
476 'apihelp-empty'
477 ) ];
478 }
479
480 // Add "deprecated" flag
481 if ( !empty( $settings[ApiBase::PARAM_DEPRECATED] ) ) {
482 $help['parameters'] .= Html::openElement( 'dd',
483 [ 'class' => 'info' ] );
484 $help['parameters'] .= self::wrap(
485 $context->msg( 'api-help-param-deprecated' ),
486 'apihelp-deprecated', 'strong'
487 );
488 $help['parameters'] .= Html::closeElement( 'dd' );
489 }
490
491 if ( $description ) {
492 $description = implode( '', $description );
493 $description = preg_replace( '!\s*</([oud]l)>\s*<\1>\s*!', "\n", $description );
494 $help['parameters'] .= Html::rawElement( 'dd',
495 [ 'class' => 'description' ], $description );
496 }
497
498 // Add usage info
499 $info = [];
500 $paramHelp = $paramValidator->getHelpInfo( $module, $name, $settings, [] );
501
502 unset( $paramHelp[ParamValidator::PARAM_DEPRECATED] );
503
504 if ( isset( $paramHelp[ParamValidator::PARAM_REQUIRED] ) ) {
505 $paramHelp[ParamValidator::PARAM_REQUIRED]->setContext( $context );
506 $info[] = $paramHelp[ParamValidator::PARAM_REQUIRED];
507 unset( $paramHelp[ParamValidator::PARAM_REQUIRED] );
508 }
509
510 // Custom info?
511 if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
512 foreach ( $settings[ApiBase::PARAM_HELP_MSG_INFO] as $i ) {
513 $tag = array_shift( $i );
514 $info[] = $context->msg( "apihelp-{$path}-paraminfo-{$tag}" )
515 ->numParams( count( $i ) )
516 ->params( $context->getLanguage()->commaList( $i ) )
517 ->params( $module->getModulePrefix() )
518 ->parse();
519 }
520 }
521
522 // Templated?
523 if ( !empty( $settings[ApiBase::PARAM_TEMPLATE_VARS] ) ) {
524 $vars = [];
525 $msg = 'api-help-param-templated-var-first';
526 foreach ( $settings[ApiBase::PARAM_TEMPLATE_VARS] as $k => $v ) {
527 $vars[] = $context->msg( $msg, $k, $module->encodeParamName( $v ) );
528 $msg = 'api-help-param-templated-var';
529 }
530 $info[] = $context->msg( 'api-help-param-templated' )
531 ->numParams( count( $vars ) )
532 ->params( Message::listParam( $vars ) )
533 ->parse();
534 }
535
536 // Type documentation
537 foreach ( $paramHelp as $m ) {
538 $m->setContext( $context );
539 $info[] = $m;
540 }
541
542 foreach ( $info as $i ) {
543 $help['parameters'] .= Html::rawElement( 'dd', [ 'class' => 'info' ], $i );
544 }
545 }
546
547 if ( $dynamicParams !== null ) {
548 $dynamicParams = ApiBase::makeMessage( $dynamicParams, $context, [
549 $module->getModulePrefix(),
550 $module->getModuleName(),
551 $module->getModulePath()
552 ] );
553 $help['parameters'] .= Html::element( 'dt', null, '*' );
554 $help['parameters'] .= Html::rawElement( 'dd',
555 [ 'class' => 'description' ], $dynamicParams->parse() );
556 }
557
558 $help['parameters'] .= Html::closeElement( 'dl' );
559 $help['parameters'] .= Html::closeElement( 'div' );
560 }
561
562 $examples = $module->getExamplesMessages();
563 if ( $examples ) {
564 $help['examples'] .= Html::openElement( 'div',
565 [ 'class' => 'apihelp-block apihelp-examples' ] );
566 $msg = $context->msg( 'api-help-examples' );
567 if ( !$msg->isDisabled() ) {
568 $help['examples'] .= self::wrap(
569 $msg->numParams( count( $examples ) ), 'apihelp-block-head', 'div'
570 );
571 }
572
573 $help['examples'] .= Html::openElement( 'dl' );
574 foreach ( $examples as $qs => $msg ) {
575 $msg = ApiBase::makeMessage( $msg, $context, [
576 $module->getModulePrefix(),
577 $module->getModuleName(),
578 $module->getModulePath()
579 ] );
580
581 $link = wfAppendQuery( wfScript( 'api' ), $qs );
582 $sandbox = SpecialPage::getTitleFor( 'ApiSandbox' )->getLocalURL() . '#' . $qs;
583 $help['examples'] .= Html::rawElement( 'dt', null, $msg->parse() );
584 $help['examples'] .= Html::rawElement( 'dd', null,
585 Html::element( 'a', [
586 'href' => $link,
587 'dir' => 'ltr',
588 'rel' => 'nofollow',
589 ], "api.php?$qs" ) . ' ' .
590 Html::rawElement( 'a', [ 'href' => $sandbox ],
591 $context->msg( 'api-help-open-in-apisandbox' )->parse() )
592 );
593 }
594 $help['examples'] .= Html::closeElement( 'dl' );
595 $help['examples'] .= Html::closeElement( 'div' );
596 }
597
598 $subtocnumber = $tocnumber;
599 $subtocnumber[$level + 1] = 0;
600 $suboptions = [
601 'submodules' => $options['recursivesubmodules'],
602 'headerlevel' => $level + 1,
603 'tocnumber' => &$subtocnumber,
604 'noheader' => false,
605 ] + $options;
606
607 if ( $options['submodules'] && $module->getModuleManager() ) {
608 $manager = $module->getModuleManager();
609 $submodules = [];
610 foreach ( $groups as $group ) {
611 $names = $manager->getNames( $group );
612 sort( $names );
613 foreach ( $names as $name ) {
614 $submodules[] = $manager->getModule( $name );
615 }
616 }
617 $help['submodules'] .= self::getHelpInternal(
618 $context,
619 $submodules,
620 $suboptions,
621 $haveModules
622 );
623 }
624
625 $module->modifyHelp( $help, $suboptions, $haveModules );
626
627 $module->getHookRunner()->onAPIHelpModifyOutput( $module, $help,
628 $suboptions, $haveModules );
629
630 $out .= implode( "\n", $help );
631 }
632
633 return $out;
634 }
635
636 public function shouldCheckMaxlag() {
637 return false;
638 }
639
640 public function isReadMode() {
641 return false;
642 }
643
644 public function getCustomPrinter() {
645 $params = $this->extractRequestParams();
646 if ( $params['wrap'] ) {
647 return null;
648 }
649
650 $main = $this->getMain();
651 $errorPrinter = $main->createPrinterByName( $main->getParameter( 'format' ) );
652 return new ApiFormatRaw( $main, $errorPrinter );
653 }
654
655 public function getAllowedParams() {
656 return [
657 'modules' => [
658 ApiBase::PARAM_DFLT => 'main',
660 ],
661 'submodules' => false,
662 'recursivesubmodules' => false,
663 'wrap' => false,
664 'toc' => false,
665 ];
666 }
667
668 protected function getExamplesMessages() {
669 return [
670 'action=help'
671 => 'apihelp-help-example-main',
672 'action=help&modules=query&submodules=1'
673 => 'apihelp-help-example-submodules',
674 'action=help&recursivesubmodules=1'
675 => 'apihelp-help-example-recursive',
676 'action=help&modules=help'
677 => 'apihelp-help-example-help',
678 'action=help&modules=query+info|query+categorymembers'
679 => 'apihelp-help-example-query',
680 ];
681 }
682
683 public function getHelpUrls() {
684 return [
685 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page',
686 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:FAQ',
687 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Quick_start_guide',
688 ];
689 }
690}
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:52
const PARAM_DEPRECATED
Definition ApiBase.php:98
getModuleFromPath( $path)
Get a module from its module path.
Definition ApiBase.php:582
static makeMessage( $msg, IContextSource $context, array $params=null)
Create a Message from a string or array.
Definition ApiBase.php:1223
getMain()
Get the main module.
Definition ApiBase.php:515
const PARAM_TYPE
Definition ApiBase.php:78
const PARAM_HELP_MSG_INFO
(array) Specify additional information tags for the parameter.
Definition ApiBase.php:179
const PARAM_DFLT
Definition ApiBase.php:70
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:620
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:772
getModulePath()
Get the path to this module.
Definition ApiBase.php:564
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:499
const PARAM_ISMULTI
Definition ApiBase.php:74
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:231
isReadMode()
Indicates whether this module requires read rights Stable to override.
Definition ApiHelp.php:640
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition ApiHelp.php:35
getExamplesMessages()
Returns usage examples for this module.
Definition ApiHelp.php:668
static fixHelpLinks( $html, $helptitle=null, $localModules=[])
Replace Special:ApiHelp links with links to api.php.
Definition ApiHelp.php:191
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition ApiHelp.php:655
getHelpUrls()
Return links to more detailed help pages about the module.
Definition ApiHelp.php:683
static getHelpInternal(IContextSource $context, array $modules, array $options, &$haveModules)
Recursively-called function to actually construct the help.
Definition ApiHelp.php:246
static getHelp(IContextSource $context, $modules, array $options)
Generate help for the specified modules.
Definition ApiHelp.php:114
shouldCheckMaxlag()
Indicates if this module needs maxlag to be checked Stable to override.
Definition ApiHelp.php:636
getCustomPrinter()
If the module may only be used with a certain format module, it should override this method to return...
Definition ApiHelp.php:644
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:47
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:1774
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:161
static listParam(array $list, $type='text')
Definition Message.php:1141
parse()
Fully parse the text from wikitext to HTML.
Definition Message.php:956
This is one of the Core classes and should be read at least once by any new developers.
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