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();
45 $text = $params['text'];
46 $title = $params['title'];
47 if ( $title === null ) {
48 $titleProvided = false;
49 // A title is needed for parsing, so arbitrarily choose one
52 $titleProvided = true;
55 $page = $params['page'];
56 $pageid = $params['pageid'];
57 $oldid = $params['oldid'];
59 $model = $params['contentmodel'];
60 $format = $params['contentformat'];
62 if ( !is_null( $page ) && ( !is_null( $text ) ||
$titleProvided ) ) {
64 'The page parameter cannot be used together with the text and title parameters',
69 $prop = array_flip( $params['prop'] );
71 if ( isset( $params['section'] ) ) {
72 $this->section
= $params['section'];
73 if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section
) ) {
74 $this->dieUsage( "The section parameter must be a valid section id or 'new'", "invalidsection" );
77 $this->section
= false;
80 // The parser needs $wgTitle to be set, apparently the
81 // $title parameter in Parser::parse isn't enough *sigh*
82 // TODO: Does this still need $wgTitle?
83 global $wgParser, $wgTitle;
88 $result = $this->getResult();
90 if ( !is_null( $oldid ) ||
!is_null( $pageid ) ||
!is_null( $page ) ) {
91 if ( $this->section
=== 'new' ) {
92 $this->dieUsage( 'section=new cannot be combined with oldid, pageid or page parameters. Please use text', 'params' );
94 if ( !is_null( $oldid ) ) {
95 // Don't use the parser cache
96 $rev = Revision
::newFromId( $oldid );
98 $this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
100 if ( !$rev->userCan( Revision
::DELETED_TEXT
, $this->getUser() ) ) {
101 $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
104 $titleObj = $rev->getTitle();
105 $wgTitle = $titleObj;
106 $pageObj = WikiPage
::factory( $titleObj );
107 $popts = $this->makeParserOptions( $pageObj, $params );
109 // If for some reason the "oldid" is actually the current revision, it may be cached
110 // Deliberately comparing $pageObj->getLatest() with $rev->getId(), rather than
111 // checking $rev->isCurrent(), because $pageObj is what actually ends up being used,
112 // and if its ->getLatest() is outdated, $rev->isCurrent() won't tell us that.
113 if ( $rev->getId() == $pageObj->getLatest() ) {
114 // May get from/save to parser cache
115 $p_result = $this->getParsedContent( $pageObj, $popts,
116 $pageid, isset( $prop['wikitext'] ) );
117 } else { // This is an old revision, so get the text differently
118 $this->content
= $rev->getContent( Revision
::FOR_THIS_USER
, $this->getUser() );
120 if ( $this->section
!== false ) {
121 $this->content
= $this->getSectionContent( $this->content
, 'r' . $rev->getId() );
124 // Should we save old revision parses to the parser cache?
125 $p_result = $this->content
->getParserOutput( $titleObj, $rev->getId(), $popts );
127 } else { // Not $oldid, but $pageid or $page
128 if ( $params['redirects'] ) {
132 if ( !is_null( $pageid ) ) {
133 $reqParams['pageids'] = $pageid;
135 $reqParams['titles'] = $page;
137 $req = new FauxRequest( $reqParams );
138 $main = new ApiMain( $req );
139 $pageSet = new ApiPageSet( $main );
141 $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
144 foreach ( $pageSet->getRedirectTitles() as $title ) {
145 $to = $title->getFullText();
147 $pageParams = array( 'title' => $to );
148 } elseif ( !is_null( $pageid ) ) {
149 $pageParams = array( 'pageid' => $pageid );
151 $pageParams = array( 'title' => $page );
154 $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
155 $titleObj = $pageObj->getTitle();
156 if ( !$titleObj ||
!$titleObj->exists() ) {
157 $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
159 $wgTitle = $titleObj;
161 if ( isset( $prop['revid'] ) ) {
162 $oldid = $pageObj->getLatest();
165 $popts = $this->makeParserOptions( $pageObj, $params );
167 // Potentially cached
168 $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
169 isset( $prop['wikitext'] ) );
171 } else { // Not $oldid, $pageid, $page. Hence based on $text
172 $titleObj = Title
::newFromText( $title );
173 if ( !$titleObj ||
$titleObj->isExternal() ) {
174 $this->dieUsageMsg( array( 'invalidtitle', $title ) );
176 $wgTitle = $titleObj;
177 if ( $titleObj->canExist() ) {
178 $pageObj = WikiPage
::factory( $titleObj );
180 // Do like MediaWiki::initializeArticle()
181 $article = Article
::newFromTitle( $titleObj, $this->getContext() );
182 $pageObj = $article->getPage();
185 $popts = $this->makeParserOptions( $pageObj, $params );
186 $textProvided = !is_null( $text );
188 if ( !$textProvided ) {
189 if ( $titleProvided && ( $prop ||
$params['generatexml'] ) ) {
191 "'title' used without 'text', and parsed page properties were requested " .
192 "(did you mean to use 'page' instead of 'title'?)"
195 // Prevent warning from ContentHandler::makeContent()
199 // If we are parsing text, do not use the content model of the default
200 // API title, but default to wikitext to keep BC.
201 if ( $textProvided && !$titleProvided && is_null( $model ) ) {
202 $model = CONTENT_MODEL_WIKITEXT
;
203 $this->setWarning( "No 'title' or 'contentmodel' was given, assuming $model." );
207 $this->content
= ContentHandler
::makeContent( $text, $titleObj, $model, $format );
208 } catch ( MWContentSerializationException
$ex ) {
209 $this->dieUsage( $ex->getMessage(), 'parseerror' );
212 if ( $this->section
!== false ) {
213 if ( $this->section
=== 'new' ) {
214 // Insert the section title above the content.
215 if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
216 $this->content
= $this->content
->addSectionHeader( $params['sectiontitle'] );
219 $this->content
= $this->getSectionContent( $this->content
, $titleObj->getPrefixedText() );
223 if ( $params['pst'] ||
$params['onlypst'] ) {
224 $this->pstContent
= $this->content
->preSaveTransform( $titleObj, $this->getUser(), $popts );
226 if ( $params['onlypst'] ) {
227 // Build a result and bail out
228 $result_array = array();
229 $result_array['text'] = $this->pstContent
->serialize( $format );
230 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'text';
231 if ( isset( $prop['wikitext'] ) ) {
232 $result_array['wikitext'] = $this->content
->serialize( $format );
233 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'wikitext';
235 if ( !is_null( $params['summary'] ) ||
236 ( !is_null( $params['sectiontitle'] ) && $this->section
=== 'new' )
238 $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
239 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsedsummary';
242 $result->addValue( null, $this->getModuleName(), $result_array );
247 // Not cached (save or load)
248 if ( $params['pst'] ) {
249 $p_result = $this->pstContent
->getParserOutput( $titleObj, null, $popts );
251 $p_result = $this->content
->getParserOutput( $titleObj, null, $popts );
255 $result_array = array();
257 $result_array['title'] = $titleObj->getPrefixedText();
259 if ( !is_null( $oldid ) ) {
260 $result_array['revid'] = intval( $oldid );
263 if ( $params['redirects'] && !is_null( $redirValues ) ) {
264 $result_array['redirects'] = $redirValues;
267 if ( $params['disabletoc'] ) {
268 $p_result->setTOCEnabled( false );
271 if ( isset( $prop['text'] ) ) {
272 $result_array['text'] = $p_result->getText();
273 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'text';
276 if ( !is_null( $params['summary'] ) ||
277 ( !is_null( $params['sectiontitle'] ) && $this->section
=== 'new' )
279 $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
280 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsedsummary';
283 if ( isset( $prop['langlinks'] ) ) {
284 $langlinks = $p_result->getLanguageLinks();
286 if ( $params['effectivelanglinks'] ) {
287 // Link flags are ignored for now, but may in the future be
288 // included in the result.
289 $linkFlags = array();
290 Hooks
::run( 'LanguageLinks', array( $titleObj, &$langlinks, &$linkFlags ) );
296 if ( isset( $prop['langlinks'] ) ) {
297 $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
299 if ( isset( $prop['categories'] ) ) {
300 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
302 if ( isset( $prop['categorieshtml'] ) ) {
303 $result_array['categorieshtml'] = $this->categoriesHtml( $p_result->getCategories() );
304 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'categorieshtml';
306 if ( isset( $prop['links'] ) ) {
307 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
309 if ( isset( $prop['templates'] ) ) {
310 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
312 if ( isset( $prop['images'] ) ) {
313 $result_array['images'] = array_keys( $p_result->getImages() );
315 if ( isset( $prop['externallinks'] ) ) {
316 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
318 if ( isset( $prop['sections'] ) ) {
319 $result_array['sections'] = $p_result->getSections();
322 if ( isset( $prop['displaytitle'] ) ) {
323 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
324 $p_result->getDisplayTitle() :
325 $titleObj->getPrefixedText();
328 if ( isset( $prop['headitems'] ) ||
isset( $prop['headhtml'] ) ) {
329 $context = $this->getContext();
330 $context->setTitle( $titleObj );
331 $context->getOutput()->addParserOutputMetadata( $p_result );
333 if ( isset( $prop['headitems'] ) ) {
334 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
336 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
338 $scripts = array( $context->getOutput()->getHeadScripts() );
340 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
343 if ( isset( $prop['headhtml'] ) ) {
344 $result_array['headhtml'] = $context->getOutput()->headElement( $context->getSkin() );
345 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'headhtml';
349 if ( isset( $prop['modules'] ) ) {
350 $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
351 $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
352 $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
353 // To be removed in 1.27
354 $result_array['modulemessages'] = array();
355 $this->setWarning( 'modulemessages is deprecated since MediaWiki 1.26' );
358 if ( isset( $prop['jsconfigvars'] ) ) {
359 $result_array['jsconfigvars'] = $this->formatJsConfigVars( $p_result->getJsConfigVars() );
362 if ( isset( $prop['encodedjsconfigvars'] ) ) {
363 $result_array['encodedjsconfigvars'] = FormatJson
::encode(
364 $p_result->getJsConfigVars(), false, FormatJson
::ALL_OK
366 $result_array[ApiResult
::META_SUBELEMENTS
][] = 'encodedjsconfigvars';
369 if ( isset( $prop['indicators'] ) ) {
370 $result_array['indicators'] = (array)$p_result->getIndicators();
371 ApiResult
::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
374 if ( isset( $prop['iwlinks'] ) ) {
375 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
378 if ( isset( $prop['wikitext'] ) ) {
379 $result_array['wikitext'] = $this->content
->serialize( $format );
380 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'wikitext';
381 if ( !is_null( $this->pstContent
) ) {
382 $result_array['psttext'] = $this->pstContent
->serialize( $format );
383 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'psttext';
386 if ( isset( $prop['properties'] ) ) {
387 $result_array['properties'] = (array)$p_result->getProperties();
388 ApiResult
::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
391 if ( isset( $prop['limitreportdata'] ) ) {
392 $result_array['limitreportdata'] =
393 $this->formatLimitReportData( $p_result->getLimitReportData() );
395 if ( isset( $prop['limitreporthtml'] ) ) {
396 $result_array['limitreporthtml'] = EditPage
::getPreviewLimitReport( $p_result );
397 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'limitreporthtml';
400 if ( $params['generatexml'] ) {
401 if ( $this->content
->getModel() != CONTENT_MODEL_WIKITEXT
) {
402 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
405 $wgParser->startExternalParse( $titleObj, $popts, Parser
::OT_PREPROCESS
);
406 $dom = $wgParser->preprocessToDom( $this->content
->getNativeData() );
407 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
408 $xml = $dom->saveXML();
410 $xml = $dom->__toString();
412 $result_array['parsetree'] = $xml;
413 $result_array[ApiResult
::META_BC_SUBELEMENTS
][] = 'parsetree';
416 $result_mapping = array(
419 'categories' => 'cl',
423 'externallinks' => 'el',
428 'indicators' => 'ind',
429 'modulescripts' => 'm',
430 'modulestyles' => 'm',
431 'modulemessages' => 'm',
432 'properties' => 'pp',
433 'limitreportdata' => 'lr',
435 $this->setIndexedTagNames( $result_array, $result_mapping );
436 $result->addValue( null, $this->getModuleName(), $result_array );
440 * Constructs a ParserOptions object
442 * @param WikiPage $pageObj
443 * @param array $params
445 * @return ParserOptions
447 protected function makeParserOptions( WikiPage
$pageObj, array $params ) {
449 $popts = $pageObj->makeParserOptions( $this->getContext() );
450 $popts->enableLimitReport( !$params['disablepp'] );
451 $popts->setIsPreview( $params['preview'] ||
$params['sectionpreview'] );
452 $popts->setIsSectionPreview( $params['sectionpreview'] );
453 $popts->setEditSection( !$params['disableeditsection'] );
459 * @param WikiPage $page
460 * @param ParserOptions $popts
462 * @param bool $getWikitext
463 * @return ParserOutput
465 private function getParsedContent( WikiPage
$page, $popts, $pageId = null, $getWikitext = false ) {
466 $this->content
= $page->getContent( Revision
::RAW
); //XXX: really raw?
468 if ( $this->section
!== false && $this->content
!== null ) {
469 $this->content
= $this->getSectionContent(
471 !is_null( $pageId ) ?
'page id ' . $pageId : $page->getTitle()->getPrefixedText()
474 // Not cached (save or load)
475 return $this->content
->getParserOutput( $page->getTitle(), null, $popts );
478 // Try the parser cache first
479 // getParserOutput will save to Parser cache if able
480 $pout = $page->getParserOutput( $popts );
482 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
484 if ( $getWikitext ) {
485 $this->content
= $page->getContent( Revision
::RAW
);
492 * @param Content $content
493 * @param string $what Identifies the content in error messages, e.g. page title.
494 * @return Content|bool
496 private function getSectionContent( Content
$content, $what ) {
497 // Not cached (save or load)
498 $section = $content->getSection( $this->section
);
499 if ( $section === false ) {
500 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
502 if ( $section === null ) {
503 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
511 * This mimicks the behavior of EditPage in formatting a summary
513 * @param Title $title of the page being parsed
514 * @param Array $params the API parameters of the request
515 * @return Content|bool
517 private function formatSummary( $title, $params ) {
519 $summary = !is_null( $params['summary'] ) ?
$params['summary'] : '';
520 $sectionTitle = !is_null( $params['sectiontitle'] ) ?
$params['sectiontitle'] : '';
522 if ( $this->section
=== 'new' && ( $sectionTitle === '' ||
$summary === '' ) ) {
523 if( $sectionTitle !== '' ) {
524 $summary = $params['sectiontitle'];
526 if ( $summary !== '' ) {
527 $summary = wfMessage( 'newsectionsummary' )->rawParams( $wgParser->stripSectionName( $summary ) )
528 ->inContentLanguage()->text();
531 return Linker
::formatComment( $summary, $title, $this->section
=== 'new' );
534 private function formatLangLinks( $links ) {
536 foreach ( $links as $link ) {
538 $bits = explode( ':', $link, 2 );
539 $title = Title
::newFromText( $link );
541 $entry['lang'] = $bits[0];
543 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
544 // localised language name in 'uselang' language
545 $entry['langname'] = Language
::fetchLanguageName(
546 $title->getInterwiki(),
547 $this->getLanguage()->getCode()
550 // native language name
551 $entry['autonym'] = Language
::fetchLanguageName( $title->getInterwiki() );
553 ApiResult
::setContentValue( $entry, 'title', $bits[1] );
560 private function formatCategoryLinks( $links ) {
567 // Fetch hiddencat property
569 $lb->setArray( array( NS_CATEGORY
=> $links ) );
570 $db = $this->getDB();
571 $res = $db->select( array( 'page', 'page_props' ),
572 array( 'page_title', 'pp_propname' ),
573 $lb->constructSet( 'page', $db ),
576 array( 'page_props' => array(
577 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' )
580 $hiddencats = array();
581 foreach ( $res as $row ) {
582 $hiddencats[$row->page_title
] = isset( $row->pp_propname
);
585 foreach ( $links as $link => $sortkey ) {
587 $entry['sortkey'] = $sortkey;
588 ApiResult
::setContentValue( $entry, 'category', $link );
589 if ( !isset( $hiddencats[$link] ) ) {
590 $entry['missing'] = true;
591 } elseif ( $hiddencats[$link] ) {
592 $entry['hidden'] = true;
600 private function categoriesHtml( $categories ) {
601 $context = $this->getContext();
602 $context->getOutput()->addCategoryLinks( $categories );
604 return $context->getSkin()->getCategories();
607 private function formatLinks( $links ) {
609 foreach ( $links as $ns => $nslinks ) {
610 foreach ( $nslinks as $title => $id ) {
613 ApiResult
::setContentValue( $entry, 'title', Title
::makeTitle( $ns, $title )->getFullText() );
614 $entry['exists'] = $id != 0;
622 private function formatIWLinks( $iw ) {
624 foreach ( $iw as $prefix => $titles ) {
625 foreach ( array_keys( $titles ) as $title ) {
627 $entry['prefix'] = $prefix;
629 $title = Title
::newFromText( "{$prefix}:{$title}" );
631 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT
);
634 ApiResult
::setContentValue( $entry, 'title', $title->getFullText() );
642 private function formatHeadItems( $headItems ) {
644 foreach ( $headItems as $tag => $content ) {
646 $entry['tag'] = $tag;
647 ApiResult
::setContentValue( $entry, 'content', $content );
654 private function formatCss( $css ) {
656 foreach ( $css as $file => $link ) {
658 $entry['file'] = $file;
659 ApiResult
::setContentValue( $entry, 'link', $link );
666 private function formatLimitReportData( $limitReportData ) {
668 $apiResult = $this->getResult();
670 foreach ( $limitReportData as $name => $value ) {
672 $entry['name'] = $name;
673 if ( !is_array( $value ) ) {
674 $value = array( $value );
676 ApiResult
::setIndexedTagNameRecursive( $value, 'param' );
677 $entry = array_merge( $entry, $value );
684 private function formatJsConfigVars( $vars, $forceHash = true ) {
685 // Process subarrays and determine if this is a JS [] or {}
689 foreach ( $vars as $k => $v ) {
690 if ( is_array( $v ) ||
is_object( $v ) ) {
691 $vars[$k] = $this->formatJsConfigVars( (array)$v, false );
692 } elseif ( is_bool( $v ) ) {
693 // Better here to use real bools even in BC formats
696 if ( is_string( $k ) ) {
698 } elseif ( $k > $maxKey ) {
702 if ( !$hash && $maxKey !== count( $vars ) - 1 ) {
706 // Get the list of keys we actually care about. Unfortunately, we can't support
707 // certain keys that conflict with ApiResult metadata.
708 $keys = array_diff( array_keys( $vars ), array(
709 ApiResult
::META_TYPE
, ApiResult
::META_PRESERVE_KEYS
, ApiResult
::META_KVP_KEY_NAME
,
710 ApiResult
::META_INDEXED_TAG_NAME
, ApiResult
::META_BC_BOOLS
713 // Set metadata appropriately
716 ApiResult
::META_TYPE
=> 'kvp',
717 ApiResult
::META_KVP_KEY_NAME
=> 'key',
718 ApiResult
::META_PRESERVE_KEYS
=> $keys,
719 ApiResult
::META_BC_BOOLS
=> $bools,
720 ApiResult
::META_INDEXED_TAG_NAME
=> 'var',
724 ApiResult
::META_TYPE
=> 'array',
725 ApiResult
::META_BC_BOOLS
=> $bools,
726 ApiResult
::META_INDEXED_TAG_NAME
=> 'value',
731 private function setIndexedTagNames( &$array, $mapping ) {
732 foreach ( $mapping as $key => $name ) {
733 if ( isset( $array[$key] ) ) {
734 ApiResult
::setIndexedTagName( $array[$key], $name );
739 public function getAllowedParams() {
746 ApiBase
::PARAM_TYPE
=> 'integer',
748 'redirects' => false,
750 ApiBase
::PARAM_TYPE
=> 'integer',
753 ApiBase
::PARAM_DFLT
=> 'text|langlinks|categories|links|templates|' .
754 'images|externallinks|sections|revid|displaytitle|iwlinks|properties',
755 ApiBase
::PARAM_ISMULTI
=> true,
756 ApiBase
::PARAM_TYPE
=> array(
772 'encodedjsconfigvars',
780 ApiBase
::PARAM_HELP_MSG_PER_VALUE
=> array(),
784 'effectivelanglinks' => false,
786 'sectiontitle' => array(
787 ApiBase
::PARAM_TYPE
=> 'string',
789 'disablepp' => false,
790 'disableeditsection' => false,
791 'generatexml' => array(
792 ApiBase
::PARAM_DFLT
=> false,
793 ApiBase
::PARAM_HELP_MSG
=> array(
794 'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
798 'sectionpreview' => false,
799 'disabletoc' => false,
800 'contentformat' => array(
801 ApiBase
::PARAM_TYPE
=> ContentHandler
::getAllContentFormats(),
803 'contentmodel' => array(
804 ApiBase
::PARAM_TYPE
=> ContentHandler
::getContentModels(),
809 protected function getExamplesMessages() {
811 'action=parse&page=Project:Sandbox'
812 => 'apihelp-parse-example-page',
813 'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
814 => 'apihelp-parse-example-text',
815 'action=parse&text={{PAGENAME}}&title=Test'
816 => 'apihelp-parse-example-texttitle',
817 'action=parse&summary=Some+[[link]]&prop='
818 => 'apihelp-parse-example-summary',
822 public function getHelpUrls() {
823 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse';