Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -388,7 +388,10 @@ |
389 | 389 | 'revreview-submitedit', 'revreview-submitedit-title', |
390 | 390 | 'revreview-submit-review', 'revreview-submit-unreview', |
391 | 391 | 'revreview-submit-reviewed', 'revreview-submit-unreviewed', |
392 | | - 'revreview-submitting', 'actioncomplete', 'actionfailed' |
| 392 | + 'revreview-submitting', 'actioncomplete', 'actionfailed', |
| 393 | + 'revreview-adv-reviewing-p', 'revreview-adv-reviewing-c', |
| 394 | + 'revreview-sadv-reviewing-p', 'revreview-sadv-reviewing-c', |
| 395 | + 'revreview-advertise-start', 'revreview-advertise-stop' |
393 | 396 | ), |
394 | 397 | 'dependencies' => array( 'mediawiki.util' ), |
395 | 398 | 'localBasePath' => $localModulePath, |
— | — | @@ -500,9 +503,6 @@ |
501 | 504 | # Implicit autoreview rights group |
502 | 505 | $wgHooks['AutopromoteCondition'][] = 'FlaggedRevsHooks::checkAutoPromoteCond'; |
503 | 506 | |
504 | | -# Check if a page is currently being reviewed |
505 | | -$wgHooks['MediaWikiPerformAction'][] = 'FlaggedRevsUIHooks::onMediaWikiPerformAction'; |
506 | | - |
507 | 507 | # Actually register special pages |
508 | 508 | $wgHooks['SpecialPage_initList'][] = 'FlaggedRevsUIHooks::defineSpecialPages'; |
509 | 509 | |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php |
— | — | @@ -119,30 +119,6 @@ |
120 | 120 | return true; |
121 | 121 | } |
122 | 122 | |
123 | | - public static function onMediaWikiPerformAction( |
124 | | - $output, $article, Title $title, $user, $request |
125 | | - ) { |
126 | | - $fa = FlaggedPage::getTitleInstance( $title ); |
127 | | - self::maybeMarkUnderReview( $fa, $request ); |
128 | | - return true; |
129 | | - } |
130 | | - |
131 | | - // Mark when an unreviewed page is being reviewed |
132 | | - protected static function maybeMarkUnderReview( FlaggedPage $fa, WebRequest $request ) { |
133 | | - global $wgUser; |
134 | | - if ( !$request->getInt( 'reviewing' ) && !$request->getInt( 'rcid' ) ) { |
135 | | - return true; // not implied by URL |
136 | | - } |
137 | | - # Set a key to note when someone is reviewing this. |
138 | | - # NOTE: diff-to-stable views already handled elsewhere. |
139 | | - if ( $fa->isReviewable() && !$fa->getStable() // not reviewed yet |
140 | | - && $fa->getTitle()->userCan( 'review' ) ) |
141 | | - { |
142 | | - FRUserActivity::setUserReviewingPage( $wgUser, $fa->getID() ); |
143 | | - } |
144 | | - return true; |
145 | | - } |
146 | | - |
147 | 123 | /** Add user preferences */ |
148 | 124 | public static function onGetPreferences( $user, array &$preferences ) { |
149 | 125 | // Box or bar UI |
Index: trunk/extensions/FlaggedRevs/presentation/language/RevisionReview.i18n.php |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | See the [[Special:Unreviewedpages|list of unreviewed pages]].', |
55 | 55 | 'revreview-stable1' => 'You may want to view [{{fullurl:$1|stableid=$2}} this flagged version] and see if it is now the [{{fullurl:$1|stable=1}} stable version] of this page.', |
56 | 56 | 'revreview-stable2' => 'You may want to view the [{{fullurl:$1|stable=1}} stable version] of this page.', |
| 57 | + 'revreview-cancel' => 'Cancel', |
57 | 58 | 'revreview-submit' => 'Submit', |
58 | 59 | 'revreview-submitting' => 'Submitting...', |
59 | 60 | 'revreview-submit-review' => 'Accept revision', |
— | — | @@ -64,8 +65,12 @@ |
65 | 66 | 'revreview-successful2' => '\'\'\'Revision of [[:$1|$1]] successfully unflagged.\'\'\'', |
66 | 67 | 'revreview-poss-conflict-p' => '\'\'\'Warning: [[User:$1|$1]] started reviewing this page on $2 at $3.\'\'\'', |
67 | 68 | 'revreview-poss-conflict-c' => '\'\'\'Warning: [[User:$1|$1]] started reviewing these changes on $2 at $3.\'\'\'', |
68 | | - 'revreview-adv-reviewing-p' => '\'\'\'Notice: You are being advertised as having started reviewing this page on $1 at $2.\'\'\'', |
69 | | - 'revreview-adv-reviewing-c' => '\'\'\'Notice: You are being advertised as having started reviewing these changes on $1 at $2.\'\'\'', |
| 69 | + 'revreview-adv-reviewing-p' => 'Notice: Other reviewers can see that you are reviewing this page.', |
| 70 | + 'revreview-adv-reviewing-c' => 'Notice: Other reviewers can see that you are reviewing these changes.', |
| 71 | + 'revreview-sadv-reviewing-p' => 'Notice: Please advertise yourself as reviewing this page.', |
| 72 | + 'revreview-sadv-reviewing-c' => 'Notice: Please advertise yourself as reviewing these changes.', |
| 73 | + 'revreview-advertise-start' => 'Advertise', |
| 74 | + 'revreview-advertise-stop' => 'De-advertise', |
70 | 75 | 'revreview-toolow' => '\'\'\'You must rate each of the attributes higher than "inadequate" in order for a revision to be considered reviewed.\'\'\' |
71 | 76 | |
72 | 77 | To remove the review status of a revision, click "unaccept". |
— | — | @@ -78,7 +83,7 @@ |
79 | 84 | 'revreview-update-edited-prev' => '<span class="flaggedrevs_important">Your changes are not yet in the stable version. There are previous changes pending review.</span> |
80 | 85 | |
81 | 86 | Please review all the changes shown below to make your edits appear in the stable version.', |
82 | | - 'revreview-update-includes' => '\'\'\'Templates/files updated (unreviewed pages in bold):\'\'\'', |
| 87 | + 'revreview-update-includes' => 'Templates/files updated (unreviewed pages in bold):', |
83 | 88 | |
84 | 89 | 'revreview-reject-header' => 'Reject changes for $1', |
85 | 90 | 'revreview-reject-text-list' => 'By completing this action you will be \'\'\'rejecting\'\'\' the source text changes from the following {{PLURAL:$1|revision|revisions}} of [[:$2|$2]]:', |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php |
— | — | @@ -1416,9 +1416,6 @@ |
1417 | 1417 | $changeDiv = ''; |
1418 | 1418 | # If the user can review then prompt them to review them... |
1419 | 1419 | if ( $wgUser->isAllowed( 'review' ) ) { |
1420 | | - # Set a key to note that someone is viewing this |
1421 | | - FRUserActivity::setUserReviewingDiff( |
1422 | | - $wgUser, $oldRev->getId(), $newRev->getId() ); |
1423 | 1420 | // Reviewer just edited... |
1424 | 1421 | if ( $wgRequest->getInt( 'shownotice' ) |
1425 | 1422 | && $newRev->isCurrent() |
Index: trunk/extensions/FlaggedRevs/presentation/RevisionReviewFormUI.php |
— | — | @@ -124,15 +124,18 @@ |
125 | 125 | $form .= Xml::closeElement( 'legend' ) . "\n"; |
126 | 126 | # Show explanatory text |
127 | 127 | $form .= $this->topNotice; |
128 | | - # Show possible conflict warning msg... |
| 128 | + |
| 129 | + # Check if anyone is reviewing this already and |
| 130 | + # show a conflict warning message as needed... |
129 | 131 | if ( $priorRevId ) { |
130 | 132 | list( $u, $ts ) = |
131 | 133 | FRUserActivity::getUserReviewingDiff( $priorRevId, $this->rev->getId() ); |
132 | 134 | } else { |
133 | 135 | list( $u, $ts ) = FRUserActivity::getUserReviewingPage( $this->rev->getPage() ); |
134 | 136 | } |
| 137 | + $form .= "<p>"; |
135 | 138 | if ( $u !== null ) { // page under review... |
136 | | - $form .= '<p><span class="fr-under-review">'; |
| 139 | + $form .= '<span class="fr-under-review">'; |
137 | 140 | if ( $u != $this->user->getName() ) { // by another user... |
138 | 141 | $msg = $priorRevId |
139 | 142 | ? 'revreview-poss-conflict-c' |
— | — | @@ -143,11 +146,19 @@ |
144 | 147 | $msg = $priorRevId |
145 | 148 | ? 'revreview-adv-reviewing-c' |
146 | 149 | : 'revreview-adv-reviewing-p'; |
147 | | - $form .= wfMsgExt( $msg, 'parseinline', |
148 | | - $wgLang->date( $ts, true ), $wgLang->time( $ts, true ) ); |
| 150 | + $form .= wfMsgHtml( $msg ); |
149 | 151 | } |
150 | | - $form .= "</span></p>\n"; |
| 152 | + $form .= "</span>"; |
| 153 | + } else { // page not under review; add JS button |
| 154 | + $form .= '<span id="mw-fr-reviewing-status" style="display:none;"></span>'; |
151 | 155 | } |
| 156 | + # Let user toggle advertising that they are reviewing this |
| 157 | + if ( $u === null || $u === $this->user->getName() ) { |
| 158 | + $form .= '<span id="mw-fr-reviewing-toggle" style="display:none;">'; |
| 159 | + $form .= ' (<a href="javascript:void()"></a>)'; // JS activated |
| 160 | + $form .= '</span>'; |
| 161 | + } |
| 162 | + $form .= "</p>\n"; |
152 | 163 | |
153 | 164 | if ( $disabled ) { |
154 | 165 | $form .= Xml::openElement( 'div', array( 'class' => 'fr-rating-controls-disabled', |
— | — | @@ -185,11 +196,14 @@ |
186 | 197 | } |
187 | 198 | # Determine if there will be reject button |
188 | 199 | $rejectId = $this->rejectRefRevId(); |
| 200 | + |
189 | 201 | # Add the submit buttons |
190 | 202 | $form .= self::submitButtons( $rejectId, $frev, (bool)$disabled, $reviewIncludes ); |
191 | | - # Untoggle "reviewing" status on exit |
192 | | - $form .= '<script type="text/javascript">var jsReviewingStatus = ' . |
193 | | - (int)( $u == $this->user->getName() ) . "</script>\n"; |
| 203 | + # Add "cancel" link |
| 204 | + $form .= Linker::link( $article->getTitle(), |
| 205 | + wfMsg( 'revreview-cancel' ), |
| 206 | + array( 'onClick' => 'history.back(); return !history.length;' ) ); |
| 207 | + |
194 | 208 | # Show stability log if there is anything interesting... |
195 | 209 | if ( $article->isPageLocked() ) { |
196 | 210 | $form .= ' ' . FlaggedRevsXML::logToggle( 'revreview-log-toggle-show' ); |
— | — | @@ -208,7 +222,9 @@ |
209 | 223 | $form .= Html::hidden( 'oldid', $revId, array( 'id' => 'mw-fr-input-oldid' ) ) . "\n"; |
210 | 224 | $form .= Html::hidden( 'wpEditToken', $this->user->editToken() ) . "\n"; |
211 | 225 | $form .= Html::hidden( 'changetime', $reviewTime, |
212 | | - array( 'id' => 'mw-fr-input-changetime' ) ) . "\n";; // id for JS |
| 226 | + array( 'id' => 'mw-fr-input-changetime' ) ) . "\n"; // id for JS |
| 227 | + $form .= Html::hidden( 'userreviewing', (int)($u === $this->user->getName()), |
| 228 | + array( 'id' => 'mw-fr-user-reviewing' ) ) . "\n"; // id for JS |
213 | 229 | # Add review parameters |
214 | 230 | $form .= Html::hidden( 'templateParams', $templateParams ) . "\n"; |
215 | 231 | $form .= Html::hidden( 'imageParams', $imageParams ) . "\n"; |
Index: trunk/extensions/FlaggedRevs/presentation/modules/review.js |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | window.FlaggedRevsReview = { |
| 9 | + 'isUserReviewing': 0, // user reviewing this page? |
9 | 10 | /* |
10 | 11 | * Updates for radios/checkboxes on patch by Daniel Arnold (bug 13744). |
11 | 12 | * Visually update the revision rating form on change. |
— | — | @@ -322,17 +323,79 @@ |
323 | 324 | }, |
324 | 325 | |
325 | 326 | /* |
| 327 | + * Enable AJAX-based functionality to set that a user is reviewing a page/diff |
| 328 | + */ |
| 329 | + 'enableAjaxReviewActivity': function() { |
| 330 | + // User is already reviewing in another tab... |
| 331 | + if ( $('#mw-fr-user-reviewing').val() == 1 ) { |
| 332 | + var msgkey = $('#mw-fr-input-refid') |
| 333 | + ? 'revreview-adv-reviewing-c' |
| 334 | + : 'revreview-adv-reviewing-p'; |
| 335 | + $('#mw-fr-reviewing-status').html( |
| 336 | + mw.msg( msgkey, [mw.config.get('wgUserName')] ) // advertised notice |
| 337 | + ); |
| 338 | + $('#mw-fr-reviewing-toggle a').html( |
| 339 | + mw.msg('revreview-advertise-stop') |
| 340 | + ).click( FlaggedRevsReview.deadvertiseReviewing ); |
| 341 | + // User is not already reviewing this.... |
| 342 | + } else { |
| 343 | + var msgkey = $('#mw-fr-input-refid') |
| 344 | + ? 'revreview-sadv-reviewing-c' |
| 345 | + : 'revreview-sadv-reviewing-p'; |
| 346 | + $('#mw-fr-reviewing-status').html( |
| 347 | + mw.msg( msgkey, [mw.config.get('wgUserName')] ) // suggest to advertise |
| 348 | + ); |
| 349 | + |
| 350 | + $('#mw-fr-reviewing-toggle a').html( |
| 351 | + mw.msg('revreview-advertise-start') |
| 352 | + ).click( FlaggedRevsReview.advertiseReviewing ); |
| 353 | + } |
| 354 | + $('#mw-fr-reviewing-status').addClass('fr-under-review').show(); |
| 355 | + $('#mw-fr-reviewing-toggle').show(); |
| 356 | + }, |
| 357 | + |
| 358 | + /* |
| 359 | + * Flag users as "now reviewing" |
| 360 | + */ |
| 361 | + 'advertiseReviewing': function() { |
| 362 | + FlaggedRevsReview.setReviewingStatus( 1 ); |
| 363 | + var msgkey = $('#mw-fr-input-refid') |
| 364 | + ? 'revreview-adv-reviewing-c' // diff |
| 365 | + : 'revreview-adv-reviewing-p' // page |
| 366 | + $('#mw-fr-reviewing-status').html( |
| 367 | + mw.msg( msgkey, [mw.config.get('wgUserName')] ) |
| 368 | + ); |
| 369 | + // Invert toggle text/function... |
| 370 | + $('#mw-fr-reviewing-toggle a').html( |
| 371 | + mw.msg('revreview-advertise-stop') |
| 372 | + ).unbind('click').click( FlaggedRevsReview.deadvertiseReviewing ); |
| 373 | + }, |
| 374 | + |
| 375 | + /* |
326 | 376 | * Flag users as "no longer reviewing" |
327 | 377 | */ |
328 | 378 | 'deadvertiseReviewing': function() { |
329 | | - var form = document.getElementById('mw-fr-reviewform'); |
330 | | - if( form && jsReviewingStatus ) { |
331 | | - var oRevId = document.getElementById('mw-fr-input-refid').value; |
332 | | - var nRevId = document.getElementById('mw-fr-input-oldid').value; |
333 | | - } else if( location.href.indexOf('&reviewing=1') != -1 ) { |
334 | | - var oRevId = 0; |
335 | | - var nRevId = mw.config.get('wgCurRevisionId'); |
336 | | - } |
| 379 | + FlaggedRevsReview.setReviewingStatus( 0 ); |
| 380 | + var msgkey = $('#mw-fr-input-refid') |
| 381 | + ? 'revreview-sadv-reviewing-c' // diff |
| 382 | + : 'revreview-sadv-reviewing-p' // page |
| 383 | + $('#mw-fr-reviewing-status').html( |
| 384 | + mw.msg( msgkey, [mw.config.get('wgUserName')] ) |
| 385 | + ); |
| 386 | + // Invert toggle text/function... |
| 387 | + $('#mw-fr-reviewing-toggle a').html( |
| 388 | + mw.msg('revreview-advertise-start') |
| 389 | + ).unbind('click').click( FlaggedRevsReview.advertiseReviewing ); |
| 390 | + }, |
| 391 | + |
| 392 | + /* |
| 393 | + * Set reviewing status for this page/diff |
| 394 | + */ |
| 395 | + 'setReviewingStatus': function( value ) { |
| 396 | + // Get {previd,oldid} array for this page view. |
| 397 | + // The previd value will be 0 if this is not a diff view. |
| 398 | + var oRevId = $('#mw-fr-input-refid') ? $('#mw-fr-input-refid').val() : 0; |
| 399 | + var nRevId = $('#mw-fr-input-oldid') ? $('#mw-fr-input-oldid').val() : 0; |
337 | 400 | if ( nRevId > 0 ) { |
338 | 401 | // Send GET request via AJAX! |
339 | 402 | var call = jQuery.ajax({ |
— | — | @@ -341,15 +404,16 @@ |
342 | 405 | action : 'reviewactivity', |
343 | 406 | previd : oRevId, |
344 | 407 | oldid : nRevId, |
345 | | - reviewing : 0 |
| 408 | + reviewing : value |
346 | 409 | }, |
347 | 410 | type : "POST", |
348 | 411 | dataType: "html", // response type |
349 | | - timeout : 2000, // don't delay user exiting |
| 412 | + timeout : 1700, // don't delay user exiting |
350 | 413 | async : false |
351 | 414 | }); |
352 | 415 | } |
353 | | - return; |
| 416 | + FlaggedRevsReview.isUserReviewing = value; |
| 417 | + return ( call.status == 200 ); |
354 | 418 | } |
355 | 419 | }; |
356 | 420 | |
— | — | @@ -357,6 +421,11 @@ |
358 | 422 | FlaggedRevsReview.maybeDisableAcceptButton(); |
359 | 423 | FlaggedRevsReview.updateRatingFormColors(); |
360 | 424 | FlaggedRevsReview.enableAjaxReview(); |
| 425 | +FlaggedRevsReview.enableAjaxReviewActivity(); |
361 | 426 | |
362 | 427 | // Flag users as "no longer reviewing" on navigate-away |
363 | | -window.onbeforeunload = FlaggedRevsReview.deadvertiseReviewing; |
| 428 | +window.onbeforeunload = function( e ) { |
| 429 | + if ( FlaggedRevsReview.isUserReviewing == 1 ) { |
| 430 | + FlaggedRevsReview.deadvertiseReviewing; |
| 431 | + } |
| 432 | +}; |
Index: trunk/extensions/FlaggedRevs/presentation/RejectConfirmationFormUI.php |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | $form .= Html::input( 'wpSubmit', wfMsg( 'revreview-reject-confirm' ), 'submit' ); |
149 | 149 | $form .= ' '; |
150 | 150 | $form .= $skin->link( $this->form->getPage(), wfMsg( 'revreview-reject-cancel' ), |
151 | | - array( 'onClick' => 'history.back(); return false;' ), |
| 151 | + array( 'onClick' => 'history.back(); return !history.length;' ), |
152 | 152 | array( 'oldid' => $this->form->getRefId(), 'diff' => $this->form->getOldId() ) ); |
153 | 153 | $form .= Xml::closeElement( 'form' ); |
154 | 154 | |