r56555 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56554‎ | r56555 | r56556 >
Date:19:15, 17 September 2009
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Merged r56553: script location fix
Modified paths:
  • /branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.php
@@ -63,8 +63,8 @@
6464 );
6565
6666 #########
67 -# IMPORTANT:
68 -# When configuring globals, add them to localsettings.php and edit them THERE
 67+# IMPORTANT: DO NOT EDIT THIS FILE
 68+# When configuring globals, set them at LocalSettings.php instead
6969
7070 # This will only distinguish "sigted", "quality", and unreviewed
7171 # A small icon will show in the upper right hand corner
@@ -182,10 +182,6 @@
183183 # Implicit autoreview group
184184 $wgGroupPermissions['autoreview']['autoreview'] = true;
185185
186 -# Bots are granted autoreview via hooks, mark in rights
187 -# array so that it shows up in sp:ListGroupRights...
188 -$wgGroupPermissions['bot']['autoreview'] = true;
189 -
190186 # Define when users get automatically promoted to Editors. Set as false to disable.
191187 # 'spacing' and 'benchmarks' require edits to be spread out. Users must have X (benchmark)
192188 # edits Y (spacing) days apart.
@@ -269,6 +265,10 @@
270266 # End of configuration variables.
271267 #########
272268
 269+# Bots are granted autoreview via hooks, mark in rights
 270+# array so that it shows up in sp:ListGroupRights...
 271+$wgGroupPermissions['bot']['autoreview'] = true;
 272+
273273 # Lets some users access the review UI and set some flags
274274 $wgAvailableRights[] = 'review';
275275 $wgAvailableRights[] = 'validate'; # Let some users set higher settings
@@ -445,6 +445,7 @@
446446
447447 # Add CSS/JS as needed
448448 $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::injectStyleAndJS';
 449+$wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars';
449450
450451 # Cache updates
451452 $wgHooks['HTMLCacheUpdate::doUpdate'][] = 'FlaggedRevsHooks::doCacheUpdate';
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1286,7 +1286,7 @@
12871287 $tagsJS[$tag] = self::$minQL[$tag];
12881288 }
12891289 $params = array( 'tags' => (object)$tagsJS );
1290 - return Xml::encodeJsVar( (object)$params );
 1290+ return (object)$params;
12911291 }
12921292
12931293 /**
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -17,38 +17,42 @@
1818 return true;
1919 }
2020 global $wgScriptPath, $wgJsMimeType, $wgFlaggedRevsStylePath, $wgFlaggedRevStyleVersion;
 21+ $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFlaggedRevsStylePath );
 22+ # Get JS/CSS file locations
 23+ $encCssFile = htmlspecialchars( "$stylePath/flaggedrevs.css?$wgFlaggedRevStyleVersion" );
 24+ $encJsFile = htmlspecialchars( "$stylePath/flaggedrevs.js?$wgFlaggedRevStyleVersion" );
 25+ # Add CSS file
 26+ $wgOut->addExtensionStyle( $encCssFile );
 27+ # Add JS file
 28+ $head = "<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>";
 29+ $wgOut->addHeadItem( 'FlaggedRevs', $head );
 30+ return true;
 31+ }
 32+
 33+ public static function injectGlobalJSVars( &$globalVars ) {
 34+ global $wgJsMimeType;
 35+ $fa = FlaggedArticle::getGlobalInstance();
 36+ # Try to only add to relevant pages
 37+ if( !$fa || !$fa->isReviewable(true) ) {
 38+ return true;
 39+ }
2140 # Load required messages
2241 wfLoadExtensionMessages( 'FlaggedRevs' );
23 -
24 - $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFlaggedRevsStylePath );
 42+ # Get the review tags on this wiki
2543 $rTags = FlaggedRevs::getJSTagParams();
 44+ # Get page-specific meta-data
2645 $frev = $fa->getStableRev();
2746 $stableId = $frev ? $frev->getRevId() : 0;
28 -
29 - $encCssFile = htmlspecialchars( "$stylePath/flaggedrevs.css?$wgFlaggedRevStyleVersion" );
30 - $encJsFile = htmlspecialchars( "$stylePath/flaggedrevs.js?$wgFlaggedRevStyleVersion" );
31 -
32 - $wgOut->addExtensionStyle( $encCssFile );
33 -
34 - $ajaxReview = Xml::encodeJsVar( (object) array(
 47+ $ajaxReview = (object) array(
3548 'sendingMsg' => wfMsgHtml('revreview-submitting'),
3649 'sentMsgOk' => wfMsgHtml('revreview-finished'),
3750 'sentMsgBad' => wfMsgHtml('revreview-failed'),
3851 'actioncomplete' => wfMsgHtml('actioncomplete'),
3952 'actionfailed' => wfMsgHtml('actionfailed')
40 - )
4153 );
42 -
43 - $head = <<<EOT
44 -<script type="$wgJsMimeType">
45 -var wgFlaggedRevsParams = $rTags;
46 -var wgStableRevisionId = $stableId;
47 -var wgAjaxReview = $ajaxReview
48 -</script>
49 -<script type="$wgJsMimeType" src="$encJsFile"></script>
50 -
51 -EOT;
52 - $wgOut->addHeadItem( 'FlaggedRevs', $head );
 54+ $globalVars['wgFlaggedRevsParams'] = $rTags;
 55+ $globalVars['wgStableRevisionId'] = $stableId;
 56+ $globalVars['wgAjaxReview'] = $ajaxReview;
5357 return true;
5458 }
5559

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56553bug 20690: use MakeGlobalVariablesScript hookaaron19:10, 17 September 2009

Comments

#Comment by Tim Starling (talk | contribs)   00:54, 2 December 2009

This doesn't look like r56553 to me. Please merge only the changes that you actually need to deploy.

Status & tagging log