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