convert "::1" and other pseudo-IPv6 addresses that Apache may throw at us to their...
[lhc/web/wiklou.git] / includes / EditPage.php
index 860f1ab..8cad492 100644 (file)
@@ -43,10 +43,11 @@ class EditPage {
 
        # Placeholders for text injection by hooks (must be HTML)
        # extensions should take care to _append_ to the present value
-       var $editFormTextTop;
-       var $editFormTextAfterWarn;
-       var $editFormTextAfterTools;
-       var $editFormTextBottom;
+       public $editFormPageTop; // Before even the preview
+       public $editFormTextTop;
+       public $editFormTextAfterWarn;
+       public $editFormTextAfterTools;
+       public $editFormTextBottom;
 
        /**
         * @todo document
@@ -58,9 +59,10 @@ class EditPage {
                $this->mTitle =& $wgTitle;
 
                # Placeholders for text injection by hooks (empty per default)
-               $this->editFormTextTop = "";
-               $this->editFormTextAfterWarn = "";
-               $this->editFormTextAfterTools = "";
+               $this->editFormPageTop =
+               $this->editFormTextTop =
+               $this->editFormTextAfterWarn =
+               $this->editFormTextAfterTools =
                $this->editFormTextBottom = "";
        }
        
@@ -99,24 +101,28 @@ class EditPage {
                                #Undoing a specific edit overrides section editing; section-editing
                                # doesn't work with undoing.
                                $undorev = Revision::newFromId($undo);
-                               $oldrev = $undorev->getPrevious();
 
                                #Sanity check, make sure it's the right page.
                                # Otherwise, $text will be left as-is.
-                               if ($undorev->getPage() == $this->mArticle->getID()) {
+                               if (!is_null($undorev) && $undorev->getPage() == $this->mArticle->getID()) {
+                                       $oldrev = $undorev->getPrevious();
                                        $undorev_text = $undorev->getText();
                                        $oldrev_text = $oldrev->getText();
                                        $currev_text = $text;
        
-                                       $result = wfMerge($undorev_text, $oldrev_text, $currev_text, &$text);
+                                       $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text);
        
                                        if (!$result) {
                                                #Undoing failed. Bailing out with regular revision text.
                                                $text = $currev_text;
 
                                                #Give a warning
-                                               $this->editFormTextTop = "<h2>" . wfMsg('undofailed') . "</h2><br/>\n" .
-                                                                       wfMsg('explainundofailed');
+                                               $this->editFormPageTop .= "<h2>" . wfMsg('undofailed') . "</h2>\n" .
+                                                                       '<p><strong class="error">'.wfMsg('explainundofailed').'</strong></p>';
+                                       } else {
+                                               $this->editFormPageTop .= '<h2>'.wfMsg('undosucceeded')."</h2>\n" .
+                                                                               '<p>'.wfMsg('explainundosucceeded').'</p>';
+                                               $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
                                        }
                                }
                        }
@@ -842,8 +848,8 @@ class EditPage {
         */
        function initialiseForm() {
                $this->edittime = $this->mArticle->getTimestamp();
-               $this->textbox1 = $this->getContent();
                $this->summary = '';
+               $this->textbox1 = $this->getContent();
                if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
                        $this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() ) ;
                wfProxyCheck();
@@ -1047,6 +1053,8 @@ class EditPage {
 
                $checkboxhtml = $minoredithtml . $watchhtml;
 
+               $wgOut->addHTML( $this->editFormPageTop );
+
                if ( $wgUser->getOption( 'previewontop' ) ) {
 
                        if ( 'preview' == $this->formtype ) {