3 * Created on Dec 01, 2007
5 * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
28 class ApiParse
extends ApiBase
{
30 /** @var string $section */
31 private $section = null;
33 /** @var Content $content */
34 private $content = null;
36 /** @var Content $pstContent */
37 private $pstContent = null;
39 public function execute() {
40 // The data is hot but user-dependent, like page views, so we set vary cookies
41 $this->getMain()->setCacheMode( 'anon-public-user-private' );
44 $params = $this->extractRequestParams();
46 // No easy way to say that text & title are allowed together while the
47 // rest aren't, so just do it in two calls.
48 $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'text' );
49 $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'title' );
51 $text = $params['text'];
52 $title = $params['title'];
53 if ( $title === null ) {
54 $titleProvided = false;
55 // A title is needed for parsing, so arbitrarily choose one
58 $titleProvided = true;
61 $page = $params['page'];
62 $pageid = $params['pageid'];
63 $oldid = $params['oldid'];
65 $model = $params['contentmodel'];
66 $format = $params['contentformat'];
68 $prop = array_flip( $params['prop'] );
70 if ( isset( $params['section'] ) ) {
71 $this->section
= $params['section'];
72 if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section
) ) {
73 $this->dieWithError( 'apierror-invalidsection' );
76 $this->section
= false;
79 // The parser needs $wgTitle to be set, apparently the
80 // $title parameter in Parser::parse isn't enough *sigh*
81 // TODO: Does this still need $wgTitle?
82 global $wgParser, $wgTitle;
87 $result = $this->getResult();
89 if ( !is_null( $oldid ) ||
!is_null( $pageid ) ||
!is_null( $page ) ) {
90 if ( $this->section
=== 'new' ) {
91 $this->dieWithError( 'apierror-invalidparammix-parse-new-section', 'invalidparammix' );
93 if ( !is_null( $oldid ) ) {
94 // Don't use the parser cache
95 $rev = Revision
::newFromId( $oldid );
97 $this->dieWithError( [ 'apierror-nosuchrevid', $oldid ] );
100 $this->checkTitleUserPermissions( $rev->getTitle(), 'read' );
101 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
103 [ 'apierror-permissiondenied', $this->msg( 'action-deletedtext' ) ]
107 $titleObj = $rev->getTitle();
108 $wgTitle = $titleObj;
109 $pageObj = WikiPage
::factory( $titleObj );
110 list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
112 // If for some reason the "oldid" is actually the current revision, it may be cached
113 // Deliberately comparing $pageObj->getLatest() with $rev->getId(), rather than
114 // checking $rev->isCurrent(), because $pageObj is what actually ends up being used,
115 // and if its ->getLatest() is outdated, $rev->isCurrent() won't tell us that.
116 if ( !$suppressCache && $rev->getId() == $pageObj->getLatest() ) {
117 // May get from/save to parser cache
118 $p_result = $this->getParsedContent( $pageObj, $popts,
119 $pageid, isset( $prop['wikitext'] ) );
120 } else { // This is an old revision, so get the text differently
121 $this->content
= $rev->getContent( Revision
::FOR_THIS_USER
, $this->getUser() );
123 if ( $this->section
!== false ) {
124 $this->content
= $this->getSectionContent(
125 $this->content
, $this->msg( 'revid', $rev->getId() )
129 // Should we save old revision parses to the parser cache?
130 $p_result = $this->content
->getParserOutput( $titleObj, $rev->getId(), $popts );
132 } else { // Not $oldid, but $pageid or $page
133 if ( $params['redirects'] ) {
137 if ( !is_null( $pageid ) ) {
138 $reqParams['pageids'] = $pageid;
140 $reqParams['titles'] = $page;
142 $req = new FauxRequest( $reqParams );
143 $main = new ApiMain( $req );
144 $pageSet = new ApiPageSet( $main );
146 $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
149 foreach ( $pageSet->getRedirectTitles() as $title ) {
150 $to = $title->getFullText();
152 $pageParams = [ 'title' => $to ];
153 } elseif ( !is_null( $pageid ) ) {
154 $pageParams = [ 'pageid' => $pageid ];
156 $pageParams = [ 'title' => $page ];
159 $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
160 $titleObj = $pageObj->getTitle();
161 if ( !$titleObj ||
!$titleObj->exists() ) {
162 $this->dieWithError( 'apierror-missingtitle' );
165 $this->checkTitleUserPermissions( $titleObj, 'read' );
166 $wgTitle = $titleObj;
168 if ( isset( $prop['revid'] ) ) {
169 $oldid = $pageObj->getLatest();
172 list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
174 // Don't pollute the parser cache when setting options that aren't
175 // in ParserOptions::optionsHash()
176 /// @todo: This should be handled closer to the actual cache instead of here, see T110269
177 $suppressCache = $suppressCache ||
178 $params['disablepp'] ||
179 $params['disablelimitreport'] ||
180 $params['preview'] ||
181 $params['sectionpreview'] ||
182 $params['disabletidy'];
184 if ( $suppressCache ) {
185 $this->content
= $this->getContent( $pageObj, $pageid );
186 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
188 // Potentially cached
189 $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
190 isset( $prop['wikitext'] ) );
193 } else { // Not $oldid, $pageid, $page. Hence based on $text
194 $titleObj = Title
::newFromText( $title );
195 if ( !$titleObj ||
$titleObj->isExternal() ) {
196 $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
198 $wgTitle = $titleObj;
199 if ( $titleObj->canExist() ) {
200 $pageObj = WikiPage
::factory( $titleObj );
202 // Do like MediaWiki::initializeArticle()
203 $article = Article
::newFromTitle( $titleObj, $this->getContext() );
204 $pageObj = $article->getPage();
207 list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
208 $textProvided = !is_null( $text );
210 if ( !$textProvided ) {
211 if ( $titleProvided && ( $prop ||
$params['generatexml'] ) ) {
212 $this->addWarning( 'apiwarn-parse-titlewithouttext' );
214 // Prevent warning from ContentHandler::makeContent()
218 // If we are parsing text, do not use the content model of the default
219 // API title, but default to wikitext to keep BC.
220 if ( $textProvided && !$titleProvided && is_null( $model ) ) {
221 $model = CONTENT_MODEL_WIKITEXT
;
222 $this->addWarning( [ 'apiwarn-parse-nocontentmodel', $model ] );
226 $this->content
= ContentHandler
::makeContent( $text, $titleObj, $model, $format );
227 } catch ( MWContentSerializationException
$ex ) {
228 $this->dieWithException( $ex, [
229 'wrap' => ApiMessage
::create( 'apierror-contentserializationexception', 'parseerror' )
233 if ( $this->section
!== false ) {
234 if ( $this->section
=== 'new' ) {
235 // Insert the section title above the content.
236 if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
237 $this->content
= $this->content
->addSectionHeader( $params['sectiontitle'] );
240 $this->content
= $this->getSectionContent( $this->content
, $titleObj->getPrefixedText() );
244 if ( $params['pst'] ||
$params['onlypst'] ) {
245 $this->pstContent
= $this->content
->preSaveTransform( $titleObj, $this->getUser(), $popts );
247 if ( $params['onlypst'] ) {
248 // Build a result and bail out
250 $result_array['text'] = $this->pstContent
->serialize( $format );
251 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'text';
252 if ( isset( $prop['wikitext'] ) ) {
253 $result_array['wikitext'] = $this->content
->serialize( $format );
254 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'wikitext';
256 if ( !is_null( $params['summary'] ) ||
257 ( !is_null( $params['sectiontitle'] ) && $this->section
=== 'new' )
259 $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
260 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsedsummary';
263 $result->addValue( null, $this->getModuleName(), $result_array );
268 // Not cached (save or load)
269 if ( $params['pst'] ) {
270 $p_result = $this->pstContent
->getParserOutput( $titleObj, null, $popts );
272 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
278 $result_array['title'] = $titleObj->getPrefixedText();
279 $result_array['pageid'] = $pageid ?
: $pageObj->getId();
281 if ( !is_null( $oldid ) ) {
282 $result_array['revid'] = intval( $oldid );
285 if ( $params['redirects'] && !is_null( $redirValues ) ) {
286 $result_array['redirects'] = $redirValues;
289 if ( $params['disabletoc'] ) {
290 $p_result->setTOCEnabled( false );
293 if ( isset( $prop['text'] ) ) {
294 $result_array['text'] = $p_result->getText();
295 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'text';
298 if ( !is_null( $params['summary'] ) ||
299 ( !is_null( $params['sectiontitle'] ) && $this->section
=== 'new' )
301 $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
302 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsedsummary';
305 if ( isset( $prop['langlinks'] ) ) {
306 $langlinks = $p_result->getLanguageLinks();
308 if ( $params['effectivelanglinks'] ) {
309 // Link flags are ignored for now, but may in the future be
310 // included in the result.
312 Hooks
::run( 'LanguageLinks', [ $titleObj, &$langlinks, &$linkFlags ] );
318 if ( isset( $prop['langlinks'] ) ) {
319 $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
321 if ( isset( $prop['categories'] ) ) {
322 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
324 if ( isset( $prop['categorieshtml'] ) ) {
325 $result_array['categorieshtml'] = $this->categoriesHtml( $p_result->getCategories() );
326 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'categorieshtml';
328 if ( isset( $prop['links'] ) ) {
329 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
331 if ( isset( $prop['templates'] ) ) {
332 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
334 if ( isset( $prop['images'] ) ) {
335 $result_array['images'] = array_keys( $p_result->getImages() );
337 if ( isset( $prop['externallinks'] ) ) {
338 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
340 if ( isset( $prop['sections'] ) ) {
341 $result_array['sections'] = $p_result->getSections();
343 if ( isset( $prop['parsewarnings'] ) ) {
344 $result_array['parsewarnings'] = $p_result->getWarnings();
347 if ( isset( $prop['displaytitle'] ) ) {
348 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
:
349 $titleObj->getPrefixedText();
352 if ( isset( $prop['headitems'] ) ) {
353 $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
354 $this->addDeprecation( 'apiwarn-deprecation-parse-headitems', 'action=parse&prop=headitems' );
357 if ( isset( $prop['headhtml'] ) ) {
358 $context = new DerivativeContext( $this->getContext() );
359 $context->setTitle( $titleObj );
360 $context->setWikiPage( $pageObj );
362 // We need an OutputPage tied to $context, not to the
363 // RequestContext at the root of the stack.
364 $output = new OutputPage( $context );
365 $output->addParserOutputMetadata( $p_result );
367 $result_array['headhtml'] = $output->headElement( $context->getSkin() );
368 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'headhtml';
371 if ( isset( $prop['modules'] ) ) {
372 $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
373 $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
374 $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
377 if ( isset( $prop['jsconfigvars'] ) ) {
378 $result_array['jsconfigvars'] =
379 ApiResult
::addMetadataToResultVars( $p_result->getJsConfigVars() );
382 if ( isset( $prop['encodedjsconfigvars'] ) ) {
383 $result_array['encodedjsconfigvars'] = FormatJson
::encode(
384 $p_result->getJsConfigVars(), false, FormatJson
::ALL_OK
386 $result_array[ApiResult
::META_SUBELEMENTS
][] = 'encodedjsconfigvars';
389 if ( isset( $prop['modules'] ) &&
390 !isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) {
391 $this->addWarning( 'apiwarn-moduleswithoutvars' );
394 if ( isset( $prop['indicators'] ) ) {
395 $result_array['indicators'] = (array)$p_result->getIndicators();
396 ApiResult
::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
399 if ( isset( $prop['iwlinks'] ) ) {
400 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
403 if ( isset( $prop['wikitext'] ) ) {
404 $result_array['wikitext'] = $this->content
->serialize( $format );
405 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'wikitext';
406 if ( !is_null( $this->pstContent
) ) {
407 $result_array['psttext'] = $this->pstContent
->serialize( $format );
408 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'psttext';
411 if ( isset( $prop['properties'] ) ) {
412 $result_array['properties'] = (array)$p_result->getProperties();
413 ApiResult
::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
416 if ( isset( $prop['limitreportdata'] ) ) {
417 $result_array['limitreportdata'] =
418 $this->formatLimitReportData( $p_result->getLimitReportData() );
420 if ( isset( $prop['limitreporthtml'] ) ) {
421 $result_array['limitreporthtml'] = EditPage
::getPreviewLimitReport( $p_result );
422 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'limitreporthtml';
425 if ( isset( $prop['parsetree'] ) ||
$params['generatexml'] ) {
426 if ( $this->content
->getModel() != CONTENT_MODEL_WIKITEXT
) {
427 $this->dieWithError( 'apierror-parsetree-notwikitext', 'notwikitext' );
430 $wgParser->startExternalParse( $titleObj, $popts, Parser
::OT_PREPROCESS
);
431 $dom = $wgParser->preprocessToDom( $this->content
->getNativeData() );
432 if ( is_callable( [ $dom, 'saveXML' ] ) ) {
433 $xml = $dom->saveXML();
435 $xml = $dom->__toString();
437 $result_array['parsetree'] = $xml;
438 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsetree';
444 'categories' => 'cl',
448 'externallinks' => 'el',
453 'indicators' => 'ind',
454 'modulescripts' => 'm',
455 'modulestyles' => 'm',
456 'properties' => 'pp',
457 'limitreportdata' => 'lr',
458 'parsewarnings' => 'pw'
460 $this->setIndexedTagNames( $result_array, $result_mapping );
461 $result->addValue( null, $this->getModuleName(), $result_array );
465 * Constructs a ParserOptions object
467 * @param WikiPage $pageObj
468 * @param array $params
470 * @return array [ ParserOptions, ScopedCallback, bool $suppressCache ]
472 protected function makeParserOptions( WikiPage
$pageObj, array $params ) {
473 $popts = $pageObj->makeParserOptions( $this->getContext() );
474 $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
475 $popts->setIsPreview( $params['preview'] ||
$params['sectionpreview'] );
476 $popts->setIsSectionPreview( $params['sectionpreview'] );
477 $popts->setEditSection( !$params['disableeditsection'] );
478 if ( $params['disabletidy'] ) {
479 $popts->setTidy( false );
483 $suppressCache = false;
484 Hooks
::run( 'ApiMakeParserOptions',
485 [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
487 return [ $popts, $reset, $suppressCache ];
491 * @param WikiPage $page
492 * @param ParserOptions $popts
494 * @param bool $getWikitext
495 * @return ParserOutput
497 private function getParsedContent( WikiPage
$page, $popts, $pageId = null, $getWikitext = false ) {
498 $this->content
= $this->getContent( $page, $pageId );
500 if ( $this->section
!== false && $this->content
!== null ) {
501 // Not cached (save or load)
502 return $this->content
->getParserOutput( $page->getTitle(), null, $popts );
505 // Try the parser cache first
506 // getParserOutput will save to Parser cache if able
507 $pout = $page->getParserOutput( $popts );
509 $this->dieWithError( [ 'apierror-nosuchrevid', $page->getLatest() ] );
511 if ( $getWikitext ) {
512 $this->content
= $page->getContent( Revision
::RAW
);
519 * Get the content for the given page and the requested section.
521 * @param WikiPage $page
525 private function getContent( WikiPage
$page, $pageId = null ) {
526 $content = $page->getContent( Revision
::RAW
); // XXX: really raw?
528 if ( $this->section
!== false && $content !== null ) {
529 $content = $this->getSectionContent(
532 ?
$this->msg( 'pageid', $pageId )
533 : $page->getTitle()->getPrefixedText()
540 * Extract the requested section from the given Content
542 * @param Content $content
543 * @param string|Message $what Identifies the content in error messages, e.g. page title.
544 * @return Content|bool
546 private function getSectionContent( Content
$content, $what ) {
547 // Not cached (save or load)
548 $section = $content->getSection( $this->section
);
549 if ( $section === false ) {
550 $this->dieWithError( [ 'apierror-nosuchsection-what', $this->section
, $what ], 'nosuchsection' );
552 if ( $section === null ) {
553 $this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
561 * This mimicks the behavior of EditPage in formatting a summary
563 * @param Title $title of the page being parsed
564 * @param Array $params the API parameters of the request
565 * @return Content|bool
567 private function formatSummary( $title, $params ) {
569 $summary = !is_null( $params['summary'] ) ?
$params['summary'] : '';
570 $sectionTitle = !is_null( $params['sectiontitle'] ) ?
$params['sectiontitle'] : '';
572 if ( $this->section
=== 'new' && ( $sectionTitle === '' ||
$summary === '' ) ) {
573 if ( $sectionTitle !== '' ) {
574 $summary = $params['sectiontitle'];
576 if ( $summary !== '' ) {
577 $summary = wfMessage( 'newsectionsummary' )
578 ->rawParams( $wgParser->stripSectionName( $summary ) )
579 ->inContentLanguage()->text();
582 return Linker
::formatComment( $summary, $title, $this->section
=== 'new' );
585 private function formatLangLinks( $links ) {
587 foreach ( $links as $link ) {
589 $bits = explode( ':', $link, 2 );
590 $title = Title
::newFromText( $link );
592 $entry['lang'] = $bits[0];
594 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
595 // localised language name in 'uselang' language
596 $entry['langname'] = Language
::fetchLanguageName(
597 $title->getInterwiki(),
598 $this->getLanguage()->getCode()
601 // native language name
602 $entry['autonym'] = Language
::fetchLanguageName( $title->getInterwiki() );
604 ApiResult
::setContentValue( $entry, 'title', $bits[1] );
611 private function formatCategoryLinks( $links ) {
618 // Fetch hiddencat property
620 $lb->setArray( [ NS_CATEGORY
=> $links ] );
621 $db = $this->getDB();
622 $res = $db->select( [ 'page', 'page_props' ],
623 [ 'page_title', 'pp_propname' ],
624 $lb->constructSet( 'page', $db ),
628 'LEFT JOIN', [ 'pp_propname' => 'hiddencat', 'pp_page = page_id' ]
632 foreach ( $res as $row ) {
633 $hiddencats[$row->page_title
] = isset( $row->pp_propname
);
636 $linkCache = LinkCache
::singleton();
638 foreach ( $links as $link => $sortkey ) {
640 $entry['sortkey'] = $sortkey;
641 // array keys will cast numeric category names to ints, so cast back to string
642 ApiResult
::setContentValue( $entry, 'category', (string)$link );
643 if ( !isset( $hiddencats[$link] ) ) {
644 $entry['missing'] = true;
646 // We already know the link doesn't exist in the database, so
647 // tell LinkCache that before calling $title->isKnown().
648 $title = Title
::makeTitle( NS_CATEGORY
, $link );
649 $linkCache->addBadLinkObj( $title );
650 if ( $title->isKnown() ) {
651 $entry['known'] = true;
653 } elseif ( $hiddencats[$link] ) {
654 $entry['hidden'] = true;
662 private function categoriesHtml( $categories ) {
663 $context = $this->getContext();
664 $context->getOutput()->addCategoryLinks( $categories );
666 return $context->getSkin()->getCategories();
669 private function formatLinks( $links ) {
671 foreach ( $links as $ns => $nslinks ) {
672 foreach ( $nslinks as $title => $id ) {
675 ApiResult
::setContentValue( $entry, 'title', Title
::makeTitle( $ns, $title )->getFullText() );
676 $entry['exists'] = $id != 0;
684 private function formatIWLinks( $iw ) {
686 foreach ( $iw as $prefix => $titles ) {
687 foreach ( array_keys( $titles ) as $title ) {
689 $entry['prefix'] = $prefix;
691 $title = Title
::newFromText( "{$prefix}:{$title}" );
693 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
696 ApiResult
::setContentValue( $entry, 'title', $title->getFullText() );
704 private function formatHeadItems( $headItems ) {
706 foreach ( $headItems as $tag => $content ) {
708 $entry['tag'] = $tag;
709 ApiResult
::setContentValue( $entry, 'content', $content );
716 private function formatLimitReportData( $limitReportData ) {
719 foreach ( $limitReportData as $name => $value ) {
721 $entry['name'] = $name;
722 if ( !is_array( $value ) ) {
725 ApiResult
::setIndexedTagNameRecursive( $value, 'param' );
726 $entry = array_merge( $entry, $value );
733 private function setIndexedTagNames( &$array, $mapping ) {
734 foreach ( $mapping as $key => $name ) {
735 if ( isset( $array[$key] ) ) {
736 ApiResult
::setIndexedTagName( $array[$key], $name );
741 public function getAllowedParams() {
745 ApiBase
::PARAM_TYPE
=> 'text',
750 ApiBase
::PARAM_TYPE
=> 'integer',
752 'redirects' => false,
754 ApiBase
::PARAM_TYPE
=> 'integer',
757 ApiBase
::PARAM_DFLT
=> 'text|langlinks|categories|links|templates|' .
758 'images|externallinks|sections|revid|displaytitle|iwlinks|' .
759 'properties|parsewarnings',
760 ApiBase
::PARAM_ISMULTI
=> true,
761 ApiBase
::PARAM_TYPE
=> [
777 'encodedjsconfigvars',
787 ApiBase
::PARAM_HELP_MSG_PER_VALUE
=> [
788 'parsetree' => [ 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT
],
793 'effectivelanglinks' => false,
796 ApiBase
::PARAM_TYPE
=> 'string',
799 ApiBase
::PARAM_DFLT
=> false,
800 ApiBase
::PARAM_DEPRECATED
=> true,
802 'disablelimitreport' => false,
803 'disableeditsection' => false,
804 'disabletidy' => false,
806 ApiBase
::PARAM_DFLT
=> false,
807 ApiBase
::PARAM_HELP_MSG
=> [
808 'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
810 ApiBase
::PARAM_DEPRECATED
=> true,
813 'sectionpreview' => false,
814 'disabletoc' => false,
816 ApiBase
::PARAM_TYPE
=> ContentHandler
::getAllContentFormats(),
819 ApiBase
::PARAM_TYPE
=> ContentHandler
::getContentModels(),
824 protected function getExamplesMessages() {
826 'action=parse&page=Project:Sandbox'
827 => 'apihelp-parse-example-page',
828 'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
829 => 'apihelp-parse-example-text',
830 'action=parse&text={{PAGENAME}}&title=Test'
831 => 'apihelp-parse-example-texttitle',
832 'action=parse&summary=Some+[[link]]&prop='
833 => 'apihelp-parse-example-summary',
837 public function getHelpUrls() {
838 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parsing_wikitext#parse';