From d19811e469bfa0b4f6347129cc0dd8f7f562ff64 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Thu, 7 Oct 2010 23:31:30 +0000 Subject: [PATCH] * ResourceLoaderModule.php - added basePath argument to ResourceLoaderFileModule::__construct to help make module definitions be less repeditive. * Vector.hooks.php, WikiEditor.hooks.php - implemented new basePath argument for ResourceLoaderFileModule::__construct --- includes/ResourceLoaderModule.php | 51 +++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/includes/ResourceLoaderModule.php b/includes/ResourceLoaderModule.php index 83cafc8a01..02de115744 100644 --- a/includes/ResourceLoaderModule.php +++ b/includes/ResourceLoaderModule.php @@ -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. -- 2.20.1