<?php
/**
- * Created on Dec 01, 2007
- *
* Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
if ( $params['onlypst'] ) {
// Build a result and bail out
$result_array = [];
- if ( $this->contentIsDeleted ) {
- $result_array['textdeleted'] = true;
- }
- if ( $this->contentIsSuppressed ) {
- $result_array['textsuppressed'] = true;
- }
$result_array['text'] = $this->pstContent->serialize( $format );
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
if ( isset( $prop['wikitext'] ) ) {
$result_array['text'] = $p_result->getText( [
'allowTOC' => !$params['disabletoc'],
'enableSectionEditLinks' => !$params['disableeditsection'],
+ 'unwrap' => $params['wrapoutputclass'] === '',
+ 'deduplicateStyles' => !$params['disablestylededuplication'],
] );
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
}
}
if ( isset( $prop['displaytitle'] ) ) {
- $result_array['displaytitle'] = $p_result->getDisplayTitle() ?:
- $titleObj->getPrefixedText();
+ $result_array['displaytitle'] = $p_result->getDisplayTitle() !== false
+ ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
}
if ( isset( $prop['headitems'] ) ) {
}
$wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
- $dom = $wgParser->preprocessToDom( $this->content->getNativeData() );
- if ( is_callable( [ $dom, 'saveXML' ] ) ) {
- $xml = $dom->saveXML();
- } else {
- $xml = $dom->__toString();
- }
+ $xml = $wgParser->preprocessToDom( $this->content->getNativeData() )->__toString();
$result_array['parsetree'] = $xml;
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
}
$popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
$popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
$popts->setIsSectionPreview( $params['sectionpreview'] );
- $popts->setEditSection( !$params['disableeditsection'] );
if ( $params['disabletidy'] ) {
$popts->setTidy( false );
}
- $popts->setWrapOutputClass(
- $params['wrapoutputclass'] === '' ? false : $params['wrapoutputclass']
- );
+ if ( $params['wrapoutputclass'] !== '' ) {
+ $popts->setWrapOutputClass( $params['wrapoutputclass'] );
+ }
$reset = null;
$suppressCache = false;
} else {
$this->content = $page->getContent( Revision::FOR_THIS_USER, $this->getUser() );
if ( !$this->content ) {
- $this->dieWithError( [ 'apierror-missingcontent-pageid', $pageId ] );
+ $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ] );
}
}
$this->contentIsDeleted = $isDeleted;
$pout = $page->getParserOutput( $popts, $revId, $suppressCache );
}
if ( !$pout ) {
- $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] );
+ $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] ); // @codeCoverageIgnore
}
return $pout;
'disablelimitreport' => false,
'disableeditsection' => false,
'disabletidy' => false,
+ 'disablestylededuplication' => false,
'generatexml' => [
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_HELP_MSG => [