r71980 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71979‎ | r71980 | r71981 >
Date:21:10, 30 August 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Have getScript() and getStyle() return all scripts / styles instead of just the primary ones. Moved old functionality of getScript() / getStyle() to getPrimaryScript() / getPrimaryStyle()
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php
@@ -216,20 +216,48 @@
217217 }
218218
219219 /**
 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+ /**
220248 * Get the primary JS for this module. This is pulled from the
221249 * script files added through addScripts()
222250 * @return string JS
223251 */
224 - public function getScript() {
 252+ protected function getPrimaryScript() {
225253 return self::concatScripts( $this->scripts );
226254 }
227255
228256 /**
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()
231259 * @return string JS
232260 */
233 - public function getStyle() {
 261+ protected function getPrimaryStyle() {
234262 return self::concatStyles( $this->styles );
235263 }
236264
@@ -256,7 +284,7 @@
257285 * files added through addDebugScripts()
258286 * @return string JS
259287 */
260 - public function getDebugScript() {
 288+ protected function getDebugScript() {
261289 return self::concatScripts( $this->debugScripts );
262290 }
263291
@@ -265,7 +293,7 @@
266294 * from the language-specific script files added through addLanguageScripts()
267295 * @return string JS
268296 */
269 - public function getLanguageScript( $lang ) {
 297+ protected function getLanguageScript( $lang ) {
270298 if ( !isset( $this->languageScripts[$lang] ) ) {
271299 return '';
272300 }
@@ -277,7 +305,7 @@
278306 * skin-specific JS files added through addSkinScripts()
279307 * @return string JS
280308 */
281 - public function getSkinScript( $skin ) {
 309+ protected function getSkinScript( $skin ) {
282310 return self::concatScripts( self::getSkinFiles( $skin, $this->skinScripts ) );
283311 }
284312
@@ -286,7 +314,7 @@
287315 * skin-specific CSS files added through addSkinStyles()
288316 * @return string CSS
289317 */
290 - public function getSkinStyle( $skin ) {
 318+ protected function getSkinStyle( $skin ) {
291319 return self::concatStyles( self::getSkinFiles( $skin, $this->skinStyles ) );
292320 }
293321
@@ -393,7 +421,7 @@
394422 * Custom module for MediaWiki:Common.js and MediaWiki:Skinname.js
395423 */
396424 class ResourceLoaderSiteJSModule extends ResourceLoaderModule {
397 - public function getSkinScript( $skin ) {
 425+ protected function getSkinScript( $skin ) {
398426 return Skin::newFromKey( $skin )->generateUserJs();
399427 }
400428
@@ -421,12 +449,12 @@
422450
423451 // Dummy overrides to return emptyness
424452 // 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 ''; }
427455 public function getMessages() { return array(); }
428456 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 ''; }
432460 public function getLoaderScript() { return false; }
433461 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r72006resourceloader: Followup to r71980: fix calls in ResourceLoader referring to ...catrope02:20, 31 August 2010

Status & tagging log