* Make "undo" and "rollback" links appear in a consistent fashion on page histories
authorRob Church <robchurch@users.mediawiki.org>
Sat, 7 Jul 2007 00:17:51 +0000 (00:17 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 7 Jul 2007 00:17:51 +0000 (00:17 +0000)
* Fix odd user interface behaviour in rollback success pages - introduce a separate message for the UI feedback and pass standard tool links

RELEASE-NOTES
includes/Article.php
includes/Linker.php
includes/PageHistory.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index df25f06..a55cddb 100644 (file)
@@ -124,6 +124,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   removals, and convenient exporting of watchlist contents
 * Show "undo" links in page histories
 * Option to jump to specified time period in user contributions
+* Improved feedback on "rollback success" page
 
 == Bugfixes since 1.10 ==
 
index e8ab1b2..ccd63d4 100644 (file)
@@ -2257,16 +2257,20 @@ class Article {
                $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from );
                $newComment = $wgRequest->getText( 'summary', $newComment );
 
-               # Save it!
-               $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
-               $wgOut->setRobotpolicy( 'noindex,nofollow' );
-               $wgOut->addHTML( '<h2>' . htmlspecialchars( $newComment ) . "</h2>\n<hr />\n" );
-
+               # Save
                $flags = EDIT_UPDATE | EDIT_MINOR;
                if( $bot )
                        $flags |= EDIT_FORCE_BOT;
-               if( !$this->doEdit( $target->getText(), $newComment, $flags ) )
-                       ;       # todo: this error case has not been handled? Use db transactions?
+               $this->doEdit( $target->getText(), $newComment, $flags );
+
+               # User feedback
+               $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) );
+               $wgOut->setRobotPolicy( 'noindex,nofollow' );
+               $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
+                       . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
+               $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
+                       . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
+               $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
 
                $wgOut->returnToMain( false );
        }
@@ -2991,6 +2995,4 @@ class Article {
                $wgOut->addParserOutput( $parserOutput );
        }
 
-}
-
-
+}
\ No newline at end of file
index 600f455..9613026 100644 (file)
@@ -1175,15 +1175,28 @@ class Linker {
         * @param Revision $rev
         */
        function generateRollback( $rev ) {
-               global $wgUser, $wgRequest;
+               return '<span class="mw-rollback-link">['
+                       . $this->buildRollbackLink( $rev )
+                       . ']</span>';
+       }
+       
+       /**
+        * Build a raw rollback link, useful for collections of "tool" links
+        *
+        * @param Revision $rev
+        * @return string
+        */
+       public function buildRollbackLink( $rev ) {
+               global $wgRequest, $wgUser;
                $title = $rev->getTitle();
-
-               $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
-               $extraRollback .= '&token=' . urlencode(
-                       $wgUser->editToken( array( $title->getPrefixedText(), $rev->getUserText() ) ) );
-               return '<span class="mw-rollback-link">['. $this->makeKnownLinkObj( $title,
-                       wfMsg('rollbacklink'),
-                       'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extraRollback ) .']</span>';
+               $extra  = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
+               $extra .= '&token=' . urlencode( $wgUser->editToken( array( $title->getPrefixedText(),
+                       $rev->getUserText() ) ) );
+               return $this->makeKnownLinkObj(
+                       $title,
+                       wfMsgHtml( 'rollbacklink' ),
+                       'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extra
+               );              
        }
 
        /**
@@ -1323,3 +1336,4 @@ class Linker {
 }
 
 
+
index 2b57d66..7e7c541 100644 (file)
@@ -244,19 +244,26 @@ class PageHistory {
                if( $row->rev_deleted & Revision::DELETED_TEXT ) {
                        $s .= ' ' . wfMsgHtml( 'deletedrev' );
                }
+               
+               $tools = array();
+               
                if( $wgUser->isAllowed( 'rollback' ) && $latest ) {
-                       $s .= ' '.$this->mSkin->generateRollback( $rev );
+                       $tools[] = '<span class="mw-rollback-link">'
+                               . $this->mSkin->buildRollbackLink( $rev )
+                               . '</span>';
                }
-
+                       
                if ( !is_null( $next ) ) {
                        $undolink = $this->mSkin->makeKnownLinkObj(
                                $this->mTitle,
-                               '(' . wfMsgHtml( 'editundo' ) . ')',
+                               wfMsgHtml( 'editundo' ),
                                'action=edit&undoafter=' . $next->rev_id . '&undo=' . $rev->getId()
                        );
-                       $s .= " <span class=\"mw-history-undo\">{$undolink}</span>";
+                       $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
                }
                
+               $s .= ' (' . implode( ' | ', $tools ) . ')';
+               
                wfRunHooks( 'PageHistoryLineEnding', array( &$row , &$s ) );
                
                $s .= "</li>\n";
@@ -599,3 +606,4 @@ class PageHistoryPager extends ReverseChronologicalPager {
 }
 
 
+
index 8abc3ec..89f70fa 100644 (file)
@@ -1802,6 +1802,7 @@ by [[User:$2|$2]] ([[User talk:$2|Talk]]); someone else has edited or rolled bac
 Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]).',
 'editcomment'                 => 'The edit comment was: "<i>$1</i>".', # only shown if there is an edit comment
 'revertpage'                  => 'Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|Talk]]); changed back to last version by [[User:$1|$1]]',
+'rollback-success' => 'Reverted edits by $1; changed back to last version by $2.',
 'sessionfailure'              => 'There seems to be a problem with your login session;
 this action has been canceled as a precaution against session hijacking.
 Please hit "back" and reload the page you came from, then try again.',
index 9b87411..aa5eb3e 100644 (file)
@@ -1154,6 +1154,7 @@ $wgMessageStructure = array(
                'alreadyrolled',
                'editcomment',
                'revertpage',
+               'rollback-success',
                'sessionfailure',
                'protectlogpage',
                'protectlogtext',