From 87d06dff5f057c6c2243c1f0cbf923e7ba887801 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Tue, 20 Mar 2012 12:12:55 +0000 Subject: [PATCH] fix JS/CSS view --- includes/Article.php | 5 +++-- includes/Content.php | 10 ++-------- includes/EditPage.php | 10 ++++------ includes/WikiPage.php | 21 ++++++++++++++------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index d1bdc03bdb..9fccdf68de 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -620,7 +620,7 @@ class Article extends Page { # 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; } @@ -754,7 +754,8 @@ class Article extends Page { // 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() ); } } diff --git a/includes/Content.php b/includes/Content.php index 0fcb7179f3..8f2a4e0676 100644 --- a/includes/Content.php +++ b/includes/Content.php @@ -8,7 +8,7 @@ */ 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; } @@ -100,8 +100,6 @@ abstract class Content { # 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 @@ -205,10 +203,6 @@ abstract class TextContent extends Content { $html = $this->getHtml( $options ); $po = new ParserOutput( $html ); - if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() ); - - #TODO: cache settings, etc? - return $po; } @@ -249,7 +243,7 @@ class WikitextContent extends TextContent { $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; } diff --git a/includes/EditPage.php b/includes/EditPage.php index cd7a8ac8d0..d3719c70fd 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1299,17 +1299,15 @@ class EditPage { 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 @@ -2315,7 +2313,7 @@ HTML $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 ) ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 42637e23f0..0c4bd2c58c 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -303,7 +303,9 @@ class WikiPage extends Page { 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(); } /** @@ -429,7 +431,7 @@ class WikiPage extends Page { * * @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; @@ -563,7 +565,7 @@ class WikiPage extends Page { $content = $this->getContent(); } - if ( $content->isRedirect( ) ) { + if ( !$content || $content->isRedirect( ) ) { return false; } @@ -1111,7 +1113,11 @@ class WikiPage extends Page { $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; @@ -1123,8 +1129,9 @@ class WikiPage extends Page { * @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. @@ -1159,7 +1166,7 @@ class WikiPage extends Page { } wfProfileOut( __METHOD__ ); - return $newContent; + return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext! } /** @@ -2762,7 +2769,7 @@ class PoolWorkArticleView extends PoolCounterWork { } $time = - wfTime(); - $this->parserOutput = $content->getParserOutput( $this->parserOptions ); + $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions ); $time += wfTime(); # Timing hack -- 2.20.1