if ( !$titleObj || $titleObj->isExternal() ) {
$this->dieUsageMsg( array( 'invalidtitle', $title ) );
}
- if ( !$titleObj->canExist() ) {
- $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
- }
$wgTitle = $titleObj;
- $pageObj = WikiPage::factory( $titleObj );
+ if ( $titleObj->canExist() ) {
+ $pageObj = WikiPage::factory( $titleObj );
+ } else {
+ // Do like MediaWiki::initializeArticle()
+ $article = Article::newFromTitle( $titleObj, $this->getContext() );
+ $pageObj = $article->getPage();
+ }
$popts = $this->makeParserOptions( $pageObj, $params );
$result_array['redirects'] = $redirValues;
}
+ if ( $params['disabletoc'] ) {
+ $p_result->setTOCEnabled( false );
+ }
+
if ( isset( $prop['text'] ) ) {
$result_array['text'] = array();
ApiResult::setContent( $result_array['text'], $p_result->getText() );
'generatexml' => false,
'preview' => false,
'sectionpreview' => false,
+ 'disabletoc' => false,
'contentformat' => array(
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
),
'generatexml' => "Generate XML parse tree (requires contentmodel=$wikitext)",
'preview' => 'Parse in preview mode',
'sectionpreview' => 'Parse in section preview mode (enables preview mode too)',
+ 'disabletoc' => 'Disable table of contents in output',
'contentformat' => array(
'Content serialization format used for the input text',
"Only valid when used with {$p}text",
'code' => 'notwikitext',
'info' => 'The requested operation is only supported on wikitext content.'
),
- array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
) );
}