if ( isset( $params['section'] ) ) {
$this->section = $params['section'];
+ if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section ) ) {
+ $this->dieUsage( "The section parameter must be a valid section id or 'new'", "invalidsection" );
+ }
} else {
$this->section = false;
}
$result = $this->getResult();
if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
+ if ( $this->section === 'new' ) {
+ $this->dieUsage( 'section=new cannot be combined with oldid, pageid or page parameters. Please use text', 'params' );
+ }
if ( !is_null( $oldid ) ) {
// Don't use the parser cache
$rev = Revision::newFromId( $oldid );
}
if ( $this->section !== false ) {
- $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
+ if ( $this->section === 'new' ) {
+ // Insert the section title above the content.
+ if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
+ $this->content = $this->content->addSectionHeader( $params['sectiontitle'] );
+ }
+ } else {
+ $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
+ }
}
if ( $params['pst'] || $params['onlypst'] ) {
$result_array['wikitext'] = array();
ApiResult::setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
}
+ if ( !is_null( $params['summary'] ) ) {
+ $result_array['parsedsummary'] = array();
+ ApiResult::setContent(
+ $result_array['parsedsummary'],
+ Linker::formatComment( $params['summary'], $titleObj )
+ );
+ }
+
$result->addValue( null, $this->getModuleName(), $result_array );
return;
'onlypst' => false,
'effectivelanglinks' => false,
'section' => null,
+ 'sectiontitle' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ),
'disablepp' => false,
'disableeditsection' => false,
'generatexml' => array(