# Viewing a redirect page (e.g. with parameter redirect=no)
$wgOut->addHTML( $this->viewRedirect( $rt ) );
# Parse just to get categories, displaytitle, etc.
- $this->mParserOutput = $content->getParserOutput( $parserOptions );
+ $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions );
$wgOut->addParserOutputNoText( $this->mParserOutput );
$outputDone = true;
}
// Give hooks a chance to customise the output
if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
- $wgOut->addHTML( $this->mContentObject->getHTML() );
+ $po = $this->mContentObject->getParserOutput();
+ $wgOut->addHTML( $po->getText() );
}
}
*/
abstract class Content {
- public function __construct( $modelName = null ) { #FIXME: really need revId? annoying! #FIXME: really $title? or just when parsing, every time?
+ public function __construct( $modelName = null ) {
$this->mModelName = $modelName;
}
# XXX: isCacheable( ) # can/should we do this here?
- # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null )
-
# TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText
# TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format
# TODO: tie into WikiPage, make it use Content-objects throughout, especially in doEdit(), doDelete(), updateRevisionOn(), etc
$html = $this->getHtml( $options );
$po = new ParserOutput( $html );
- if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() );
-
- #TODO: cache settings, etc?
-
return $po;
}
$options = $this->getDefaultParserOptions();
}
- $po = $wgParser->parse( $this->mText, $this->getTitle(), $options, true, true, $this->mRevId );
+ $po = $wgParser->parse( $this->mText, $title, $options, true, true, $revId );
return $po;
}
if ( $this->isConflict ) {
wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
- $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime );
- $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
} else {
wfDebug( __METHOD__ . ": getting section '$this->section'\n" );
- $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle );
- $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
}
if ( is_null( $text ) ) {
wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" );
$this->isConflict = true;
- $text = $this->textbox1; // do not try to merge here!
+ $text = $this->textbox1; // do not try to merge here! #FIXME: unserialize Content
} elseif ( $this->isConflict ) {
# Attempt merge
if ( $this->mergeChangesInto( $text ) ) { #FIXME: passe/receive Content object
$oldtext = $this->getOriginalContent();
$newtext = $this->mArticle->replaceSection(
- $this->section, $this->textbox1, $this->summary, $this->edittime );
+ $this->section, $this->textbox1, $this->summary, $this->edittime ); #FIXME: use Content::replaceSection
wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) );
if ( $text === false ) $content = $this->getContent();
else $content = ContentHandler::makeContent( $text, $this->mTitle ); # TODO: allow model and format to be provided; or better, expect a Content object
- return $content->isRedirect();
+
+ if ( empty( $content ) ) return false;
+ else return $content->isRedirect();
}
/**
*
* @return Contet|false The text of the current revision
*/
- protected function getNativeData() {
+ protected function getNativeData() { #FIXME: examine all uses carefully! caller must be aware of content model!
$content = $this->getContent( Revision::RAW );
if ( !$content ) return null;
$content = $this->getContent();
}
- if ( $content->isRedirect( ) ) {
+ if ( !$content || $content->isRedirect( ) ) {
return false;
}
$handler = ContentHandler::getForTitle( $this->getTitle() );
$undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter );
- return ContentHandler::getContentText( $undone );
+ if ( !$undone ) {
+ return false;
+ } else {
+ return ContentHandler::getContentText( $undone );
+ }
}
return false;
* @param $sectionTitle String: new section's subject, only if $section is 'new'
* @param $edittime String: revision timestamp or null to use the current revision
* @return Content new complete article content, or null if error
+ * @deprecated since 1.20: use Content::replaceSection () instead.
*/
- public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
+ public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: create a Content-based version (take and return Content object)
wfProfileIn( __METHOD__ );
$sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); #XXX: could make section title, but that's not required.
}
wfProfileOut( __METHOD__ );
- return $newContent;
+ return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext!
}
/**
}
$time = - wfTime();
- $this->parserOutput = $content->getParserOutput( $this->parserOptions );
+ $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
$time += wfTime();
# Timing hack