Merge "Add support for mulitpart mime email to email sending code"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderFileModule.php
index aa177f8..fa84843 100644 (file)
@@ -113,6 +113,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
        protected $debugRaw = true;
        /** Boolean: Whether mw.loader.state() call should be omitted */
        protected $raw = false;
+       protected $targets = array( 'desktop' );
+
        /**
         * Array: Cache for mtime
         * @par Usage:
@@ -168,7 +170,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *         // Scripts to include in the startup module
         *         'loaderScripts' => [file path string or array of file path strings],
         *         // Modules which must be loaded before this module
-        *         'dependencies' => [modile name string or array of module name strings],
+        *         'dependencies' => [module name string or array of module name strings],
         *         // Styles to always load
         *         'styles' => [file path string or array of file path strings],
         *         // Styles to include in specific skin contexts
@@ -232,6 +234,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                // Lists of strings
                                case 'dependencies':
                                case 'messages':
+                               case 'targets':
                                        $this->{$member} = (array) $option;
                                        break;
                                // Single strings
@@ -529,7 +532,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                if ( $context->getDebug() ) {
                        $files = array_merge( $files, $this->debugScripts );
                }
-               return $files;
+
+               return array_unique( $files );
        }
 
        /**
@@ -645,23 +649,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                );
        }
 
-       /**
-        * Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist
-        * but returns 1 instead.
-        * @param $filename string File name
-        * @return int UNIX timestamp, or 1 if the file doesn't exist
-        */
-       protected static function safeFilemtime( $filename ) {
-               if ( file_exists( $filename ) ) {
-                       return filemtime( $filename );
-               } else {
-                       // We only ever map this function on an array if we're gonna call max() after,
-                       // so return our standard minimum timestamps here. This is 1, not 0, because
-                       // wfTimestamp(0) == NOW
-                       return 1;
-               }
-       }
-
        /**
         * Get whether CSS for this module should be flipped
         * @param $context ResourceLoaderContext
@@ -670,4 +657,14 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
        public function getFlip( $context ) {
                return $context->getDirection() === 'rtl';
        }
+
+       /**
+        * Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']
+        *
+        * @return array of strings
+        */
+       public function getTargets() {
+               return $this->targets;
+       }
+
 }