* ResourceLoaderModule.php - added basePath argument to ResourceLoaderFileModule...
authorTrevor Parscal <tparscal@users.mediawiki.org>
Thu, 7 Oct 2010 23:31:30 +0000 (23:31 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Thu, 7 Oct 2010 23:31:30 +0000 (23:31 +0000)
* Vector.hooks.php, WikiEditor.hooks.php - implemented new basePath argument for ResourceLoaderFileModule::__construct

includes/ResourceLoaderModule.php

index 83cafc8..02de115 100644 (file)
@@ -280,43 +280,48 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *              'group' => 'stuff',
         *      )
         */
-       public function __construct( $options = array() ) {
+       public function __construct( $options = array(), $basePath = null ) {
                foreach ( $options as $option => $value ) {
                        switch ( $option ) {
                                case 'scripts':
-                                       $this->scripts = (array)$value;
+                               case 'debugScripts':
+                               case 'languageScripts':
+                               case 'skinScripts':
+                               case 'loaders':
+                                       $this->{$option} = (array)$value;
+                                       // Automatically prefix script paths
+                                       if ( is_string( $basePath ) ) {
+                                               foreach ( $this->{$option} as $key => $value ) {
+                                                       $this->{$option}[$key] = $basePath . $value;
+                                               }
+                                       }
                                        break;
                                case 'styles':
-                                       $this->styles = (array)$value;
+                               case 'skinStyles':
+                                       $this->{$option} = (array)$value;
+                                       // Automatically prefix style paths
+                                       if ( is_string( $basePath ) ) {
+                                               foreach ( $this->{$option} as $key => $value ) {
+                                                       if ( is_array( $value ) ) {
+                                                               $this->{$option}[$basePath . $key] = $value;
+                                                               unset( $this->{$option}[$key] );
+                                                       } else {
+                                                               $this->{$option}[$key] = $basePath . $value;
+                                                       }
+                                               }
+                                       }
                                        break;
+                               case 'dependencies':
                                case 'messages':
-                                       $this->messages = (array)$value;
+                                       $this->{$option} = (array)$value;
                                        break;
                                case 'group':
                                        $this->group = (string)$value;
                                        break;
-                               case 'dependencies':
-                                       $this->dependencies = (array)$value;
-                                       break;
-                               case 'debugScripts':
-                                       $this->debugScripts = (array)$value;
-                                       break;
-                               case 'languageScripts':
-                                       $this->languageScripts = (array)$value;
-                                       break;
-                               case 'skinScripts':
-                                       $this->skinScripts = (array)$value;
-                                       break;
-                               case 'skinStyles':
-                                       $this->skinStyles = (array)$value;
-                                       break;
-                               case 'loaders':
-                                       $this->loaders = (array)$value;
-                                       break;
                        }
                }
        }
-
+       
        /**
         * Add script files to this module. In order to be valid, a module
         * must contain at least one script file.