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