Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -73,7 +73,8 @@ |
74 | 74 | # Get variables from query string :P |
75 | 75 | $section = $wgRequest->getVal( 'section' ); |
76 | 76 | $preload = $wgRequest->getVal( 'preload' ); |
77 | | - $undo = $wgRequest->getVal( 'undo' ); |
| 77 | + $undoafter = $wgRequest->getVal( 'undoafter' ); |
| 78 | + $undoto = $wgRequest->getVal( 'undoto' ); |
78 | 79 | |
79 | 80 | wfProfileIn( __METHOD__ ); |
80 | 81 | |
— | — | @@ -98,24 +99,21 @@ |
99 | 100 | |
100 | 101 | $text = $this->mArticle->getContent(); |
101 | 102 | |
102 | | - if ( $undo > 0 ) { |
| 103 | + if ( $undoafter > 0 && $undoto > $undoafter ) { |
103 | 104 | #Undoing a specific edit overrides section editing; section-editing |
104 | 105 | # doesn't work with undoing. |
105 | | - $undorev = Revision::newFromId($undo); |
106 | | - $oldrev = $undorev ? $undorev->getPrevious() : null; |
| 106 | + $undorev = Revision::newFromId($undoto); |
| 107 | + $oldrev = Revision::newFromId($undoafter); |
107 | 108 | |
108 | 109 | #Sanity check, make sure it's the right page. |
109 | 110 | # Otherwise, $text will be left as-is. |
110 | | - if( !is_null($undorev) |
111 | | - && !is_null( $oldrev ) |
112 | | - && $undorev->getPage() == $this->mArticle->getID() ) { |
113 | | - |
| 111 | + if ( !is_null($undorev) && !is_null($oldrev) && $undorev->getPage()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) { |
114 | 112 | $undorev_text = $undorev->getText(); |
115 | | - $oldrev_text = $oldrev->getText(); |
116 | | - $currev_text = $text; |
| 113 | + $oldrev_text = $oldrev->getText(); |
| 114 | + $currev_text = $text; |
117 | 115 | |
118 | 116 | #No use doing a merge if it's just a straight revert. |
119 | | - if ($currev_text != $undorev_text) { |
| 117 | + if ( $currev_text != $undorev_text ) { |
120 | 118 | $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text); |
121 | 119 | } else { |
122 | 120 | $text = $oldrev_text; |
— | — | @@ -131,21 +129,24 @@ |
132 | 130 | if( $result ) { |
133 | 131 | # Inform the user of our success and set an automatic edit summary |
134 | 132 | $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) ); |
135 | | - $this->summary = wfMsgForContent( 'undo-summary', $undo, $undorev->getUserText() ); |
| 133 | + $firstrev = $oldrev->getNext(); |
| 134 | + # If we just undid one rev, use an autosummary |
| 135 | + if ( $firstrev->mId == $undoto ) { |
| 136 | + $this->summary = wfMsgForContent('undo-summary', $undoto, $undorev->getUserText()); |
| 137 | + } |
136 | 138 | $this->formtype = 'diff'; |
137 | 139 | } else { |
138 | 140 | # Warn the user that something went wrong |
139 | 141 | $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-failure' ) ); |
140 | 142 | } |
| 143 | + } else if( $section != '' ) { |
| 144 | + if( $section == 'new' ) { |
| 145 | + $text = $this->getPreloadedText( $preload ); |
| 146 | + } else { |
| 147 | + $text = $wgParser->getSection( $text, $section ); |
141 | 148 | } |
142 | | - else if( $section != '' ) { |
143 | | - if( $section == 'new' ) { |
144 | | - $text = $this->getPreloadedText( $preload ); |
145 | | - } else { |
146 | | - $text = $wgParser->getSection( $text, $section ); |
147 | | - } |
148 | | - } |
149 | 149 | } |
| 150 | + } |
150 | 151 | |
151 | 152 | wfProfileOut( __METHOD__ ); |
152 | 153 | return $text; |
Index: trunk/phase3/includes/DifferenceEngine.php |
— | — | @@ -546,21 +546,17 @@ |
547 | 547 | $newLink = $this->mNewPage->escapeLocalUrl(); |
548 | 548 | $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) ); |
549 | 549 | $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' ); |
550 | | - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); |
551 | 550 | |
552 | 551 | $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a> ($timestamp)" |
553 | | - . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)" |
554 | | - . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
| 552 | + . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
555 | 553 | |
556 | 554 | } else { |
557 | 555 | $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); |
558 | 556 | $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid ); |
559 | | - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid ); |
560 | 557 | $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) ); |
561 | 558 | |
562 | 559 | $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>" |
563 | | - . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)" |
564 | | - . " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
| 560 | + . " (<a href='$newEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
565 | 561 | } |
566 | 562 | |
567 | 563 | // Load the old revision object |
— | — | @@ -591,6 +587,9 @@ |
592 | 588 | $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid ); |
593 | 589 | $this->mOldtitle = "<a href='$oldLink'>" . htmlspecialchars( wfMsg( 'revisionasof', $t ) ) |
594 | 590 | . "</a> (<a href='$oldEdit'>" . htmlspecialchars( wfMsg( 'editold' ) ) . "</a>)"; |
| 591 | + //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo) |
| 592 | + $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undoto=' . $this->mNewid); |
| 593 | + $this->mNewtitle .= " (<a href='$newUndo'>" . htmlspecialchars( wfMsg( 'editundo' ) ) . "</a>)"; |
595 | 594 | } |
596 | 595 | |
597 | 596 | return true; |