Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | private $dependencies = array(); |
29 | 29 | private $debugScripts = array(); |
30 | 30 | private $languageScripts = array(); |
| 31 | + private $skinScripts = array(); |
31 | 32 | private $skinStyles = array(); |
32 | 33 | private $loaders = array(); |
33 | 34 | private $parameters = array(); |
— | — | @@ -48,6 +49,7 @@ |
49 | 50 | * '[lang name]' => 'dir/lang.js' | '[lang name]' => array( 'dir/lang1.js', 'dir/lang2.js' ... ) |
50 | 51 | * ... |
51 | 52 | * ), |
| 53 | + * 'skinScripts' => 'dir/skin.js' | array( 'dir/skin1.js', 'dir/skin2.js' ... ), |
52 | 54 | * 'debugScripts' => 'dir/debug.js' | array( 'dir/debug1.js', 'dir/debug2.js' ... ), |
53 | 55 | * |
54 | 56 | * // Non-raw module options |
— | — | @@ -55,7 +57,7 @@ |
56 | 58 | * 'loaderScripts' => 'dir/loader.js' | array( 'dir/loader1.js', 'dir/loader2.js' ... ), |
57 | 59 | * 'styles' => 'dir/file.css' | array( 'dir/file1.css', 'dir/file2.css' ... ), |
58 | 60 | * 'skinStyles' => array( |
59 | | - * '[skin name]' => 'dir/theme.css' | '[skin name]' => array( 'dir/theme1.css', 'dir/theme2.css' ... ) |
| 61 | + * '[skin name]' => 'dir/skin.css' | '[skin name]' => array( 'dir/skin1.css', 'dir/skin2.css' ... ) |
60 | 62 | * ... |
61 | 63 | * ), |
62 | 64 | * 'messages' => array( 'message1', 'message2' ... ), |
— | — | @@ -82,6 +84,9 @@ |
83 | 85 | case 'languageScripts': |
84 | 86 | $this->languageScripts = (array)$value; |
85 | 87 | break; |
| 88 | + case 'skinScripts': |
| 89 | + $this->skinScripts = (array)$value; |
| 90 | + break; |
86 | 91 | case 'skinStyles': |
87 | 92 | $this->skinStyles = (array)$value; |
88 | 93 | break; |
— | — | @@ -156,6 +161,19 @@ |
157 | 162 | array( $lang => $scripts ) |
158 | 163 | ); |
159 | 164 | } |
| 165 | + |
| 166 | + /** |
| 167 | + * Add skin-specific scripts. These scripts are only included for |
| 168 | + * a given skin. |
| 169 | + * @param $skin string Skin name, or 'default' |
| 170 | + * @param $scripts mixed Path to script file (string) or array of paths |
| 171 | + */ |
| 172 | + public function addSkinScripts( $skin, $scripts ) { |
| 173 | + $this->skinScripts = array_merge_recursive( |
| 174 | + $this->skinScripts, |
| 175 | + array( $skin => $scripts ) |
| 176 | + ); |
| 177 | + } |
160 | 178 | |
161 | 179 | /** |
162 | 180 | * Add skin-specific CSS. These CSS files are only included for a |
— | — | @@ -256,6 +274,21 @@ |
257 | 275 | } |
258 | 276 | |
259 | 277 | /** |
| 278 | + * Get the skin-specific JS for a given skin. This is pulled from the |
| 279 | + * skin-specific JS files added through addSkinScripts() |
| 280 | + * @return string JS |
| 281 | + */ |
| 282 | + public function getSkinScript( $skin ) { |
| 283 | + $scripts = array(); |
| 284 | + if ( isset( $this->skinScripts[$skin] ) && count( $this->skinScripts[$skin] ) ) { |
| 285 | + $scripts = $this->skinScripts[$skin]; |
| 286 | + } else if ( isset( $this->skinScripts['default'] ) ) { |
| 287 | + $scripts = $this->skinScripts['default']; |
| 288 | + } |
| 289 | + return self::concatFiles( $scripts ); |
| 290 | + } |
| 291 | + |
| 292 | + /** |
260 | 293 | * Get the skin-specific CSS for a given skin. This is pulled from the |
261 | 294 | * skin-specific CSS files added through addSkinStyles() |
262 | 295 | * @return string CSS |
— | — | @@ -314,6 +347,7 @@ |
315 | 348 | public function getDependencies() { return array(); } |
316 | 349 | public function getDebugScript() { return ''; } |
317 | 350 | public function getLanguageScript( $lang ) { return ''; } |
| 351 | + public function getSkinScript( $skin ) { return ''; } |
318 | 352 | public function getSkinStyle( $skin ) { return ''; } |
319 | 353 | public function getLoaderScript() { return false; } |
320 | 354 | } |