fix JS/CSS view
authorDaniel Kinzler <daniel.kinzler@wikimedia.de>
Tue, 20 Mar 2012 12:12:55 +0000 (12:12 +0000)
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>
Wed, 4 Apr 2012 17:57:05 +0000 (19:57 +0200)
includes/Article.php
includes/Content.php
includes/EditPage.php
includes/WikiPage.php

index d1bdc03..9fccdf6 100644 (file)
@@ -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() );
                }
        }
 
index 0fcb717..8f2a4e0 100644 (file)
@@ -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;
     }
index cd7a8ac..d3719c7 100644 (file)
@@ -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 ) );
 
index 42637e2..0c4bd2c 100644 (file)
@@ -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