r72064 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72063‎ | r72064 | r72065 >
Date:23:28, 31 August 2010
Author:catrope
Status:deferred
Tags:
Comment:
resourceloader: Put startup code in its own module
Modified paths:
  • /branches/resourceloader/phase3/includes/ResourceLoader.php (modified) (history)
  • /branches/resourceloader/phase3/includes/ResourceLoaderModule.php (modified) (history)
  • /branches/resourceloader/phase3/resources/Resources.php (modified) (history)

Diff [purge]

Index: branches/resourceloader/phase3/includes/ResourceLoader.php
@@ -117,14 +117,14 @@
118118 *
119119 * @return {string} JavaScript code for registereing all modules with client loader
120120 */
121 - protected static function getModuleRegistrations() {
 121+ public static function getModuleRegistrations() {
122122 $scripts = '';
123123 $registrations = array();
124124 foreach ( self::$modules as $name => $module ) {
125125 if ( !in_array( $name, self::$preRegisteredModules ) ) {
126126 // Support module loader scripts
127 - if ( $loader = $module->getLoaderScript() !== false ) {
128 - $scripts .= $loader;
 127+ if ( ( $loader = $module->getLoaderScript() ) !== false ) {
 128+ $scripts .= "\n" . $loader;
129129 }
130130 // Automatically register module
131131 else {
@@ -139,7 +139,8 @@
140140 }
141141 }
142142 }
143 - return $scripts . "\nmediaWiki.loader.register( " . FormatJSON::encode( $registrations ) . " );\n";
 143+ $scripts .= "\nmediaWiki.loader.register( " . FormatJson::encode( $registrations ) . " );\n";
 144+ return "window.mediaWikiStartUp = function() {" . $scripts . "};";
144145 }
145146
146147 /* Static Methods */
Index: branches/resourceloader/phase3/includes/ResourceLoaderModule.php
@@ -543,3 +543,20 @@
544544 public function getLoaderScript() { return ''; }
545545 public function getDependencies() { return array(); }
546546 }
 547+
 548+
 549+class ResourceLoaderStartupModule extends ResourceLoaderModule {
 550+ public function getScript( $lang, $skin, $debug ) {
 551+ return ResourceLoader::getModuleRegistrations();
 552+ }
 553+
 554+ public function getModifiedTime( $lang, $skin, $debug ) {
 555+ // FIXME
 556+ return wfTimestamp();
 557+ }
 558+
 559+ public function getStyle( $skin ) { return ''; }
 560+ public function getMessages() { return array(); }
 561+ public function getLoaderScript() { return ''; }
 562+ public function getDependencies() { return array(); }
 563+}
\ No newline at end of file
Index: branches/resourceloader/phase3/resources/Resources.php
@@ -5,6 +5,7 @@
66 /* Special resources who have their own classes */
77
88 'sitejs' => new ResourceLoaderSiteJSModule,
 9+ 'startup' => new ResourceLoaderStartupModule,
910
1011 /* Skins */
1112

Status & tagging log