Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1400,6 +1400,11 @@ |
1401 | 1401 | loader request or generating HTML output. |
1402 | 1402 | &$resourceLoader: ResourceLoader object |
1403 | 1403 | |
| 1404 | +'ResourceLoaderGetStartupModules': Run once the startup module is being generated. This allows you |
| 1405 | +to add modules to the startup module. This hook should be used sparingly since any module added here |
| 1406 | +will be loaded on all pages. This hook is useful if you want to make code available to module loader |
| 1407 | +scripts. |
| 1408 | + |
1404 | 1409 | 'RawPageViewBeforeOutput': Right before the text is blown out in action=raw |
1405 | 1410 | &$obj: RawPage object |
1406 | 1411 | &$text: The text that's going to be the output |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php |
— | — | @@ -159,17 +159,26 @@ |
160 | 160 | |
161 | 161 | $out = file_get_contents( "$IP/resources/startup.js" ); |
162 | 162 | if ( $context->getOnly() === 'scripts' ) { |
163 | | - // Build load query for jquery and mediawiki modules |
| 163 | + |
| 164 | + // The core modules: |
| 165 | + $modules = array( 'jquery', 'mediawiki' ); |
| 166 | + wfRunHooks( 'ResourceLoaderGetStartupModules', array( &$modules ) ); |
| 167 | + |
| 168 | + // Get the latest version |
| 169 | + $version = 0; |
| 170 | + foreach ( $modules as $moduleName ) { |
| 171 | + $version = max( $version, |
| 172 | + $context->getResourceLoader()->getModule( $moduleName )->getModifiedTime( $context ) |
| 173 | + ); |
| 174 | + } |
| 175 | + // Build load query for StartupModules |
164 | 176 | $query = array( |
165 | | - 'modules' => implode( '|', array( 'jquery', 'mediawiki' ) ), |
| 177 | + 'modules' => implode( '|', $modules ), |
166 | 178 | 'only' => 'scripts', |
167 | 179 | 'lang' => $context->getLanguage(), |
168 | 180 | 'skin' => $context->getSkin(), |
169 | 181 | 'debug' => $context->getDebug() ? 'true' : 'false', |
170 | | - 'version' => wfTimestamp( TS_ISO_8601_BASIC, max( |
171 | | - $context->getResourceLoader()->getModule( 'jquery' )->getModifiedTime( $context ), |
172 | | - $context->getResourceLoader()->getModule( 'mediawiki' )->getModifiedTime( $context ) |
173 | | - ) ) |
| 182 | + 'version' => wfTimestamp( TS_ISO_8601_BASIC, round( $version, -2 ) ) |
174 | 183 | ); |
175 | 184 | // Ensure uniform query order |
176 | 185 | ksort( $query ); |