r24842 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24841‎ | r24842 | r24843 >
Date:22:16, 15 August 2007
Author:aaron
Status:old
Tags:
Comment:
*Use ArticleUpdateBeforeRedirect hook to jump to diff against stable on edit
*Add $wgReviewChangesAfterEdit
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -83,6 +83,8 @@
8484 $wgFlaggedRevComments = false;
8585 # Make user's watch pages when reviewed if they watch pages that they edit
8686 $wgFlaggedRevsWatch = true;
 87+# Redirect users out to review changes since stable version on save?
 88+$wgReviewChangesAfterEdit = true;
8789
8890 # How long to cache stable versions? (seconds)
8991 $wgFlaggedRevsExpire = 7 * 24 * 3600;
@@ -592,7 +594,7 @@
593595 return true;
594596 }
595597
596 - function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) {
 598+ public static function maybeUpdateMainCache( $article, &$outputDone, &$pcache ) {
597599 global $wgUser, $action;
598600 // Only trigger on article view for content pages, not for protect/delete/hist
599601 if( !$article || !$article->exists() || !$article->mTitle->isContentPage() || $action !='view' )
@@ -614,7 +616,7 @@
615617 return true;
616618 }
617619
618 - function updateFromMove( $movePageForm, $oldtitle, $newtitle ) {
 620+ public static function updateFromMove( $movePageForm, $oldtitle, $newtitle ) {
619621 $dbw = wfGetDB( DB_MASTER );
620622 $dbw->update( 'flaggedrevs',
621623 array('fr_namespace' => $newtitle->getNamespace(), 'fr_title' => $newtitle->getDBkey() ),
@@ -771,7 +773,7 @@
772774
773775 /**
774776 * Callback that autopromotes user according to the setting in
775 - * $wgFlaggedRevsAutopromote
 777+ * $wgFlaggedRevsAutopromote. This is not as efficient as it should be
776778 */
777779 public static function autoPromoteUser( $article, $user, &$text, &$summary, &$isminor, &$iswatch, &$section ) {
778780 global $wgUser, $wgFlaggedRevsAutopromote;
@@ -817,6 +819,24 @@
818820 return true;
819821 }
820822
 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+
821841 static function pageOverride() { return false; }
822842
823843 function setPageContent( $article, $outputDone, &$pcache ) {}
@@ -1047,7 +1067,7 @@
10481068 $tfrev = $this->getOverridingRev();
10491069 if( $tfrev ) return true;
10501070 }
1051 - $this->addQuickReview( $revId, $out, false );
 1071+ $this->addQuickReview( $revId, $out, $wgRequest->getBool('topreview') );
10521072
10531073 return true;
10541074 }
@@ -1216,7 +1236,7 @@
12171237 return true;
12181238 }
12191239
1220 - function addQuickReview( $id=NULL, $out ) {
 1240+ function addQuickReview( $id=NULL, $out, $top=false ) {
12211241 global $wgOut, $wgTitle, $wgUser, $wgFlaggedRevsOverride, $wgFlaggedRevComments, $wgFlaggedRevsWatch;
12221242 // User must have review rights
12231243 if( !$wgUser->isAllowed( 'review' ) ) return;
@@ -1292,7 +1312,11 @@
12931313 $form .= Xml::submitButton( wfMsgHtml( 'revreview-submit' ) ) . "</p></fieldset>";
12941314 $form .= Xml::closeElement( 'form' );
12951315
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+
12971321 }
12981322
12991323 /**
@@ -1429,9 +1453,9 @@
14301454
14311455 ######### Hook attachments #########
14321456 # Main hooks, overrides pages content, adds tags, sets tabs and permalink
1433 -$wgHooks['SkinTemplateTabs'][] = array($wgFlaggedArticle, 'setCurrentTab');
 1457+$wgHooks['SkinTemplateTabs'][] = array( $wgFlaggedArticle, 'setCurrentTab');
14341458 # Update older, incomplete, page caches (ones that lack template Ids/image timestamps)
1435 -$wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'maybeUpdateMainCache');
 1459+$wgHooks['ArticleViewHeader'][] = array( $wgFlaggedArticle, 'maybeUpdateMainCache');
14361460 $wgHooks['ArticleViewHeader'][] = array($wgFlaggedArticle, 'setPageContent');
14371461 $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = array($wgFlaggedArticle, 'setPermaLink');
14381462 # Add tags do edit view
@@ -1450,11 +1474,14 @@
14511475 # Update our table NS/Titles when things are moved
14521476 $wgHooks['SpecialMovepageAfterMove'][] = array($wgFlaggedArticle, 'updateFromMove');
14531477 # 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');
14571481 $wgHooks['BeforeParserMakeImageLinkObj'][] = array( $wgFlaggedArticle, 'parserMakeStableImageLink');
14581482 # Additional parser versioning
14591483 $wgHooks['ParserAfterTidy'][] = array( $wgFlaggedArticle, 'parserInjectImageTimestamps');
14601484 $wgHooks['OutputPageParserOutput'][] = array( $wgFlaggedArticle, 'outputInjectImageTimestamps');
 1485+# Page review on edit
 1486+$wgHooks['ArticleUpdateBeforeRedirect'][] = array( $wgFlaggedArticle, 'injectReviewDiffURLParams');
 1487+
14611488 #########

Status & tagging log