r72792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72791‎ | r72792 | r72793 >
Date:09:59, 11 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Testing resource loader use in extension
Modified paths:
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -405,6 +405,12 @@
406406
407407 # Startup code
408408
 409+if ( class_exists( 'ResourceLoader' ) ) {
 410+ ResourceLoader::register( array( 'translate-css' =>
 411+ new ResourceLoaderFileModule( array( 'styles' => 'extensions/Translate/Translate.css' ) )
 412+ ) );
 413+}
 414+
409415 function efTranslateNamespaces( &$list ) {
410416 global $wgPageTranslationNamespace;
411417 if ( !defined( 'NS_TRANSLATIONS' ) ) {
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -359,16 +359,20 @@
360360 * Injects extension css (only once).
361361 */
362362 public static function injectCSS() {
 363+ global $wgOut;
 364+
 365+ if ( class_exists( 'ResourceLoader' ) ) {
 366+ $wgOut->addModuleStyles( 'translate-css' );
 367+ return true;
 368+ }
 369+
363370 static $done = false;
364371
365 - if ( $done ) {
366 - return;
 372+ if ( !$done ) {
 373+ $wgOut->addExtensionStyle( self::assetPath( 'Translate.css' ) );
367374 }
368375
369 - $done = true;
370 -
371 - global $wgOut;
372 - $wgOut->addExtensionStyle( self::assetPath( 'Translate.css' ) );
 376+ return $done = true;
373377 }
374378
375379 /**

Status & tagging log