Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -15,7 +15,8 @@ |
16 | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | * http://www.gnu.org/copyleft/gpl.html |
18 | 18 | * |
19 | | - * @author Roan Kattouw, Trevor Parscal |
| 19 | + * @author Roan Kattouw |
| 20 | + * @author Trevor Parscal |
20 | 21 | */ |
21 | 22 | |
22 | 23 | /* |
— | — | @@ -113,10 +114,10 @@ |
114 | 115 | $missing = array_diff( $modules, array_keys( $blobs ) ); |
115 | 116 | foreach ( $missing as $module ) { |
116 | 117 | // Build message blob for module messages |
117 | | - $messages = isset( static::$modules[$module]['messages'] ) ? |
118 | | - array_keys( static::$modules[$module]['messages'] ) : false; |
| 118 | + $messages = isset( self::$modules[$module]['messages'] ) ? |
| 119 | + array_keys( self::$modules[$module]['messages'] ) : false; |
119 | 120 | if ( $messages ) { |
120 | | - foreach ( ResourceLoader::$modules[$module]['messages'] as $key ) { |
| 121 | + foreach ( self::$modules[$module]['messages'] as $key ) { |
121 | 122 | $messages[$encKey] = wfMsgExt( $key, array( 'language' => $lang ) ); |
122 | 123 | } |
123 | 124 | $blob = json_encode( $messages ); |
— | — | @@ -166,14 +167,14 @@ |
167 | 168 | if ( is_array( $module ) && empty( $options ) ) { |
168 | 169 | $success = true; |
169 | 170 | foreach ( $module as $name => $options ) { |
170 | | - if ( !static::register( $name, $options ) ) { |
| 171 | + if ( !self::register( $name, $options ) ) { |
171 | 172 | $success = false; |
172 | 173 | } |
173 | 174 | } |
174 | 175 | return $success; |
175 | 176 | } |
176 | 177 | // Disallow duplicate registrations |
177 | | - if ( isset( static::$modules[$module] ) ) { |
| 178 | + if ( isset( self::$modules[$module] ) ) { |
178 | 179 | // A module has already been registered by this name |
179 | 180 | return false; |
180 | 181 | } |
— | — | @@ -203,13 +204,12 @@ |
204 | 205 | // Style file does not exist |
205 | 206 | return false; |
206 | 207 | } |
207 | | - static::$modules[$module] = $options; |
| 208 | + self::$modules[$module] = $options; |
208 | 209 | } |
209 | 210 | /* |
210 | 211 | * Outputs a response to a resource load-request, including a content-type header |
211 | 212 | * |
212 | | - * @param array $modules module names to include in the request |
213 | | - * @param array $options options which affect the content of the response (optional) |
| 213 | + * @param WebRequest $request web request object to respond to |
214 | 214 | * |
215 | 215 | * $options format: |
216 | 216 | * array( |
— | — | @@ -223,12 +223,12 @@ |
224 | 224 | public static function respond( WebRequest $request ) { |
225 | 225 | global $wgUser, $wgLang, $wgDefaultSkin; |
226 | 226 | // Fallback on system settings |
227 | | - $parameters = array_merge( array( |
| 227 | + $parameters = array( |
228 | 228 | 'user' => $request->getBool( 'user', $wgUser->isLoggedIn() ), |
229 | 229 | 'lang' => $request->getVal( 'lang', $wgLang->getCode() ), |
230 | 230 | 'skin' => $request->getVal( 'skin', $wgDefaultSkin ), |
231 | 231 | 'debug' => $request->getBool( 'debug' ), |
232 | | - ) ); |
| 232 | + ); |
233 | 233 | // Get the direction from the requested language |
234 | 234 | if ( !isset( $parameters['dir'] ) ) { |
235 | 235 | $lang = $wgLang->factory( $parameters['lang'] ); |
— | — | @@ -237,12 +237,8 @@ |
238 | 238 | // Get modules - filtering out any we don't know about |
239 | 239 | $modules = array(); |
240 | 240 | foreach ( explode( '|', $request->getVal( 'modules' ) ) as $module ) { |
241 | | - if ( isset( static::$modules[$module] ) ) { |
242 | | - if ( static::$modules[$module]['debug'] ) { |
243 | | - if ( $parameters['debug'] ) { |
244 | | - $modules[] = $module; |
245 | | - } |
246 | | - } else { |
| 241 | + if ( isset( self::$modules[$module] ) ) { |
| 242 | + if ( !self::$modules[$module]['debug'] || $parameters['debug'] ) { |
247 | 243 | $modules[] = $module; |
248 | 244 | } |
249 | 245 | } |
— | — | @@ -251,8 +247,8 @@ |
252 | 248 | ob_start(); |
253 | 249 | // Output raw modules first |
254 | 250 | foreach ( $modules as $module ) { |
255 | | - if ( static::$modules[$module]['raw'] ) { |
256 | | - readfile( static::$modules[$module]['script'] ); |
| 251 | + if ( self::$modules[$module]['raw'] ) { |
| 252 | + readfile( self::$modules[$module]['script'] ); |
257 | 253 | echo "\n"; |
258 | 254 | } |
259 | 255 | } |
— | — | @@ -285,22 +281,23 @@ |
286 | 282 | */ |
287 | 283 | } |
288 | 284 | // Output non-raw modules |
289 | | - $blobs = static::messages( $parameters['lang'], $modules ); |
| 285 | + $blobs = self::messages( $parameters['lang'], $modules ); |
290 | 286 | foreach ( $modules as $module ) { |
291 | | - if ( !static::$modules[$module]['raw'] ) { |
| 287 | + if ( !self::$modules[$module]['raw'] ) { |
292 | 288 | // Script |
293 | | - $script = file_get_contents( static::$modules[$module]['script'] ); |
| 289 | + $script = file_get_contents( self::$modules[$module]['script'] ); |
294 | 290 | if ( !$parameters['debug'] ) { |
295 | | - $script = static::filter( 'strip-debug', $script ); |
| 291 | + $script = self::filter( 'strip-debug', $script ); |
296 | 292 | } |
297 | 293 | // Style |
298 | | - $style = static::$modules[$module]['style'] ? file_get_contents( static::$modules[$module]['style'] ) : ''; |
| 294 | + $style = self::$modules[$module]['style'] ? file_get_contents( self::$modules[$module]['style'] ) : ''; |
299 | 295 | if ( $style !== '' ) { |
300 | 296 | if ( $parameters['dir'] == 'rtl' ) { |
301 | | - $style = static::filter( 'flip-css', $style ); |
| 297 | + $style = self::filter( 'flip-css', $style ); |
302 | 298 | } |
303 | 299 | $style = Xml::escapeJsString( |
304 | | - static::filter( 'minify-css', $style, static::$modules[$module]['style'] ) |
| 300 | + $parameters['debug'] ? |
| 301 | + $style : self::filter( 'minify-css', $style, self::$modules[$module]['style'] ) |
305 | 302 | ); |
306 | 303 | } |
307 | 304 | // Messages |
— | — | @@ -315,7 +312,7 @@ |
316 | 313 | if ( $parameters['debug'] ) { |
317 | 314 | ob_end_flush(); |
318 | 315 | } else { |
319 | | - echo static::filter( 'minify-js', ob_get_clean() ); |
| 316 | + echo self::filter( 'minify-js', ob_get_clean() ); |
320 | 317 | } |
321 | 318 | } |
322 | 319 | } |
\ No newline at end of file |
Index: branches/resourceloader/phase3/load.php |
— | — | @@ -15,7 +15,8 @@ |
16 | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 | * http://www.gnu.org/copyleft/gpl.html |
18 | 18 | * |
19 | | - * @author Roan Kattouw, Trevor Parscal |
| 19 | + * @author Roan Kattouw |
| 20 | + * @author Trevor Parscal |
20 | 21 | * |
21 | 22 | */ |
22 | 23 | |