return;
}
// Not cached (save or load)
- $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts );
+ $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); #FIXME: use Content object¡
}
$result_array = array();
$result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
}
+ if ( $params['generatexml'] ) {
+ $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS );
+ $dom = $wgParser->preprocessToDom( $this->text );
+ if ( is_callable( array( $dom, 'saveXML' ) ) ) {
+ $xml = $dom->saveXML();
+ } else {
+ $xml = $dom->__toString();
+ }
+ $result_array['parsetree'] = array();
+ $result->setContent( $result_array['parsetree'], $xml );
+ }
+
$result_mapping = array(
'redirects' => 'r',
'langlinks' => 'll',
$page = WikiPage::factory( $titleObj );
- if ( $this->section !== false ) {
+ if ( $this->section !== false ) { #FIXME: get section Content, get parser output, ...
$this->text = $this->getSectionText( $page->getRawText(), !is_null( $pageId )
- ? 'page id ' . $pageId : $titleObj->getText() );
+ ? 'page id ' . $pageId : $titleObj->getText() ); #FIXME: get section...
// Not cached (save or load)
return $wgParser->parse( $this->text, $titleObj, $popts );
$this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
}
if ( $getWikitext ) {
- $this->text = $page->getRawText();
+ $this->content = $page->getContent( Revision::RAW ); #FIXME: use $this->content everywhere
+ $this->text = ContentHandler::getContentText( $this->content ); #FIXME: serialize, get format from params; or use object structure in result?
}
return $pout;
}
}
- private function getSectionText( $text, $what ) {
+ private function getSectionText( $text, $what ) { #FIXME: replace with Content::getSection
global $wgParser;
// Not cached (save or load)
$text = $wgParser->getSection( $text, $this->section, false );
return '';
}
- $s = htmlspecialchars( wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ) );
+ $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() );
$langs = array();
foreach ( $languages as $l ) {
'uselang' => null,
'section' => null,
'disablepp' => false,
+ 'generatexml' => false,
);
}
'uselang' => 'Which language to parse the request in',
'section' => 'Only retrieve the content of this section number',
'disablepp' => 'Disable the PP Report from the parser output',
+ 'generatexml' => 'Generate XML parse tree',
);
}