Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -63,8 +63,8 @@ |
64 | 64 | ); |
65 | 65 | |
66 | 66 | ######### |
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 |
69 | 69 | |
70 | 70 | # This will only distinguish "sigted", "quality", and unreviewed |
71 | 71 | # A small icon will show in the upper right hand corner |
— | — | @@ -182,10 +182,6 @@ |
183 | 183 | # Implicit autoreview group |
184 | 184 | $wgGroupPermissions['autoreview']['autoreview'] = true; |
185 | 185 | |
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 | | - |
190 | 186 | # Define when users get automatically promoted to Editors. Set as false to disable. |
191 | 187 | # 'spacing' and 'benchmarks' require edits to be spread out. Users must have X (benchmark) |
192 | 188 | # edits Y (spacing) days apart. |
— | — | @@ -269,6 +265,10 @@ |
270 | 266 | # End of configuration variables. |
271 | 267 | ######### |
272 | 268 | |
| 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 | + |
273 | 273 | # Lets some users access the review UI and set some flags |
274 | 274 | $wgAvailableRights[] = 'review'; |
275 | 275 | $wgAvailableRights[] = 'validate'; # Let some users set higher settings |
— | — | @@ -445,6 +445,7 @@ |
446 | 446 | |
447 | 447 | # Add CSS/JS as needed |
448 | 448 | $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::injectStyleAndJS'; |
| 449 | +$wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars'; |
449 | 450 | |
450 | 451 | # Cache updates |
451 | 452 | $wgHooks['HTMLCacheUpdate::doUpdate'][] = 'FlaggedRevsHooks::doCacheUpdate'; |
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -1286,7 +1286,7 @@ |
1287 | 1287 | $tagsJS[$tag] = self::$minQL[$tag]; |
1288 | 1288 | } |
1289 | 1289 | $params = array( 'tags' => (object)$tagsJS ); |
1290 | | - return Xml::encodeJsVar( (object)$params ); |
| 1290 | + return (object)$params; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | /** |
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -17,38 +17,42 @@ |
18 | 18 | return true; |
19 | 19 | } |
20 | 20 | 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 | + } |
21 | 40 | # Load required messages |
22 | 41 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
23 | | - |
24 | | - $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFlaggedRevsStylePath ); |
| 42 | + # Get the review tags on this wiki |
25 | 43 | $rTags = FlaggedRevs::getJSTagParams(); |
| 44 | + # Get page-specific meta-data |
26 | 45 | $frev = $fa->getStableRev(); |
27 | 46 | $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( |
35 | 48 | 'sendingMsg' => wfMsgHtml('revreview-submitting'), |
36 | 49 | 'sentMsgOk' => wfMsgHtml('revreview-finished'), |
37 | 50 | 'sentMsgBad' => wfMsgHtml('revreview-failed'), |
38 | 51 | 'actioncomplete' => wfMsgHtml('actioncomplete'), |
39 | 52 | 'actionfailed' => wfMsgHtml('actionfailed') |
40 | | - ) |
41 | 53 | ); |
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; |
53 | 57 | return true; |
54 | 58 | } |
55 | 59 | |