/* Protected Static Methods */
+ /*
+ * Registers core modules and runs registration hooks
+ */
+ protected static function initialize() {
+ global $IP;
+
+ // Safety check - this should never be called more than once anyways
+ if ( self::$initialized ) {
+ wfDebug( 'ResourceLoader::intitialize was called more than once' );
+ return;
+ }
+
+ self::$initialized = true;
+ self::register( include( "$IP/resources/Resources.php" ) );
+ wfRunHooks( 'ResourceLoaderRegisterModules' );
+ }
+
/**
* Runs text through a filter, caching the filtered result for future calls
*
/* Static Methods */
- public static function initialize() {
- global $IP;
-
- if ( !self::$initialized ) {
- // Do this first just in case someone accidentally adds a call to ResourceLoader::initialize in their hook
- self::$initialized = true;
- self::register( include( "$IP/resources/Resources.php" ) );
- wfRunHooks( 'ResourceLoaderRegisterModules' );
- }
- }
-
/**
* Registers a module with the ResourceLoader system.
*
* the client in a way that they can easily see them if they want to, such as by using FireBug
*/
public static function register( $name, ResourceLoaderModule $object = null ) {
+
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
+
// Allow multiple modules to be registered in one call
if ( is_array( $name ) && !isset( $object ) ) {
foreach ( $name as $key => $value ) {
* @return Array: array( modulename => ResourceLoaderModule )
*/
public static function getModules() {
+
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
+
return self::$modules;
}
* @return mixed ResourceLoaderModule or null if not registered
*/
public static function getModule( $name ) {
+
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
+
return isset( self::$modules[$name] ) ? self::$modules[$name] : null;
}
* @return String: JavaScript code for registering all modules with the client loader
*/
public static function getModuleRegistrations( ResourceLoaderContext $context ) {
+
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
+
$scripts = '';
$registrations = array();
* @return Integer: UNIX timestamp
*/
public static function getHighestModifiedTime( ResourceLoaderContext $context ) {
+
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
+
$time = 1; // wfTimestamp() treats 0 as 'now', so that's not a suitable choice
foreach ( self::$modules as $module ) {
global $wgResourceLoaderVersionedClientMaxage, $wgResourceLoaderVersionedServerMaxage;
global $wgResourceLoaderUnversionedServerMaxage, $wgResourceLoaderUnversionedClientMaxage;
- // Register modules
- self::initialize();
+ if ( !self::$initialized ) {
+ self::initialize();
+ }
// Split requested modules into two groups, modules and missing
$modules = array();