Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -168,6 +168,7 @@ |
169 | 169 | * 'skin' => [string: name of skin, optional, name of default skin by default], |
170 | 170 | * 'dir' => [string: 'ltr' or 'rtl', optional, direction of lang by default], |
171 | 171 | * 'debug' => [boolean: true to include debug-only scripts, optional, false by default], |
| 172 | + * 'only' => [string: 'scripts', 'styles' or 'messages', optional, if set only get part of the requested module] |
172 | 173 | * ) |
173 | 174 | */ |
174 | 175 | public static function respond( WebRequest $request, $server ) { |
— | — | @@ -178,6 +179,7 @@ |
179 | 180 | 'lang' => $request->getVal( 'lang', $wgLang->getCode() ), |
180 | 181 | 'skin' => $request->getVal( 'skin', $wgDefaultSkin ), |
181 | 182 | 'debug' => $request->getVal( 'debug' ), |
| 183 | + 'only' => $request->getVal( 'only' ), |
182 | 184 | ); |
183 | 185 | // Mediawiki's WebRequest::getBool is a bit on the annoying side - we need to allow 'true' and 'false' values |
184 | 186 | // to be converted to boolean true and false |
— | — | @@ -207,18 +209,6 @@ |
208 | 210 | } |
209 | 211 | // Use output buffering |
210 | 212 | ob_start(); |
211 | | - // Output raw modules first and build a list of raw modules to be registered with ready status later on |
212 | | - $ready = array(); |
213 | | - foreach ( $modules as $name ) { |
214 | | - $module = self::getModule( $name ); |
215 | | - if ( $module->isRaw() ) { |
216 | | - echo $module->getScript(); |
217 | | - if ( $parameters['debug'] ) { |
218 | | - echo $module->getDebugScript(); |
219 | | - } |
220 | | - $ready[] = $name; |
221 | | - } |
222 | | - } |
223 | 213 | // Special meta-information for the 'mediawiki' module |
224 | 214 | if ( in_array( 'mediawiki', $modules ) ) { |
225 | 215 | $config = array( 'server' => $server, 'debug', 'debug' => $parameters['debug'] ); |
— | — | @@ -231,14 +221,11 @@ |
232 | 222 | if ( $loader !== false ) { |
233 | 223 | echo $loader; |
234 | 224 | } else { |
235 | | - if ( !count( $module->getDependencies() ) && |
236 | | - !in_array( $name, $ready ) && !in_array( $name, $missing ) ) { |
| 225 | + if ( !count( $module->getDependencies() ) && !in_array( $name, $missing ) ) { |
237 | 226 | $registrations[$name] = $name; |
238 | 227 | } else { |
239 | 228 | $registrations[$name] = array( $name, $module->getDependencies() ); |
240 | | - if ( in_array( $name, $ready ) ) { |
241 | | - $registrations[$name][] = 'ready'; |
242 | | - } else if ( in_array( $name, $missing ) ) { |
| 229 | + if ( in_array( $name, $missing ) ) { |
243 | 230 | $registrations[$name][] = 'missing'; |
244 | 231 | } |
245 | 232 | } |
— | — | @@ -251,34 +238,32 @@ |
252 | 239 | $blobs = MessageBlobStore::get( $modules, $parameters['lang'] ); |
253 | 240 | foreach ( $modules as $name ) { |
254 | 241 | $module = self::getModule( $name ); |
255 | | - if ( !$module->isRaw() ) { |
256 | | - // Script |
257 | | - $script = $module->getScript(); |
258 | | - // Debug |
259 | | - if ( $parameters['debug'] ) { |
260 | | - $script .= $module->getDebugScript(); |
| 242 | + // Script |
| 243 | + $script = $module->getScript(); |
| 244 | + // Debug |
| 245 | + if ( $parameters['debug'] ) { |
| 246 | + $script .= $module->getDebugScript(); |
| 247 | + } |
| 248 | + // Language-specific scripts |
| 249 | + $script .= $module->getLanguageScript( $parameters['lang'] ); |
| 250 | + // Style |
| 251 | + $style = $module->getStyle(); |
| 252 | + // Skin-specific styles |
| 253 | + $style .= $module->getSkinStyle( $parameters['skin'] ); |
| 254 | + |
| 255 | + if ( $style !== '' ) { |
| 256 | + if ( $parameters['dir'] == 'rtl' ) { |
| 257 | + $style = self::filter( 'flip-css', $style ); |
261 | 258 | } |
262 | | - // Language-specific scripts |
263 | | - $script .= $module->getLanguageScript( $parameters['lang'] ); |
264 | | - // Style |
265 | | - $style = $module->getStyle(); |
266 | | - // Skin-specific styles |
267 | | - $style .= $module->getSkinStyle( $parameters['skin'] ); |
268 | | - |
269 | | - if ( $style !== '' ) { |
270 | | - if ( $parameters['dir'] == 'rtl' ) { |
271 | | - $style = self::filter( 'flip-css', $style ); |
272 | | - } |
273 | | - $style = Xml::escapeJsString( |
274 | | - $parameters['debug'] ? |
275 | | - $style : self::filter( 'minify-css', $style ) |
276 | | - ); |
277 | | - } |
278 | | - // Messages |
279 | | - $messages = isset( $blobs[$name] ) ? $blobs[$name] : '{}'; |
280 | | - // Output |
281 | | - echo "mediaWiki.loader.implement( '{$name}', function() {\n{$script}\n}, '{$style}', {$messages} );\n"; |
| 259 | + $style = Xml::escapeJsString( |
| 260 | + $parameters['debug'] ? |
| 261 | + $style : self::filter( 'minify-css', $style ) |
| 262 | + ); |
282 | 263 | } |
| 264 | + // Messages |
| 265 | + $messages = isset( $blobs[$name] ) ? $blobs[$name] : '{}'; |
| 266 | + // Output |
| 267 | + echo "mediaWiki.loader.implement( '{$name}', function() {\n{$script}\n}, '{$style}', {$messages} );\n"; |
283 | 268 | } |
284 | 269 | // Set headers -- when we support CSS only mode, this might change! |
285 | 270 | header( 'Content-Type: text/javascript' ); |