Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -216,20 +216,48 @@ |
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
| 220 | + * Get all JS for this module for a given language and skin. This |
| 221 | + * aggregates the output of getPrimaryScript(), getLanguageScript(), |
| 222 | + * getSkinScript() and getDebugScript() (but NOT getLoaderScript() !) |
| 223 | + * @param $lang string Language code |
| 224 | + * @param $skin string Skin name |
| 225 | + * @param $debug bool Whether to include debug scripts |
| 226 | + * @return string JS |
| 227 | + */ |
| 228 | + public function getScript( $lang, $skin, $debug ) { |
| 229 | + $retval = $this->getPrimaryScript() . "\n" . |
| 230 | + $this->getLanguageScript( $lang ) . "\n" . |
| 231 | + $this->getSkinScript( $skin ); |
| 232 | + if ( $debug ) { |
| 233 | + $retval .= $this->getDebugScript(); |
| 234 | + } |
| 235 | + return $retval; |
| 236 | + } |
| 237 | + |
| 238 | + /** |
| 239 | + * Get all CSS for this module for a given skin. This |
| 240 | + * aggregates the output of getPrimaryStyle() and getSkinStyle() |
| 241 | + * @param $skin string Skin name |
| 242 | + */ |
| 243 | + public function getStyle( $skin ) { |
| 244 | + return $this->getPrimaryStyle() . $this->getSkinStyle( $skin ); |
| 245 | + } |
| 246 | + |
| 247 | + /** |
220 | 248 | * Get the primary JS for this module. This is pulled from the |
221 | 249 | * script files added through addScripts() |
222 | 250 | * @return string JS |
223 | 251 | */ |
224 | | - public function getScript() { |
| 252 | + protected function getPrimaryScript() { |
225 | 253 | return self::concatScripts( $this->scripts ); |
226 | 254 | } |
227 | 255 | |
228 | 256 | /** |
229 | | - * Get the CSS for this module. This is pulled from the CSS files |
230 | | - * added through addStyles() |
| 257 | + * Get the primary CSS for this module. This is pulled from the CSS |
| 258 | + * files added through addStyles() |
231 | 259 | * @return string JS |
232 | 260 | */ |
233 | | - public function getStyle() { |
| 261 | + protected function getPrimaryStyle() { |
234 | 262 | return self::concatStyles( $this->styles ); |
235 | 263 | } |
236 | 264 | |
— | — | @@ -256,7 +284,7 @@ |
257 | 285 | * files added through addDebugScripts() |
258 | 286 | * @return string JS |
259 | 287 | */ |
260 | | - public function getDebugScript() { |
| 288 | + protected function getDebugScript() { |
261 | 289 | return self::concatScripts( $this->debugScripts ); |
262 | 290 | } |
263 | 291 | |
— | — | @@ -265,7 +293,7 @@ |
266 | 294 | * from the language-specific script files added through addLanguageScripts() |
267 | 295 | * @return string JS |
268 | 296 | */ |
269 | | - public function getLanguageScript( $lang ) { |
| 297 | + protected function getLanguageScript( $lang ) { |
270 | 298 | if ( !isset( $this->languageScripts[$lang] ) ) { |
271 | 299 | return ''; |
272 | 300 | } |
— | — | @@ -277,7 +305,7 @@ |
278 | 306 | * skin-specific JS files added through addSkinScripts() |
279 | 307 | * @return string JS |
280 | 308 | */ |
281 | | - public function getSkinScript( $skin ) { |
| 309 | + protected function getSkinScript( $skin ) { |
282 | 310 | return self::concatScripts( self::getSkinFiles( $skin, $this->skinScripts ) ); |
283 | 311 | } |
284 | 312 | |
— | — | @@ -286,7 +314,7 @@ |
287 | 315 | * skin-specific CSS files added through addSkinStyles() |
288 | 316 | * @return string CSS |
289 | 317 | */ |
290 | | - public function getSkinStyle( $skin ) { |
| 318 | + protected function getSkinStyle( $skin ) { |
291 | 319 | return self::concatStyles( self::getSkinFiles( $skin, $this->skinStyles ) ); |
292 | 320 | } |
293 | 321 | |
— | — | @@ -393,7 +421,7 @@ |
394 | 422 | * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js |
395 | 423 | */ |
396 | 424 | class ResourceLoaderSiteJSModule extends ResourceLoaderModule { |
397 | | - public function getSkinScript( $skin ) { |
| 425 | + protected function getSkinScript( $skin ) { |
398 | 426 | return Skin::newFromKey( $skin )->generateUserJs(); |
399 | 427 | } |
400 | 428 | |
— | — | @@ -421,12 +449,12 @@ |
422 | 450 | |
423 | 451 | // Dummy overrides to return emptyness |
424 | 452 | // FIXME: Use a parent class with emptyness and let the normal module class inherit from that |
425 | | - public function getScript() { return ''; } |
426 | | - public function getStyle() { return ''; } |
| 453 | + protected function getPrimaryScript() { return ''; } |
| 454 | + protected function getPrimaryStyle() { return ''; } |
427 | 455 | public function getMessages() { return array(); } |
428 | 456 | public function getDependencies() { return array(); } |
429 | | - public function getDebugScript() { return ''; } |
430 | | - public function getLanguageScript( $lang ) { return ''; } |
431 | | - public function getSkinStyle( $skin ) { return ''; } |
| 457 | + protected function getDebugScript() { return ''; } |
| 458 | + protected function getLanguageScript( $lang ) { return ''; } |
| 459 | + protected function getSkinStyle( $skin ) { return ''; } |
432 | 460 | public function getLoaderScript() { return false; } |
433 | 461 | } |