43 private $section =
null;
49 private $pstContent =
null;
55 private $revisionLookup;
61 private $languageNameUtils;
64 private $linkBatchFactory;
70 private $contentHandlerFactory;
76 private $wikiPageFactory;
79 private $contentTransformer;
82 private $commentFormatter;
85 private $contentRenderer;
117 parent::__construct( $main, $action );
118 $this->revisionLookup = $revisionLookup;
119 $this->skinFactory = $skinFactory;
120 $this->languageNameUtils = $languageNameUtils;
121 $this->linkBatchFactory = $linkBatchFactory;
122 $this->linkCache = $linkCache;
123 $this->contentHandlerFactory = $contentHandlerFactory;
124 $this->parser = $parser;
125 $this->wikiPageFactory = $wikiPageFactory;
126 $this->contentRenderer = $contentRenderer;
127 $this->contentTransformer = $contentTransformer;
128 $this->commentFormatter = $commentFormatter;
131 private function getPoolKey(): string {
132 $poolKey =
WikiMap::getCurrentWikiDbDomain() .
':ApiParse:';
133 if ( !$this->
getUser()->isRegistered() ) {
134 $poolKey .=
'a:' . $this->
getUser()->getName();
136 $poolKey .=
'u:' . $this->
getUser()->getId();
141 private function getContentParserOutput(
149 'doWork' =>
function () use (
$content, $page, $revId, $popts ) {
150 return $this->contentRenderer->getParserOutput(
$content, $page, $revId, $popts );
152 'error' =>
function () {
153 $this->dieWithError(
'apierror-concurrency-limit' );
160 private function getPageParserOutput(
168 'doWork' =>
static function () use ( $page, $revId, $popts, $suppressCache ) {
171 'error' =>
function () {
172 $this->dieWithError(
'apierror-concurrency-limit' );
181 $this->getMain()->setCacheMode(
'anon-public-user-private' );
184 $params = $this->extractRequestParams();
188 $this->requireMaxOneParameter( $params,
'page',
'pageid',
'oldid',
'text' );
189 $this->requireMaxOneParameter( $params,
'page',
'pageid',
'oldid',
'title' );
190 $this->requireMaxOneParameter( $params,
'page',
'pageid',
'oldid',
'revid' );
192 $text = $params[
'text'];
193 $title = $params[
'title'];
195 $titleProvided =
false;
199 $titleProvided =
true;
202 $page = $params[
'page'];
203 $pageid = $params[
'pageid'];
204 $oldid = $params[
'oldid'];
206 $prop = array_fill_keys( $params[
'prop'],
true );
208 if ( isset( $params[
'section'] ) ) {
209 $this->section = $params[
'section'];
210 if ( !preg_match(
'/^((T-)?\d+|new)$/', $this->section ) ) {
211 $this->dieWithError(
'apierror-invalidsection' );
214 $this->section =
false;
225 $needContent = isset( $prop[
'wikitext'] ) ||
226 isset( $prop[
'parsetree'] ) || $params[
'generatexml'];
229 $result = $this->getResult();
231 if ( $oldid !==
null || $pageid !==
null || $page !==
null ) {
232 if ( $this->section ===
'new' ) {
233 $this->dieWithError(
'apierror-invalidparammix-parse-new-section',
'invalidparammix' );
235 if ( $oldid !==
null ) {
237 $rev = $this->revisionLookup->getRevisionById( $oldid );
239 $this->dieWithError( [
'apierror-nosuchrevid', $oldid ] );
242 $this->checkTitleUserPermissions( $rev->getPage(),
'read' );
244 if ( !$rev->userCan( RevisionRecord::DELETED_TEXT, $this->getAuthority() ) ) {
246 [
'apierror-permissiondenied', $this->msg(
'action-deletedtext' ) ]
250 $revLinkTarget = $rev->getPageAsLinkTarget();
253 $pageObj = $this->wikiPageFactory->newFromTitle( $titleObj );
254 list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
255 $p_result = $this->getParsedContent(
256 $pageObj, $popts, $suppressCache, $pageid, $rev, $needContent
259 if ( $params[
'redirects'] ) {
264 if ( $pageid !==
null ) {
265 $reqParams[
'pageids'] = $pageid;
266 $pageParams[
'pageid'] = $pageid;
268 $reqParams[
'titles'] = $page;
269 $pageParams[
'title'] = $page;
275 $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
277 foreach ( $pageSet->getRedirectTitles() as
$title ) {
278 $pageParams = [
'title' =>
$title->getFullText() ];
280 } elseif ( $pageid !==
null ) {
281 $pageParams = [
'pageid' => $pageid ];
283 $pageParams = [
'title' => $page ];
286 $pageObj = $this->getTitleOrPageId( $pageParams,
'fromdb' );
288 if ( !$titleObj->exists() ) {
289 $this->dieWithError(
'apierror-missingtitle' );
292 $this->checkTitleUserPermissions( $titleObj,
'read' );
295 if ( isset( $prop[
'revid'] ) ) {
299 list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
300 $p_result = $this->getParsedContent(
301 $pageObj, $popts, $suppressCache, $pageid,
null, $needContent
305 $model = $params[
'contentmodel'];
306 $format = $params[
'contentformat'];
309 if ( !$titleObj || $titleObj->isExternal() ) {
312 $revid = $params[
'revid'];
313 if ( $revid !==
null ) {
314 $rev = $this->revisionLookup->getRevisionById( $revid );
316 $this->dieWithError( [
'apierror-nosuchrevid', $revid ] );
318 $pTitleObj = $titleObj;
320 if ( $titleProvided ) {
321 if ( !$titleObj->equals( $pTitleObj ) ) {
322 $this->addWarning( [
'apierror-revwrongpage', $rev->getId(),
328 $titleProvided =
true;
332 if ( $titleObj->canExist() ) {
333 $pageObj = $this->wikiPageFactory->newFromTitle( $titleObj );
334 list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
339 list( $popts, $reset ) = $this->tweakParserOptions( $popts, $titleObj, $params );
342 $textProvided = $text !==
null;
344 if ( !$textProvided ) {
345 if ( $titleProvided && ( $prop || $params[
'generatexml'] ) ) {
346 if ( $revid !==
null ) {
347 $this->addWarning(
'apiwarn-parse-revidwithouttext' );
349 $this->addWarning(
'apiwarn-parse-titlewithouttext' );
358 if ( $textProvided && !$titleProvided && $model ===
null ) {
360 $this->addWarning( [
'apiwarn-parse-nocontentmodel', $model ] );
361 } elseif ( $model ===
null ) {
362 $model = $titleObj->getContentModel();
365 $contentHandler = $this->contentHandlerFactory->getContentHandler( $model );
367 if ( $format && !$contentHandler->isSupportedFormat( $format ) ) {
368 $this->dieWithError( [
'apierror-badformat-generic', $format, $model ] );
372 $this->content = $contentHandler->unserializeContent( $text, $format );
374 $this->dieWithException( $ex, [
375 'wrap' =>
ApiMessage::create(
'apierror-contentserializationexception',
'parseerror' )
379 if ( $this->section !==
false ) {
380 if ( $this->section ===
'new' ) {
382 if ( $params[
'sectiontitle'] !==
null ) {
383 $this->content = $this->content->addSectionHeader( $params[
'sectiontitle'] );
386 $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
390 if ( $params[
'pst'] || $params[
'onlypst'] ) {
391 $this->pstContent = $this->contentTransformer->preSaveTransform(
398 if ( $params[
'onlypst'] ) {
401 $result_array[
'text'] = $this->pstContent->serialize( $format );
403 if ( isset( $prop[
'wikitext'] ) ) {
404 $result_array[
'wikitext'] = $this->content->serialize( $format );
407 if ( $params[
'summary'] !==
null ||
408 ( $params[
'sectiontitle'] !==
null && $this->section ===
'new' )
410 $result_array[
'parsedsummary'] = $this->formatSummary( $titleObj, $params );
414 $result->addValue(
null, $this->getModuleName(), $result_array );
420 if ( $params[
'pst'] ) {
421 $p_result = $this->getContentParserOutput( $this->pstContent, $titleObj, $revid, $popts );
423 $p_result = $this->getContentParserOutput( $this->content, $titleObj, $revid, $popts );
429 $result_array[
'title'] = $titleObj->getPrefixedText();
430 $result_array[
'pageid'] = $pageid ?: $titleObj->getArticleID();
431 if ( $this->contentIsDeleted ) {
432 $result_array[
'textdeleted'] =
true;
434 if ( $this->contentIsSuppressed ) {
435 $result_array[
'textsuppressed'] =
true;
438 if ( isset( $params[
'useskin'] ) ) {
447 $skin || isset( $prop[
'subtitle'] ) || isset( $prop[
'headhtml'] ) || isset( $prop[
'categorieshtml'] ) ||
448 isset( $params[
'mobileformat'] )
465 $context->setTitle( $titleObj );
468 $context->setWikiPage( $pageObj );
472 $context->setRequest(
new FauxRequest( [
'action' =>
'view' ] ) );
476 $context->setSkin( $skin );
478 $skin = $context->getSkin();
483 $context->setSkin( $context->getSkin() );
488 $outputPage->setArticleFlag(
true );
490 $outputPage->addParserOutputMetadata( $p_result );
491 if ( $this->content ) {
492 $outputPage->addContentOverride( $titleObj, $this->content );
494 $context->setOutput( $outputPage );
498 $outputPage->loadSkinModules( $skin );
501 $this->getHookRunner()->onApiParseMakeOutputPage( $this, $outputPage );
504 if ( $oldid !==
null ) {
505 $result_array[
'revid'] = (int)$oldid;
508 if ( $params[
'redirects'] && $redirValues !==
null ) {
509 $result_array[
'redirects'] = $redirValues;
512 if ( isset( $prop[
'text'] ) ) {
513 $skin = $context ? $context->getSkin() :
null;
514 $skinOptions = $skin ? $skin->getOptions() : [
517 $result_array[
'text'] = $p_result->getText( [
518 'allowTOC' => !$params[
'disabletoc'],
519 'injectTOC' => $skinOptions[
'toc'],
520 'enableSectionEditLinks' => !$params[
'disableeditsection'],
521 'wrapperDivClass' => $params[
'wrapoutputclass'],
522 'deduplicateStyles' => !$params[
'disablestylededuplication'],
524 'includeDebugInfo' => !$params[
'disablepp'] && !$params[
'disablelimitreport']
528 $this->getHookRunner()->onOutputPageBeforeHTML( $context->getOutput(), $result_array[
'text'] );
532 if ( $params[
'summary'] !==
null ||
533 ( $params[
'sectiontitle'] !==
null && $this->section ===
'new' )
535 $result_array[
'parsedsummary'] = $this->formatSummary( $titleObj, $params );
539 if ( isset( $prop[
'langlinks'] ) ) {
541 $langlinks = $outputPage->getLanguageLinks();
543 $langlinks = $p_result->getLanguageLinks();
547 if ( $params[
'effectivelanglinks'] ) {
549 $this->getHookRunner()->onLanguageLinks( $titleObj, $langlinks, $linkFlags );
553 $result_array[
'langlinks'] = $this->formatLangLinks( $langlinks );
555 if ( isset( $prop[
'categories'] ) ) {
556 $result_array[
'categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
558 if ( isset( $prop[
'categorieshtml'] ) ) {
559 $result_array[
'categorieshtml'] = $outputPage->getSkin()->getCategories();
562 if ( isset( $prop[
'links'] ) ) {
563 $result_array[
'links'] = $this->formatLinks( $p_result->getLinks() );
565 if ( isset( $prop[
'templates'] ) ) {
566 $result_array[
'templates'] = $this->formatLinks( $p_result->getTemplates() );
568 if ( isset( $prop[
'images'] ) ) {
569 $result_array[
'images'] = array_keys( $p_result->getImages() );
571 if ( isset( $prop[
'externallinks'] ) ) {
572 $result_array[
'externallinks'] = array_keys( $p_result->getExternalLinks() );
574 if ( isset( $prop[
'sections'] ) ) {
575 $result_array[
'sections'] = $p_result->getSections();
576 $result_array[
'showtoc'] = (bool)$p_result->getTOCHTML();
578 if ( isset( $prop[
'parsewarnings'] ) ) {
579 $result_array[
'parsewarnings'] = $p_result->getWarnings();
581 if ( isset( $prop[
'parsewarningshtml'] ) ) {
582 $warnings = $p_result->getWarnings();
583 $warningsHtml = array_map(
static function ( $warning ) {
584 return (
new RawMessage(
'$1', [ $warning ] ) )->parse();
586 $result_array[
'parsewarningshtml'] = $warningsHtml;
589 if ( isset( $prop[
'displaytitle'] ) ) {
590 $result_array[
'displaytitle'] = $p_result->getDisplayTitle() !==
false
591 ? $p_result->getDisplayTitle()
592 : htmlspecialchars( $titleObj->getPrefixedText(), ENT_NOQUOTES );
595 if ( isset( $prop[
'subtitle'] ) ) {
596 $result_array[
'subtitle'] = $context->getSkin()->prepareSubtitle();
599 if ( isset( $prop[
'headitems'] ) ) {
601 $result_array[
'headitems'] = $this->formatHeadItems( $outputPage->getHeadItemsArray() );
603 $result_array[
'headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
607 if ( isset( $prop[
'headhtml'] ) ) {
608 $result_array[
'headhtml'] = $outputPage->headElement( $context->getSkin() );
612 if ( isset( $prop[
'modules'] ) ) {
614 $result_array[
'modules'] = $outputPage->getModules();
616 $result_array[
'modulescripts'] = [];
617 $result_array[
'modulestyles'] = $outputPage->getModuleStyles();
619 $result_array[
'modules'] = array_values( array_unique( $p_result->getModules() ) );
621 $result_array[
'modulescripts'] = [];
622 $result_array[
'modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
626 if ( isset( $prop[
'jsconfigvars'] ) ) {
627 $showStrategyKeys = (bool)( $params[
'showstrategykeys'] );
628 $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars( $showStrategyKeys );
632 if ( isset( $prop[
'encodedjsconfigvars'] ) ) {
633 $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars();
642 if ( isset( $prop[
'modules'] ) &&
643 !isset( $prop[
'jsconfigvars'] ) && !isset( $prop[
'encodedjsconfigvars'] ) ) {
644 $this->addWarning(
'apiwarn-moduleswithoutvars' );
647 if ( isset( $prop[
'indicators'] ) ) {
649 $result_array[
'indicators'] = (array)$outputPage->getIndicators();
651 $result_array[
'indicators'] = (array)$p_result->getIndicators();
656 if ( isset( $prop[
'iwlinks'] ) ) {
657 $result_array[
'iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
660 if ( isset( $prop[
'wikitext'] ) ) {
661 $result_array[
'wikitext'] = $this->content->serialize( $format );
664 if ( $this->pstContent !==
null ) {
665 $result_array[
'psttext'] = $this->pstContent->serialize( $format );
669 if ( isset( $prop[
'properties'] ) ) {
670 $result_array[
'properties'] = $p_result->getPageProperties();
674 if ( isset( $prop[
'limitreportdata'] ) ) {
675 $result_array[
'limitreportdata'] =
676 $this->formatLimitReportData( $p_result->getLimitReportData() );
678 if ( isset( $prop[
'limitreporthtml'] ) ) {
683 if ( isset( $prop[
'parsetree'] ) || $params[
'generatexml'] ) {
685 $this->dieWithError(
'apierror-parsetree-notwikitext',
'notwikitext' );
690 $xml = $this->parser->preprocessToDom( $this->content->getText() )->__toString();
691 $result_array[
'parsetree'] = $xml;
698 'categories' =>
'cl',
702 'externallinks' =>
'el',
707 'indicators' =>
'ind',
708 'modulescripts' =>
'm',
709 'modulestyles' =>
'm',
710 'properties' =>
'pp',
711 'limitreportdata' =>
'lr',
712 'parsewarnings' =>
'pw',
713 'parsewarningshtml' =>
'pw',
715 $this->setIndexedTagNames( $result_array, $result_mapping );
716 $result->addValue(
null, $this->getModuleName(), $result_array );
727 private function makeParserOptions(
WikiPage $pageObj, array $params ) {
729 return $this->tweakParserOptions( $popts, $pageObj->
getTitle(), $params );
742 $popts->
setIsPreview( $params[
'preview'] || $params[
'sectionpreview'] );
745 if ( $params[
'wrapoutputclass'] !==
'' ) {
750 $suppressCache =
false;
751 $this->getHookRunner()->onApiMakeParserOptions( $popts,
$title,
752 $params, $this, $reset, $suppressCache );
754 return [ $popts, $reset, $suppressCache ];
766 private function getParsedContent(
767 WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent
769 $revId = $rev ? $rev->getId() :
null;
770 $isDeleted = $rev && $rev->isDeleted( RevisionRecord::DELETED_TEXT );
772 if ( $getContent || $this->section !==
false || $isDeleted ) {
774 $this->content = $rev->getContent(
775 SlotRecord::MAIN, RevisionRecord::FOR_THIS_USER, $this->
getAuthority()
777 if ( !$this->content ) {
778 $this->dieWithError( [
'apierror-missingcontent-revid', $revId ] );
782 if ( !$this->content ) {
783 $this->dieWithError( [
'apierror-missingcontent-pageid', $page->
getId() ] );
786 $this->contentIsDeleted = $isDeleted;
787 $this->contentIsSuppressed = $rev &&
788 $rev->isDeleted( RevisionRecord::DELETED_TEXT | RevisionRecord::DELETED_RESTRICTED );
791 if ( $this->section !==
false ) {
792 $this->content = $this->getSectionContent(
794 $pageId ===
null ? $page->
getTitle()->getPrefixedText() : $this->msg(
'pageid', $pageId )
796 return $this->getContentParserOutput( $this->content, $page->
getTitle(), $revId, $popts );
802 $pout = $this->getContentParserOutput( $this->content, $page->
getTitle(), $revId, $popts );
805 $pout = $this->getPageParserOutput( $page, $revId, $popts, $suppressCache );
809 $this->dieWithError( [
'apierror-nosuchrevid', $revId ?: $page->
getLatest() ] );
825 $section =
$content->getSection( $this->section );
826 if ( $section ===
false ) {
827 $this->dieWithError( [
'apierror-nosuchsection-what', $this->section, $what ],
'nosuchsection' );
829 if ( $section ===
null ) {
830 $this->dieWithError( [
'apierror-sectionsnotsupported-what', $what ],
'nosuchsection' );
844 private function formatSummary(
$title, $params ) {
845 $summary = $params[
'summary'] ??
'';
846 $sectionTitle = $params[
'sectiontitle'] ??
'';
848 if ( $this->section ===
'new' && ( $sectionTitle ===
'' || $summary ===
'' ) ) {
849 if ( $sectionTitle !==
'' ) {
850 $summary = $params[
'sectiontitle'];
852 if ( $summary !==
'' ) {
853 $summary =
wfMessage(
'newsectionsummary' )
854 ->rawParams( $this->parser->stripSectionName( $summary ) )
855 ->inContentLanguage()->text();
858 return $this->commentFormatter->format( $summary,
$title, $this->section ===
'new' );
861 private function formatLangLinks( $links ) {
863 foreach ( $links as $link ) {
865 $bits = explode(
':', $link, 2 );
868 $entry[
'lang'] = $bits[0];
872 $entry[
'langname'] = $this->languageNameUtils->getLanguageName(
874 $this->getLanguage()->getCode()
878 $entry[
'autonym'] = $this->languageNameUtils->getLanguageName(
$title->getInterwiki() );
887 private function formatCategoryLinks( $links ) {
895 $lb = $this->linkBatchFactory->newLinkBatch();
897 $db = $this->
getDB();
898 $res = $db->select( [
'page',
'page_props' ],
899 [
'page_title',
'pp_propname' ],
900 $lb->constructSet(
'page', $db ),
904 'LEFT JOIN', [
'pp_propname' =>
'hiddencat',
'pp_page = page_id' ]
908 foreach (
$res as $row ) {
909 $hiddencats[$row->page_title] = isset( $row->pp_propname );
912 foreach ( $links as $link => $sortkey ) {
914 $entry[
'sortkey'] = $sortkey;
917 if ( !isset( $hiddencats[$link] ) ) {
918 $entry[
'missing'] =
true;
923 $this->linkCache->addBadLinkObj(
$title );
924 if (
$title->isKnown() ) {
925 $entry[
'known'] =
true;
927 } elseif ( $hiddencats[$link] ) {
928 $entry[
'hidden'] =
true;
936 private function formatLinks( $links ) {
938 foreach ( $links as $ns => $nslinks ) {
939 foreach ( $nslinks as
$title => $id ) {
943 $entry[
'exists'] = $id != 0;
951 private function formatIWLinks( $iw ) {
953 foreach ( $iw as $prefix => $titles ) {
954 foreach ( array_keys( $titles ) as
$title ) {
956 $entry[
'prefix'] = $prefix;
971 private function formatHeadItems( $headItems ) {
973 foreach ( $headItems as $tag =>
$content ) {
975 $entry[
'tag'] = $tag;
983 private function formatLimitReportData( $limitReportData ) {
986 foreach ( $limitReportData as $name => $value ) {
988 $entry[
'name'] = $name;
989 if ( !is_array( $value ) ) {
993 $entry = array_merge( $entry, $value );
1000 private function setIndexedTagNames( &$array, $mapping ) {
1001 foreach ( $mapping as $key => $name ) {
1002 if ( isset( $array[$key] ) ) {
1012 ParamValidator::PARAM_TYPE =>
'text',
1015 ParamValidator::PARAM_TYPE =>
'integer',
1020 ParamValidator::PARAM_TYPE =>
'integer',
1022 'redirects' =>
false,
1024 ParamValidator::PARAM_TYPE =>
'integer',
1027 ParamValidator::PARAM_DEFAULT =>
'text|langlinks|categories|links|templates|' .
1028 'images|externallinks|sections|revid|displaytitle|iwlinks|' .
1029 'properties|parsewarnings',
1030 ParamValidator::PARAM_ISMULTI =>
true,
1031 ParamValidator::PARAM_TYPE => [
1047 'encodedjsconfigvars',
1056 'parsewarningshtml',
1062 EnumDef::PARAM_DEPRECATED_VALUES => [
1063 'headitems' =>
'apiwarn-deprecation-parse-headitems',
1066 'wrapoutputclass' =>
'mw-parser-output',
1069 'effectivelanglinks' => [
1070 ParamValidator::PARAM_DEFAULT =>
false,
1071 ParamValidator::PARAM_DEPRECATED =>
true,
1075 ParamValidator::PARAM_TYPE =>
'string',
1078 ParamValidator::PARAM_DEFAULT =>
false,
1079 ParamValidator::PARAM_DEPRECATED =>
true,
1081 'disablelimitreport' =>
false,
1082 'disableeditsection' =>
false,
1083 'disablestylededuplication' =>
false,
1084 'showstrategykeys' =>
false,
1086 ParamValidator::PARAM_DEFAULT =>
false,
1090 ParamValidator::PARAM_DEPRECATED =>
true,
1093 'sectionpreview' =>
false,
1094 'disabletoc' =>
false,
1098 ParamValidator::PARAM_TYPE => array_keys( $this->skinFactory->getInstalledSkins() ),
1100 'contentformat' => [
1101 ParamValidator::PARAM_TYPE => $this->contentHandlerFactory->getAllContentFormats(),
1104 ParamValidator::PARAM_TYPE => $this->contentHandlerFactory->getContentModels(),
1111 'action=parse&page=Project:Sandbox'
1112 =>
'apihelp-parse-example-page',
1113 'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
1114 =>
'apihelp-parse-example-text',
1115 'action=parse&text={{PAGENAME}}&title=Test'
1116 =>
'apihelp-parse-example-texttitle',
1117 'action=parse&summary=Some+[[link]]&prop='
1118 =>
'apihelp-parse-example-summary',
1123 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parsing_wikitext#parse';
const CONTENT_MODEL_WIKITEXT
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgTitle
This abstract class implements many basic API functions, and is the base of all API classes.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
This is the main API class, used for both external and internal processing.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
This class contains a list of pages that the client has requested.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
__construct(ApiMain $main, $action, RevisionLookup $revisionLookup, SkinFactory $skinFactory, LanguageNameUtils $languageNameUtils, LinkBatchFactory $linkBatchFactory, LinkCache $linkCache, IContentHandlerFactory $contentHandlerFactory, Parser $parser, WikiPageFactory $wikiPageFactory, ContentRenderer $contentRenderer, ContentTransformer $contentTransformer, CommentFormatter $commentFormatter)
getExamplesMessages()
Returns usage examples for this module.
bool $contentIsSuppressed
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
static addMetadataToResultVars( $vars, $forceHash=true)
Add the correct metadata to an array of vars we want to export through the API.
const META_SUBELEMENTS
Key for the 'subelements' metadata item.
const META_BC_SUBELEMENTS
Key for the 'BC subelements' metadata item.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
static setIndexedTagNameRecursive(array &$arr, $tag)
Set indexed tag name on $arr and all subarrays.
An IContextSource implementation which will inherit context from another source but allow individual ...
static getPreviewLimitReport(ParserOutput $output=null)
Get the Limit report for page previews.
WebRequest clone which takes values from a provided array.
Cache for article titles (prefixed DB keys) and ids linked from one source.
Exception representing a failure to serialize or unserialize a content object.
A service to render content.
A service to transform content.
Service for creating WikiPage objects.
This is one of the Core classes and should be read at least once by any new developers.
Set options of the Parser.
setIsSectionPreview( $x)
Parsing the page for a "preview" operation on a single section?
setIsPreview( $x)
Parsing the page for a "preview" operation?
static newCanonical( $context, $userLang=null)
Creates a "canonical" ParserOptions object.
setWrapOutputClass( $className)
CSS class to use to wrap output from Parser::parse()
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Convenience class for dealing with PoolCounters using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Variant of the Message class.
Factory class to create Skin objects.
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Represents a title within MediaWiki.
static newFromLinkTarget(LinkTarget $linkTarget, $forceClone='')
Returns a Title given a LinkTarget.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Helper tools for dealing with other locally-hosted wikis.
Base representation for an editable wiki page.
getContent( $audience=RevisionRecord::FOR_PUBLIC, Authority $performer=null)
Get the content of the current revision.
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
getParserOutput(?ParserOptions $parserOptions=null, $oldid=null, $noCache=false)
Get a ParserOutput for the given ParserOptions and revision ID.
getLatest( $wikiId=self::LOCAL)
Get the page_latest field.
getId( $wikiId=self::LOCAL)
getTitle()
Get the title object of the article.
Base interface for content objects.