r23811 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23810‎ | r23811 | r23812 >
Date:00:17, 7 July 2007
Author:robchurch
Status:old
Tags:
Comment:
* Make "undo" and "rollback" links appear in a consistent fashion on page histories
* Fix odd user interface behaviour in rollback success pages - introduce a separate message for the UI feedback and pass standard tool links
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/PageHistory.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1154,6 +1154,7 @@
11551155 'alreadyrolled',
11561156 'editcomment',
11571157 'revertpage',
 1158+ 'rollback-success',
11581159 'sessionfailure',
11591160 'protectlogpage',
11601161 'protectlogtext',
Index: trunk/phase3/includes/Article.php
@@ -2257,17 +2257,21 @@
22582258 $newComment = wfMsgForContent( 'revertpage', $target->getUserText(), $from );
22592259 $newComment = $wgRequest->getText( 'summary', $newComment );
22602260
2261 - # Save it!
2262 - $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
2263 - $wgOut->setRobotpolicy( 'noindex,nofollow' );
2264 - $wgOut->addHTML( '<h2>' . htmlspecialchars( $newComment ) . "</h2>\n<hr />\n" );
2265 -
 2261+ # Save
22662262 $flags = EDIT_UPDATE | EDIT_MINOR;
22672263 if( $bot )
22682264 $flags |= EDIT_FORCE_BOT;
2269 - if( !$this->doEdit( $target->getText(), $newComment, $flags ) )
2270 - ; # todo: this error case has not been handled? Use db transactions?
 2265+ $this->doEdit( $target->getText(), $newComment, $flags );
22712266
 2267+ # User feedback
 2268+ $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) );
 2269+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
 2270+ $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
 2271+ . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
 2272+ $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
 2273+ . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
 2274+ $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
 2275+
22722276 $wgOut->returnToMain( false );
22732277 }
22742278
@@ -2991,6 +2995,4 @@
29922996 $wgOut->addParserOutput( $parserOutput );
29932997 }
29942998
2995 -}
2996 -
2997 -
 2999+}
\ No newline at end of file
Index: trunk/phase3/includes/Linker.php
@@ -1175,15 +1175,28 @@
11761176 * @param Revision $rev
11771177 */
11781178 function generateRollback( $rev ) {
1179 - global $wgUser, $wgRequest;
 1179+ return '<span class="mw-rollback-link">['
 1180+ . $this->buildRollbackLink( $rev )
 1181+ . ']</span>';
 1182+ }
 1183+
 1184+ /**
 1185+ * Build a raw rollback link, useful for collections of "tool" links
 1186+ *
 1187+ * @param Revision $rev
 1188+ * @return string
 1189+ */
 1190+ public function buildRollbackLink( $rev ) {
 1191+ global $wgRequest, $wgUser;
11801192 $title = $rev->getTitle();
1181 -
1182 - $extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
1183 - $extraRollback .= '&token=' . urlencode(
1184 - $wgUser->editToken( array( $title->getPrefixedText(), $rev->getUserText() ) ) );
1185 - return '<span class="mw-rollback-link">['. $this->makeKnownLinkObj( $title,
1186 - wfMsg('rollbacklink'),
1187 - 'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extraRollback ) .']</span>';
 1193+ $extra = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
 1194+ $extra .= '&token=' . urlencode( $wgUser->editToken( array( $title->getPrefixedText(),
 1195+ $rev->getUserText() ) ) );
 1196+ return $this->makeKnownLinkObj(
 1197+ $title,
 1198+ wfMsgHtml( 'rollbacklink' ),
 1199+ 'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extra
 1200+ );
11881201 }
11891202
11901203 /**
@@ -1323,3 +1336,4 @@
13241337 }
13251338
13261339
 1340+
Index: trunk/phase3/includes/PageHistory.php
@@ -244,19 +244,26 @@
245245 if( $row->rev_deleted & Revision::DELETED_TEXT ) {
246246 $s .= ' ' . wfMsgHtml( 'deletedrev' );
247247 }
 248+
 249+ $tools = array();
 250+
248251 if( $wgUser->isAllowed( 'rollback' ) && $latest ) {
249 - $s .= ' '.$this->mSkin->generateRollback( $rev );
 252+ $tools[] = '<span class="mw-rollback-link">'
 253+ . $this->mSkin->buildRollbackLink( $rev )
 254+ . '</span>';
250255 }
251 -
 256+
252257 if ( !is_null( $next ) ) {
253258 $undolink = $this->mSkin->makeKnownLinkObj(
254259 $this->mTitle,
255 - '(' . wfMsgHtml( 'editundo' ) . ')',
 260+ wfMsgHtml( 'editundo' ),
256261 'action=edit&undoafter=' . $next->rev_id . '&undo=' . $rev->getId()
257262 );
258 - $s .= " <span class=\"mw-history-undo\">{$undolink}</span>";
 263+ $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
259264 }
260265
 266+ $s .= ' (' . implode( ' | ', $tools ) . ')';
 267+
261268 wfRunHooks( 'PageHistoryLineEnding', array( &$row , &$s ) );
262269
263270 $s .= "</li>\n";
@@ -599,3 +606,4 @@
600607 }
601608
602609
 610+
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1802,6 +1802,7 @@
18031803 Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]).',
18041804 'editcomment' => 'The edit comment was: "<i>$1</i>".', # only shown if there is an edit comment
18051805 'revertpage' => 'Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|Talk]]); changed back to last version by [[User:$1|$1]]',
 1806+'rollback-success' => 'Reverted edits by $1; changed back to last version by $2.',
18061807 'sessionfailure' => 'There seems to be a problem with your login session;
18071808 this action has been canceled as a precaution against session hijacking.
18081809 Please hit "back" and reload the page you came from, then try again.',
Index: trunk/phase3/RELEASE-NOTES
@@ -124,6 +124,7 @@
125125 removals, and convenient exporting of watchlist contents
126126 * Show "undo" links in page histories
127127 * Option to jump to specified time period in user contributions
 128+* Improved feedback on "rollback success" page
128129
129130 == Bugfixes since 1.10 ==
130131

Follow-up revisions

RevisionCommit summaryAuthorDate
r23912Merged revisions 23662-23909 via svnmerge from...david18:11, 9 July 2007

Status & tagging log