http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72792

Revision: 72792
Author:   nikerabbit
Date:     2010-09-11 09:59:41 +0000 (Sat, 11 Sep 2010)

Log Message:
-----------
Testing resource loader use in extension

Modified Paths:
--------------
    trunk/extensions/Translate/Translate.php
    trunk/extensions/Translate/TranslateUtils.php

Modified: trunk/extensions/Translate/Translate.php
===================================================================
--- trunk/extensions/Translate/Translate.php    2010-09-11 09:49:57 UTC (rev 
72791)
+++ trunk/extensions/Translate/Translate.php    2010-09-11 09:59:41 UTC (rev 
72792)
@@ -405,6 +405,12 @@
 
 # Startup code
 
+if ( class_exists( 'ResourceLoader' ) ) {
+       ResourceLoader::register( array( 'translate-css' =>
+               new ResourceLoaderFileModule( array( 'styles' => 
'extensions/Translate/Translate.css' ) )
+       ) );
+}
+
 function efTranslateNamespaces( &$list ) {
        global $wgPageTranslationNamespace;
        if ( !defined( 'NS_TRANSLATIONS' ) ) {

Modified: trunk/extensions/Translate/TranslateUtils.php
===================================================================
--- trunk/extensions/Translate/TranslateUtils.php       2010-09-11 09:49:57 UTC 
(rev 72791)
+++ trunk/extensions/Translate/TranslateUtils.php       2010-09-11 09:59:41 UTC 
(rev 72792)
@@ -359,16 +359,20 @@
         * Injects extension css (only once).
         */
        public static function injectCSS() {
+               global $wgOut;
+
+               if ( class_exists( 'ResourceLoader' ) ) {
+                       $wgOut->addModuleStyles( 'translate-css' );
+                       return true;
+               }
+
                static $done = false;
 
-               if ( $done ) {
-                       return;
+               if ( !$done ) {
+                       $wgOut->addExtensionStyle( self::assetPath( 
'Translate.css' ) );
                }
 
-               $done = true;
-
-               global $wgOut;
-               $wgOut->addExtensionStyle( self::assetPath( 'Translate.css' ) );
+               return $done = true;
        }
 
        /**



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to