r55728 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55727‎ | r55728 | r55729 >
Date:20:53, 1 September 2009
Author:nimishg
Status:deferred
Tags:
Comment:
Moved global variable printing to top of script printing
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -121,6 +121,22 @@
122122
123123 if ( !self::$doOutput )
124124 return true;
 125+ // Transforms variables into javascript global variables
 126+ foreach ( self::$variables as $key => $value ) {
 127+ $escapedVariableValue = Xml::escapeJsString( $value );
 128+ $escapedVariableKey = Xml::escapeJsString( $key );
 129+ self::$variables[$key] =
 130+ "var {$escapedVariableKey} = '{$escapedVariableValue}';";
 131+ }
 132+ if ( count( self::$variables ) > 0 ) {
 133+ $out->addScript(
 134+ Xml::tags(
 135+ 'script',
 136+ array( 'type' => $wgJsMimeType ),
 137+ implode( self::$variables )
 138+ )
 139+ );
 140+ }
125141
126142 // Loops over each script
127143 foreach ( self::$scripts as $script ) {
@@ -156,22 +172,6 @@
157173 )
158174 );
159175 }
160 - // Transforms variables into javascript global variables
161 - foreach ( self::$variables as $key => $value ) {
162 - $escapedVariableValue = Xml::escapeJsString( $value );
163 - $escapedVariableKey = Xml::escapeJsString( $key );
164 - self::$variables[$key] =
165 - "var {$escapedVariableKey} = '{$escapedVariableValue}';";
166 - }
167 - if ( count( self::$variables ) > 0 ) {
168 - $out->addScript(
169 - Xml::tags(
170 - 'script',
171 - array( 'type' => $wgJsMimeType ),
172 - implode( self::$variables )
173 - )
174 - );
175 - }
176176 // Loops over each style
177177 foreach ( self::$styles as $style ) {
178178 // Add css for various styles

Status & tagging log