Index: trunk/extensions/ReaderFeedback/ReaderFeedback.hooks.php |
— | — | @@ -20,28 +20,25 @@ |
21 | 21 | wfLoadExtensionMessages( 'ReaderFeedback' ); |
22 | 22 | |
23 | 23 | $stylePath = str_replace( '$wgScriptPath', $wgScriptPath, $wgFeedbackStylePath ); |
24 | | - $fTags = ReaderFeedback::getJSFeedbackParams(); |
25 | 24 | |
26 | 25 | $encCssFile = htmlspecialchars( "$stylePath/readerfeedback.css?$wgFeedbackStyleVersion" ); |
27 | 26 | $encJsFile = htmlspecialchars( "$stylePath/readerfeedback.js?$wgFeedbackStyleVersion" ); |
28 | | - |
| 27 | + // Add CSS |
29 | 28 | $wgOut->addExtensionStyle( $encCssFile ); |
| 29 | + // Add JS |
| 30 | + $head = "<script type=\"$wgJsMimeType\" src=\"$encJsFile\"></script>\n"; |
| 31 | + $wgOut->addHeadItem( 'ReaderFeedback', $head ); |
30 | 32 | |
31 | | - $ajaxFeedback = Xml::encodeJsVar( (object) array( |
| 33 | + return true; |
| 34 | + } |
| 35 | + |
| 36 | + public static function injectJSVars( &$globalVars ) { |
| 37 | + global $wgUser; |
| 38 | + $globalVars['wgFeedbackParams'] = ReaderFeedback::getJSFeedbackParams(); |
| 39 | + $globalVars['wgAjaxFeedback'] = (object) array( |
32 | 40 | 'sendingMsg' => wfMsgHtml('readerfeedback-submitting'), |
33 | 41 | 'sentMsg' => wfMsgHtml('readerfeedback-finished') |
34 | | - ) |
35 | 42 | ); |
36 | | - |
37 | | - $head = <<<EOT |
38 | | -<script type="$wgJsMimeType"> |
39 | | -var wgFeedbackParams = $fTags; |
40 | | -var wgAjaxFeedback = $ajaxFeedback |
41 | | -</script> |
42 | | -<script type="$wgJsMimeType" src="$encJsFile"></script> |
43 | | - |
44 | | -EOT; |
45 | | - $wgOut->addHeadItem( 'ReaderFeedback', $head ); |
46 | 43 | return true; |
47 | 44 | } |
48 | 45 | |
Index: trunk/extensions/ReaderFeedback/ReaderFeedback.class.php |
— | — | @@ -265,7 +265,7 @@ |
266 | 266 | # Param to pass to JS function to know if tags are at quality level |
267 | 267 | global $wgFeedbackTags; |
268 | 268 | $params = array( 'tags' => (object)$wgFeedbackTags ); |
269 | | - return Xml::encodeJsVar( (object)$params ); |
| 269 | + return (object)$params; |
270 | 270 | } |
271 | 271 | |
272 | 272 | } |
Index: trunk/extensions/ReaderFeedback/ReaderFeedback.php |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | |
112 | 112 | # Add CSS/JS as needed |
113 | 113 | $wgHooks['BeforePageDisplay'][] = 'ReaderFeedbackHooks::injectStyleAndJS'; |
| 114 | +$wgHooks['MakeGlobalVariablesScript'][] = 'ReaderFeedbackHooks::injectJSVars'; |
114 | 115 | |
115 | 116 | # Duplicate flagged* tables in parserTests.php |
116 | 117 | $wgHooks['ParserTestTables'][] = 'ReaderFeedbackHooks::onParserTestTables'; |