r71640 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71639‎ | r71640 | r71641 >
Date:18:10, 25 August 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Finish exterminating 'raw', add &only parameter (still unused, functionality on its way)
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -168,6 +168,7 @@
169169 * 'skin' => [string: name of skin, optional, name of default skin by default],
170170 * 'dir' => [string: 'ltr' or 'rtl', optional, direction of lang by default],
171171 * '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]
172173 * )
173174 */
174175 public static function respond( WebRequest $request, $server ) {
@@ -178,6 +179,7 @@
179180 'lang' => $request->getVal( 'lang', $wgLang->getCode() ),
180181 'skin' => $request->getVal( 'skin', $wgDefaultSkin ),
181182 'debug' => $request->getVal( 'debug' ),
 183+ 'only' => $request->getVal( 'only' ),
182184 );
183185 // Mediawiki's WebRequest::getBool is a bit on the annoying side - we need to allow 'true' and 'false' values
184186 // to be converted to boolean true and false
@@ -207,18 +209,6 @@
208210 }
209211 // Use output buffering
210212 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 - }
223213 // Special meta-information for the 'mediawiki' module
224214 if ( in_array( 'mediawiki', $modules ) ) {
225215 $config = array( 'server' => $server, 'debug', 'debug' => $parameters['debug'] );
@@ -231,14 +221,11 @@
232222 if ( $loader !== false ) {
233223 echo $loader;
234224 } else {
235 - if ( !count( $module->getDependencies() ) &&
236 - !in_array( $name, $ready ) && !in_array( $name, $missing ) ) {
 225+ if ( !count( $module->getDependencies() ) && !in_array( $name, $missing ) ) {
237226 $registrations[$name] = $name;
238227 } else {
239228 $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 ) ) {
243230 $registrations[$name][] = 'missing';
244231 }
245232 }
@@ -251,34 +238,32 @@
252239 $blobs = MessageBlobStore::get( $modules, $parameters['lang'] );
253240 foreach ( $modules as $name ) {
254241 $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 );
261258 }
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+ );
282263 }
 264+ // Messages
 265+ $messages = isset( $blobs[$name] ) ? $blobs[$name] : '{}';
 266+ // Output
 267+ echo "mediaWiki.loader.implement( '{$name}', function() {\n{$script}\n}, '{$style}', {$messages} );\n";
283268 }
284269 // Set headers -- when we support CSS only mode, this might change!
285270 header( 'Content-Type: text/javascript' );

Status & tagging log