Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -83,6 +83,8 @@ |
84 | 84 | $wgFlaggedRevComments = false; |
85 | 85 | # Make user's watch pages when reviewed if they watch pages that they edit |
86 | 86 | $wgFlaggedRevsWatch = true; |
| 87 | +# Redirect users out to review changes since stable version on save? |
| 88 | +$wgReviewChangesAfterEdit = true; |
87 | 89 | |
88 | 90 | # How long to cache stable versions? (seconds) |
89 | 91 | $wgFlaggedRevsExpire = 7 * 24 * 3600; |
— | — | @@ -592,7 +594,7 @@ |
593 | 595 | return true; |
594 | 596 | } |
595 | 597 | |
596 | | - function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
| 598 | + public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) { |
597 | 599 | global $wgUser, $action; |
598 | 600 | // Only trigger on article view for content pages, not for protect/delete/hist |
599 | 601 | if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' ) |
— | — | @@ -614,7 +616,7 @@ |
615 | 617 | return true; |
616 | 618 | } |
617 | 619 | |
618 | | - function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
| 620 | + public static function updateFromMove( $movePageForm, $oldtitle, $newtitle ) { |
619 | 621 | $dbw = wfGetDB( DB_MASTER ); |
620 | 622 | $dbw->update( 'flaggedrevs', |
621 | 623 | array('fr_namespace' => $newtitle->getNamespace(), 'fr_title' => $newtitle->getDBkey() ), |
— | — | @@ -771,7 +773,7 @@ |
772 | 774 | |
773 | 775 | /** |
774 | 776 | * Callback that autopromotes user according to the setting in |
775 | | - * $wgFlaggedRevsAutopromote |
| 777 | + * $wgFlaggedRevsAutopromote. This is not as efficient as it should be |
776 | 778 | */ |
777 | 779 | public static function autoPromoteUser( $article, $user, &$text, &$summary, &$isminor, &$iswatch, &$section ) { |
778 | 780 | global $wgUser, $wgFlaggedRevsAutopromote; |
— | — | @@ -817,6 +819,24 @@ |
818 | 820 | return true; |
819 | 821 | } |
820 | 822 | |
| 823 | + public static function injectReviewDiffURLParams( $article, &$extraq ) { |
| 824 | + global $wgReviewChangesAfterEdit; |
| 825 | + |
| 826 | + if( !$wgReviewChangesAfterEdit ) |
| 827 | + return; |
| 828 | + |
| 829 | + $frev = self::getOverridingRev( $article->getTitle() ); |
| 830 | + |
| 831 | + if( $frev ) { |
| 832 | + $frev_id = $frev->fr_rev_id; |
| 833 | + $crev_id = $article->getLatest(); |
| 834 | + $extraq .= "oldid={$frev_id}&diff={$crev_id}&topreview=1"; |
| 835 | + } |
| 836 | + |
| 837 | + return true; |
| 838 | + |
| 839 | + } |
| 840 | + |
821 | 841 | static function pageOverride() { return false; } |
822 | 842 | |
823 | 843 | function setPageContent( $article, $outputDone, &$pcache ) {} |
— | — | @@ -1047,7 +1067,7 @@ |
1048 | 1068 | $tfrev = $this->getOverridingRev(); |
1049 | 1069 | if( $tfrev ) return true; |
1050 | 1070 | } |
1051 | | - $this->addQuickReview( $revId, $out, false ); |
| 1071 | + $this->addQuickReview( $revId, $out, $wgRequest->getBool('topreview') ); |
1052 | 1072 | |
1053 | 1073 | return true; |
1054 | 1074 | } |
— | — | @@ -1216,7 +1236,7 @@ |
1217 | 1237 | return true; |
1218 | 1238 | } |
1219 | 1239 | |
1220 | | - function addQuickReview( $id=NULL, $out ) { |
| 1240 | + function addQuickReview( $id=NULL, $out, $top=false ) { |
1221 | 1241 | global $wgOut, $wgTitle, $wgUser, $wgFlaggedRevsOverride, $wgFlaggedRevComments, $wgFlaggedRevsWatch; |
1222 | 1242 | // User must have review rights |
1223 | 1243 | if( !$wgUser->isAllowed( 'review' ) ) return; |
— | — | @@ -1292,7 +1312,11 @@ |
1293 | 1313 | $form .= Xml::submitButton( wfMsgHtml( 'revreview-submit' ) ) . "</p></fieldset>"; |
1294 | 1314 | $form .= Xml::closeElement( 'form' ); |
1295 | 1315 | |
1296 | | - $wgOut->addHTML( '<hr style="clear:both"></hr>' . $form ); |
| 1316 | + if( $top ) |
| 1317 | + $out->mBodytext = $form . '<hr style="clear:both"></hr>' . $out->mBodytext; |
| 1318 | + else |
| 1319 | + $wgOut->addHTML( '<hr style="clear:both"></hr>' . $form ); |
| 1320 | + |
1297 | 1321 | } |
1298 | 1322 | |
1299 | 1323 | /** |
— | — | @@ -1429,9 +1453,9 @@ |
1430 | 1454 | |
1431 | 1455 | ######### Hook attachments ######### |
1432 | 1456 | # Main hooks, overrides pages content, adds tags, sets tabs and permalink |
1433 | | -$wgHooks['SkinTemplateTabs'][] = array($wgFlaggedArticle, 'setCurrentTab'); |
| 1457 | +$wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setCurrentTab'); |
1434 | 1458 | # Update older, incomplete, page caches (ones that lack template Ids/image timestamps) |
1435 | | -$wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'maybeUpdateMainCache'); |
| 1459 | +$wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'maybeUpdateMainCache'); |
1436 | 1460 | $wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'setPageContent'); |
1437 | 1461 | $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($wgFlaggedArticle, 'setPermaLink'); |
1438 | 1462 | # Add tags do edit view |
— | — | @@ -1450,11 +1474,14 @@ |
1451 | 1475 | # Update our table NS/Titles when things are moved |
1452 | 1476 | $wgHooks['SpecialMovepageAfterMove'][] = array($wgFlaggedArticle, 'updateFromMove'); |
1453 | 1477 | # Parser hooks, selects the desired images/templates |
1454 | | -$wgHooks['BeforeParserrenderImageGallery'][] = array( $wgFlaggedArticle, 'parserMakeGalleryStable'); |
1455 | | -$wgHooks['BeforeGalleryFindFile'][] = array( $wgFlaggedArticle, 'galleryFindStableFileTime'); |
1456 | | -$wgHooks['BeforeParserFetchTemplateAndtitle'][] = array( $wgFlaggedArticle, 'parserFetchStableTemplate'); |
| 1478 | +$wgHooks['BeforeParserrenderImageGallery'][] = array($wgFlaggedArticle, 'parserMakeGalleryStable'); |
| 1479 | +$wgHooks['BeforeGalleryFindFile'][] = array($wgFlaggedArticle, 'galleryFindStableFileTime'); |
| 1480 | +$wgHooks['BeforeParserFetchTemplateAndtitle'][] = array($wgFlaggedArticle, 'parserFetchStableTemplate'); |
1457 | 1481 | $wgHooks['BeforeParserMakeImageLinkObj'][] = array( $wgFlaggedArticle, 'parserMakeStableImageLink'); |
1458 | 1482 | # Additional parser versioning |
1459 | 1483 | $wgHooks['ParserAfterTidy'][] = array( $wgFlaggedArticle, 'parserInjectImageTimestamps'); |
1460 | 1484 | $wgHooks['OutputPageParserOutput'][] = array( $wgFlaggedArticle, 'outputInjectImageTimestamps'); |
| 1485 | +# Page review on edit |
| 1486 | +$wgHooks['ArticleUpdateBeforeRedirect'][] = array( $wgFlaggedArticle, 'injectReviewDiffURLParams'); |
| 1487 | + |
1461 | 1488 | ######### |