r71637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71636‎ | r71637 | r71638 >
Date:18:01, 25 August 2010
Author:tparscal
Status:ok
Tags:
Comment:
Added skinScripts
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php
@@ -27,6 +27,7 @@
2828 private $dependencies = array();
2929 private $debugScripts = array();
3030 private $languageScripts = array();
 31+ private $skinScripts = array();
3132 private $skinStyles = array();
3233 private $loaders = array();
3334 private $parameters = array();
@@ -48,6 +49,7 @@
4950 * '[lang name]' => 'dir/lang.js' | '[lang name]' => array( 'dir/lang1.js', 'dir/lang2.js' ... )
5051 * ...
5152 * ),
 53+ * 'skinScripts' => 'dir/skin.js' | array( 'dir/skin1.js', 'dir/skin2.js' ... ),
5254 * 'debugScripts' => 'dir/debug.js' | array( 'dir/debug1.js', 'dir/debug2.js' ... ),
5355 *
5456 * // Non-raw module options
@@ -55,7 +57,7 @@
5658 * 'loaderScripts' => 'dir/loader.js' | array( 'dir/loader1.js', 'dir/loader2.js' ... ),
5759 * 'styles' => 'dir/file.css' | array( 'dir/file1.css', 'dir/file2.css' ... ),
5860 * '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' ... )
6062 * ...
6163 * ),
6264 * 'messages' => array( 'message1', 'message2' ... ),
@@ -82,6 +84,9 @@
8385 case 'languageScripts':
8486 $this->languageScripts = (array)$value;
8587 break;
 88+ case 'skinScripts':
 89+ $this->skinScripts = (array)$value;
 90+ break;
8691 case 'skinStyles':
8792 $this->skinStyles = (array)$value;
8893 break;
@@ -156,6 +161,19 @@
157162 array( $lang => $scripts )
158163 );
159164 }
 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+ }
160178
161179 /**
162180 * Add skin-specific CSS. These CSS files are only included for a
@@ -256,6 +274,21 @@
257275 }
258276
259277 /**
 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+ /**
260293 * Get the skin-specific CSS for a given skin. This is pulled from the
261294 * skin-specific CSS files added through addSkinStyles()
262295 * @return string CSS
@@ -314,6 +347,7 @@
315348 public function getDependencies() { return array(); }
316349 public function getDebugScript() { return ''; }
317350 public function getLanguageScript( $lang ) { return ''; }
 351+ public function getSkinScript( $skin ) { return ''; }
318352 public function getSkinStyle( $skin ) { return ''; }
319353 public function getLoaderScript() { return false; }
320354 }

Status & tagging log