$newSessionID: new session id
'ResourceLoaderGetConfigVars': Called at the end of
-ResourceLoaderStartUpModule::getConfig(). Use this to export static
+ResourceLoaderStartUpModule::getConfigSettings(). Use this to export static
configuration variables to JavaScript. Things that depend on the current page
or request state must be added through MakeGlobalVariablesScript instead.
&$vars: array( variable name => value )
/** @var array Associative array mapping module name to info associative array */
protected $moduleInfos = array();
+ /** @var Config $config */
+ private $config;
+
/**
* @var array Associative array mapping framework ids to a list of names of test suite modules
* like array( 'qunit' => array( 'mediawiki.tests.qunit.suites', 'ext.foo.tests', .. ), .. )
* @return string Filtered data, or a comment containing an error message
*/
public function filter( $filter, $data, $cacheReport = true ) {
- global $wgResourceLoaderMinifierStatementsOnOwnLine, $wgResourceLoaderMinifierMaxLineLength;
wfProfileIn( __METHOD__ );
// For empty/whitespace-only data or for unknown filters, don't perform
switch ( $filter ) {
case 'minify-js':
$result = JavaScriptMinifier::minify( $data,
- $wgResourceLoaderMinifierStatementsOnOwnLine,
- $wgResourceLoaderMinifierMaxLineLength
+ $this->config->get( 'ResourceLoaderMinifierStatementsOnOwnLine' ),
+ $this->config->get( 'ResourceLoaderMinifierMaxLineLength' )
);
if ( $cacheReport ) {
$result .= "\n/* cache key: $key */";
/**
* Register core modules and runs registration hooks.
*/
- public function __construct() {
- global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript, $wgEnableJavaScriptTest;
+ public function __construct( Config $config = null ) {
+ global $IP;
wfProfileIn( __METHOD__ );
+ if ( $config === null ) {
+ wfDebug( __METHOD__ . ' was called without providing a Config instance' );
+ $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ }
+
+ $this->config = $config;
+
// Add 'local' source first
$this->addSource(
'local',
- array( 'loadScript' => $wgLoadScript, 'apiScript' => wfScript( 'api' ) )
+ array( 'loadScript' => wfScript( 'load' ), 'apiScript' => wfScript( 'api' ) )
);
// Add other sources
- $this->addSource( $wgResourceLoaderSources );
+ $this->addSource( $config->get( 'ResourceLoaderSources' ) );
// Register core modules
$this->register( include "$IP/resources/Resources.php" );
// Register extension modules
wfRunHooks( 'ResourceLoaderRegisterModules', array( &$this ) );
- $this->register( $wgResourceModules );
+ $this->register( $config->get( 'ResourceModules' ) );
- if ( $wgEnableJavaScriptTest === true ) {
+ if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
$this->registerTestModules();
}
wfProfileOut( __METHOD__ );
}
+ /**
+ * @return Config
+ */
+ public function getConfig() {
+ return $this->config;
+ }
+
/**
* Register a module with the ResourceLoader system.
*
// Apply custom skin-defined styles to existing modules.
if ( $this->isFileModule( $name ) ) {
- global $wgResourceModuleSkinStyles;
- foreach ( $wgResourceModuleSkinStyles as $skinName => $skinStyles ) {
+ foreach ( $this->config->get( 'ResourceModuleSkinStyles' ) as $skinName => $skinStyles ) {
// If this module already defines skinStyles for this skin, ignore $wgResourceModuleSkinStyles.
if ( isset( $this->moduleInfos[$name]['skinStyles'][$skinName] ) ) {
continue;
/**
*/
public function registerTestModules() {
- global $IP, $wgEnableJavaScriptTest;
+ global $IP;
- if ( $wgEnableJavaScriptTest !== true ) {
+ if ( $this->config->get( 'EnableJavaScriptTest' ) !== true ) {
throw new MWException( 'Attempt to register JavaScript test modules '
. 'but <code>$wgEnableJavaScriptTest</code> is false. '
. 'Edit your <code>LocalSettings.php</code> to enable it.' );
} else {
$class = $info['class'];
}
+ /** @var ResourceLoaderModule $object */
$object = new $class( $info );
+ $object->setConfig( $this->getConfig() );
}
$object->setName( $name );
$this->modules[$name] = $object;
* @param ResourceLoaderContext $context Context in which a response should be formed
*/
public function respond( ResourceLoaderContext $context ) {
- global $wgCacheEpoch, $wgUseFileCache;
-
// Use file cache if enabled and available...
- if ( $wgUseFileCache ) {
+ if ( $this->config->get( 'UseFileCache' ) ) {
$fileCache = ResourceFileCache::newFromContext( $context );
if ( $this->tryRespondFromFileCache( $fileCache, $context ) ) {
return; // output handled
// To send Last-Modified and support If-Modified-Since, we need to detect
// the last modified time
- $mtime = wfTimestamp( TS_UNIX, $wgCacheEpoch );
+ $mtime = wfTimestamp( TS_UNIX, $this->config->get( 'CacheEpoch' ) );
foreach ( $modules as $module ) {
/**
* @var $module ResourceLoaderModule
* @return void
*/
protected function sendResponseHeaders( ResourceLoaderContext $context, $mtime, $errors ) {
- global $wgResourceLoaderMaxage;
+ $rlMaxage = $this->config->get( 'ResourceLoaderMaxage' );
// If a version wasn't specified we need a shorter expiry time for updates
// to propagate to clients quickly
// If there were errors, we also need a shorter expiry time so we can recover quickly
if ( is_null( $context->getVersion() ) || $errors ) {
- $maxage = $wgResourceLoaderMaxage['unversioned']['client'];
- $smaxage = $wgResourceLoaderMaxage['unversioned']['server'];
+ $maxage = $rlMaxage['unversioned']['client'];
+ $smaxage = $rlMaxage['unversioned']['server'];
// If a version was specified we can use a longer expiry time since changing
// version numbers causes cache misses
} else {
- $maxage = $wgResourceLoaderMaxage['versioned']['client'];
- $smaxage = $wgResourceLoaderMaxage['versioned']['server'];
+ $maxage = $rlMaxage['versioned']['client'];
+ $smaxage = $rlMaxage['versioned']['server'];
}
if ( $context->getOnly() === 'styles' ) {
header( 'Content-Type: text/css; charset=utf-8' );
protected function tryRespondFromFileCache(
ResourceFileCache $fileCache, ResourceLoaderContext $context
) {
- global $wgResourceLoaderMaxage;
+ $rlMaxage = $this->config->get( 'ResourceLoaderMaxage' );
// Buffer output to catch warnings.
ob_start();
// Get the maximum age the cache can be
$maxage = is_null( $context->getVersion() )
- ? $wgResourceLoaderMaxage['unversioned']['server']
- : $wgResourceLoaderMaxage['versioned']['server'];
+ ? $rlMaxage['unversioned']['server']
+ : $rlMaxage['versioned']['server'];
// Minimum timestamp the cache file must have
$good = $fileCache->isCacheGood( wfTimestamp( TS_MW, time() - $maxage ) );
if ( !$good ) {
/**
* Returns LESS compiler set up for use with MediaWiki
*
+ * @param Config $config
+ * @throws MWException
* @since 1.22
* @return lessc
*/
- public static function getLessCompiler() {
- global $wgResourceLoaderLESSFunctions, $wgResourceLoaderLESSImportPaths;
-
+ public static function getLessCompiler( Config $config ) {
// When called from the installer, it is possible that a required PHP extension
// is missing (at least for now; see bug 47564). If this is the case, throw an
// exception (caught by the installer) to prevent a fatal error later on.
$less = new lessc();
$less->setPreserveComments( true );
- $less->setVariables( self::getLESSVars() );
- $less->setImportDir( $wgResourceLoaderLESSImportPaths );
- foreach ( $wgResourceLoaderLESSFunctions as $name => $func ) {
+ $less->setVariables( self::getLESSVars( $config ) );
+ $less->setImportDir( $config->get( 'ResourceLoaderLESSImportPaths' ) );
+ foreach ( $config->get( 'ResourceLoaderLESSFunctions' ) as $name => $func ) {
$less->registerFunction( $name, $func );
}
return $less;
/**
* Get global LESS variables.
*
- * $since 1.22
+ * @param Config $config
+ * @since 1.22
* @return array Map of variable names to string CSS values.
*/
- public static function getLESSVars() {
- global $wgResourceLoaderLESSVars;
-
- $lessVars = $wgResourceLoaderLESSVars;
+ public static function getLESSVars( Config $config ) {
+ $lessVars = $config->get( 'ResourceLoaderLESSVars' );
// Sort by key to ensure consistent hashing for cache lookups.
ksort( $lessVars );
return $lessVars;
* @param WebRequest $request
*/
public function __construct( $resourceLoader, WebRequest $request ) {
- global $wgDefaultSkin, $wgResourceLoaderDebug;
-
$this->resourceLoader = $resourceLoader;
$this->request = $request;
// Various parameters
$this->skin = $request->getVal( 'skin' );
$this->user = $request->getVal( 'user' );
- $this->debug = $request->getFuzzyBool( 'debug', $wgResourceLoaderDebug );
+ $this->debug = $request->getFuzzyBool(
+ 'debug', $resourceLoader->getConfig()->get( 'ResourceLoaderDebug' )
+ );
$this->only = $request->getVal( 'only' );
$this->version = $request->getVal( 'version' );
$this->raw = $request->getFuzzyBool( 'raw' );
$skinnames = Skin::getSkinNames();
// If no skin is specified, or we don't recognize the skin, use the default skin
if ( !$this->skin || !isset( $skinnames[$this->skin] ) ) {
- $this->skin = $wgDefaultSkin;
+ $this->skin = $resourceLoader->getConfig()->get( 'DefaultSkin' );
}
}
return null;
}
- global $wgResourceLoaderValidateStaticJS;
$localPath = $this->getLocalPath( $this->skipFunction );
if ( !file_exists( $localPath ) ) {
throw new MWException( __METHOD__ . ": skip function file not found: \"$localPath\"" );
}
$contents = file_get_contents( $localPath );
- if ( $wgResourceLoaderValidateStaticJS ) {
+ if ( $this->getConfig()->get( 'ResourceLoaderValidateStaticJS' ) ) {
$contents = $this->validateScriptFile( $fileName, $contents );
}
return $contents;
* @return string Concatenated and remapped JavaScript data from $scripts
*/
protected function readScriptFiles( array $scripts ) {
- global $wgResourceLoaderValidateStaticJS;
if ( empty( $scripts ) ) {
return '';
}
throw new MWException( __METHOD__ . ": script file not found: \"$localPath\"" );
}
$contents = file_get_contents( $localPath );
- if ( $wgResourceLoaderValidateStaticJS ) {
+ if ( $this->getConfig()->get( 'ResourceLoaderValidateStaticJS' ) ) {
// Static files don't really need to be checked as often; unlike
// on-wiki module they shouldn't change unexpectedly without
// admin interference.
* @param string $fileName File name of root LESS file.
* @return string Cache key
*/
- protected static function getLESSCacheKey( $fileName ) {
- $vars = json_encode( ResourceLoader::getLESSVars() );
+ protected function getLESSCacheKey( $fileName ) {
+ $vars = json_encode( ResourceLoader::getLESSVars( $this->getConfig() ) );
$hash = md5( $fileName . $vars );
return wfMemcKey( 'resourceloader', 'less', $hash );
}
* @return string CSS source
*/
protected function compileLESSFile( $fileName ) {
- $key = self::getLESSCacheKey( $fileName );
+ $key = $this->getLESSCacheKey( $fileName );
$cache = wfGetCache( CACHE_ANYTHING );
// The input to lessc. Either an associative array representing the
$source = $fileName;
}
- $compiler = ResourceLoader::getLessCompiler();
+ $compiler = ResourceLoader::getLessCompiler( $this->getConfig() );
$result = null;
$result = $compiler->cachedCompile( $source );
// In-object cache for message blob mtime
protected $msgBlobMtime = array();
+ /**
+ * @var Config
+ */
+ protected $config;
+
/* Methods */
/**
return '';
}
+ /**
+ * @return Config
+ * @since 1.24
+ */
+ public function getConfig() {
+ if ( $this->config === null ) {
+ // Ugh, fall back to default
+ $this->config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ }
+
+ return $this->config;
+ }
+
+ /**
+ * @param Config $config
+ * @since 1.24
+ */
+ public function setConfig( Config $config ) {
+ $this->config = $config;
+ }
+
/**
* Get the URL or URLs to load for this module's JS in debug mode.
* The default behavior is to return a load.php?only=scripts URL for
* @return string JS with the original, or a replacement error
*/
protected function validateScriptFile( $fileName, $contents ) {
- global $wgResourceLoaderValidateJS;
- if ( $wgResourceLoaderValidateJS ) {
+ if ( $this->getConfig()->get( 'ResourceLoaderValidateJS' ) ) {
// Try for cache hit
// Use CACHE_ANYTHING since filtering is very slow compared to DB queries
$key = wfMemcKey( 'resourceloader', 'jsparse', self::$parseCacheVersion, md5( $contents ) );
* @return array List of pages
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgUseSiteJs, $wgUseSiteCss;
-
$pages = array();
- if ( $wgUseSiteJs ) {
+ if ( $this->getConfig()->get( 'UseSiteJs' ) ) {
$pages['MediaWiki:Common.js'] = array( 'type' => 'script' );
$pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.js'] = array( 'type' => 'script' );
}
- if ( $wgUseSiteCss ) {
+ if ( $this->getConfig()->get( 'UseSiteCss' ) ) {
$pages['MediaWiki:Common.css'] = array( 'type' => 'style' );
$pages['MediaWiki:' . ucfirst( $context->getSkin() ) . '.css'] = array( 'type' => 'style' );
* @param ResourceLoaderContext $context
* @return array
*/
- protected function getConfig( $context ) {
+ protected function getConfigSettings( $context ) {
$hash = $context->getHash();
if ( isset( $this->configVars[$hash] ) ) {
return $this->configVars[$hash];
}
- global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
- $wgArticlePath, $wgScriptPath, $wgServer, $wgServerName,
- $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion,
- $wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
- $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
- $wgCookiePrefix, $wgCookieDomain, $wgCookiePath,
- $wgCookieExpiration, $wgResourceLoaderMaxQueryLength,
- $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion,
- $wgSearchType;
+ global $wgContLang;
$mainPage = Title::newMainPage();
}
}
+ $conf = $this->getConfig();
// Build list of variables
$vars = array(
- 'wgLoadScript' => $wgLoadScript,
+ 'wgLoadScript' => wfScript( 'load' ),
'debug' => $context->getDebug(),
'skin' => $context->getSkin(),
- 'stylepath' => $wgStylePath,
+ 'stylepath' => $conf->get( 'StylePath' ),
'wgUrlProtocols' => wfUrlProtocols(),
- 'wgArticlePath' => $wgArticlePath,
- 'wgScriptPath' => $wgScriptPath,
- 'wgScriptExtension' => $wgScriptExtension,
- 'wgScript' => $wgScript,
- 'wgSearchType' => $wgSearchType,
- 'wgVariantArticlePath' => $wgVariantArticlePath,
+ 'wgArticlePath' => $conf->get( 'ArticlePath' ),
+ 'wgScriptPath' => $conf->get( 'ScriptPath' ),
+ 'wgScriptExtension' => $conf->get( 'ScriptExtension' ),
+ 'wgScript' => wfScript(),
+ 'wgSearchType' => $conf->get( 'SearchType' ),
+ 'wgVariantArticlePath' => $conf->get( 'VariantArticlePath' ),
// Force object to avoid "empty" associative array from
// becoming [] instead of {} in JS (bug 34604)
- 'wgActionPaths' => (object)$wgActionPaths,
- 'wgServer' => $wgServer,
- 'wgServerName' => $wgServerName,
+ 'wgActionPaths' => (object)$conf->get( 'ActionPaths' ),
+ 'wgServer' => $conf->get( 'Server' ),
+ 'wgServerName' => $conf->get( 'ServerName' ),
'wgUserLanguage' => $context->getLanguage(),
'wgContentLanguage' => $wgContLang->getCode(),
- 'wgVersion' => $wgVersion,
- 'wgEnableAPI' => $wgEnableAPI,
- 'wgEnableWriteAPI' => $wgEnableWriteAPI,
+ 'wgVersion' => $conf->get( 'Version' ),
+ 'wgEnableAPI' => $conf->get( 'EnableAPI' ),
+ 'wgEnableWriteAPI' => $conf->get( 'EnableWriteAPI' ),
'wgMainPageTitle' => $mainPage->getPrefixedText(),
'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds,
'wgContentNamespaces' => MWNamespace::getContentNamespaces(),
- 'wgSiteName' => $wgSitename,
- 'wgFileExtensions' => array_values( array_unique( $wgFileExtensions ) ),
- 'wgDBname' => $wgDBname,
+ 'wgSiteName' => $conf->get( 'Sitename' ),
+ 'wgFileExtensions' => array_values( array_unique( $conf->get( 'FileExtensions' ) ) ),
+ 'wgDBname' => $conf->get( 'DBname' ),
// This sucks, it is only needed on Special:Upload, but I could
// not find a way to add vars only for a certain module
'wgFileCanRotate' => BitmapHandler::canRotate(),
'wgAvailableSkins' => Skin::getSkinNames(),
- 'wgExtensionAssetsPath' => $wgExtensionAssetsPath,
+ 'wgExtensionAssetsPath' => $conf->get( 'ExtensionAssetsPath' ),
// MediaWiki sets cookies to have this prefix by default
- 'wgCookiePrefix' => $wgCookiePrefix,
- 'wgCookieDomain' => $wgCookieDomain,
- 'wgCookiePath' => $wgCookiePath,
- 'wgCookieExpiration' => $wgCookieExpiration,
- 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength,
+ 'wgCookiePrefix' => $conf->get( 'CookiePrefix' ),
+ 'wgCookieDomain' => $conf->get( 'CookieDomain' ),
+ 'wgCookiePath' => $conf->get( 'CookiePath' ),
+ 'wgCookieExpiration' => $conf->get( 'CookieExpiration' ),
+ 'wgResourceLoaderMaxQueryLength' => $conf->get( 'ResourceLoaderMaxQueryLength' ),
'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
- 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion,
- 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled,
+ 'wgResourceLoaderStorageVersion' => $conf->get( 'ResourceLoaderStorageVersion' ),
+ 'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
);
wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );
* @param ResourceLoaderContext $context
* @return string JavaScript code for registering all modules with the client loader
*/
- public static function getModuleRegistrations( ResourceLoaderContext $context ) {
- global $wgCacheEpoch;
+ public function getModuleRegistrations( ResourceLoaderContext $context ) {
wfProfileIn( __METHOD__ );
$resourceLoader = $context->getResourceLoader();
// getModifiedTime() is supposed to return a UNIX timestamp, but it doesn't always
// seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
$moduleMtime = wfTimestamp( TS_UNIX, $module->getModifiedTime( $context ) );
- $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $wgCacheEpoch ) );
+ $mtime = max( $moduleMtime, wfTimestamp( TS_UNIX, $this->getConfig()->get( 'CacheEpoch' ) ) );
// FIXME: Convert to numbers, wfTimestamp always gives us stings, even for TS_UNIX
* @return string
*/
public function getScript( ResourceLoaderContext $context ) {
- global $IP, $wgLegacyJavaScriptGlobals;
+ global $IP;
$out = file_get_contents( "$IP/resources/src/startup.js" );
if ( $context->getOnly() === 'scripts' ) {
// Startup function
- $configuration = $this->getConfig( $context );
- $registrations = self::getModuleRegistrations( $context );
+ $configuration = $this->getConfigSettings( $context );
+ $registrations = $this->getModuleRegistrations( $context );
// Fix indentation
$registrations = str_replace( "\n", "\n\t", trim( $registrations ) );
$out .= "var startUp = function () {\n" .
"\tmw.config = new " .
- Xml::encodeJsCall( 'mw.Map', array( $wgLegacyJavaScriptGlobals ) ) . "\n" .
+ Xml::encodeJsCall( 'mw.Map', array( $this->getConfig()->get( 'LegacyJavaScriptGlobals' ) ) ) . "\n" .
"\t$registrations\n" .
"\t" . Xml::encodeJsCall( 'mw.config.set', array( $configuration ) ) .
"};\n";
* @return array|mixed
*/
public function getModifiedTime( ResourceLoaderContext $context ) {
- global $IP, $wgCacheEpoch;
+ global $IP;
$hash = $context->getHash();
if ( isset( $this->modifiedTime[$hash] ) ) {
$loader->preloadModuleInfo( $loader->getModuleNames(), $context );
$time = max(
- wfTimestamp( TS_UNIX, $wgCacheEpoch ),
+ wfTimestamp( TS_UNIX, $this->getConfig()->get( 'CacheEpoch' ) ),
filemtime( "$IP/resources/src/startup.js" ),
$this->getHashMtime( $context )
);
* @return string Hash
*/
public function getModifiedHash( ResourceLoaderContext $context ) {
- global $wgLegacyJavaScriptGlobals;
-
$data = array(
- 'vars' => $this->getConfig( $context ),
- 'wgLegacyJavaScriptGlobals' => $wgLegacyJavaScriptGlobals,
+ 'vars' => $this->getConfigSettings( $context ),
+ 'wgLegacyJavaScriptGlobals' => $this->getConfig()->get( 'LegacyJavaScriptGlobals' ),
);
return md5( serialize( $data ) );
* @return array
*/
public function getStyles( ResourceLoaderContext $context ) {
- global $wgAllowUserCssPrefs, $wgUser;
+ global $wgUser;
- if ( !$wgAllowUserCssPrefs ) {
+ if ( !$this->getConfig()->get( 'AllowUserCssPrefs' ) ) {
return array();
}
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgUser, $wgUseSiteJs, $wgUseSiteCss;
+ global $wgUser;
$userName = $context->getUser();
if ( $userName === null ) {
return array();
}
- if ( !$wgUseSiteJs && !$wgUseSiteCss ) {
+
+ $useSiteJs = $this->getConfig()->get( 'UseSiteJs' );
+ $useSiteCss = $this->getConfig()->get( 'UseSiteCss' );
+ if ( !$useSiteJs && !$useSiteCss ) {
return array();
}
if ( $group == '*' ) {
continue;
}
- if ( $wgUseSiteJs ) {
+ if ( $useSiteJs ) {
$pages["MediaWiki:Group-$group.js"] = array( 'type' => 'script' );
}
- if ( $wgUseSiteCss ) {
+ if ( $useSiteCss ) {
$pages["MediaWiki:Group-$group.css"] = array( 'type' => 'style' );
}
}
* @return array
*/
protected function getPages( ResourceLoaderContext $context ) {
- global $wgAllowUserJs, $wgAllowUserCss;
$username = $context->getUser();
if ( $username === null ) {
return array();
}
- if ( !$wgAllowUserJs && !$wgAllowUserCss ) {
+
+ $allowUserJs = $this->getConfig()->get( 'AllowUserJs' );
+ $allowUserCss = $this->getConfig()->get( 'AllowUserCss' );
+
+ if ( !$allowUserJs && !$allowUserCss ) {
return array();
}
$userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
$pages = array();
- if ( $wgAllowUserJs ) {
+ if ( $allowUserJs ) {
$pages["$userpage/common.js"] = array( 'type' => 'script' );
$pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' );
}
- if ( $wgAllowUserCss ) {
+ if ( $allowUserCss ) {
$pages["$userpage/common.css"] = array( 'type' => 'style' );
$pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' );
}
* @return array
*/
public function getStyles( ResourceLoaderContext $context ) {
- global $wgScriptPath;
-
$styles = array();
foreach ( $this->getPages( $context ) as $titleText => $options ) {
if ( $options['type'] !== 'style' ) {
if ( $this->getFlip( $context ) ) {
$style = CSSJanus::transform( $style, true, false );
}
- $style = CSSMin::remap( $style, false, $wgScriptPath, true );
+ $style = CSSMin::remap( $style, false, $this->getConfig()->get( 'ScriptPath' ), true );
if ( !isset( $styles[$media] ) ) {
$styles[$media] = array();
}
"$thisString must refer to a readable file"
);
- $compiler = ResourceLoader::getLessCompiler();
+ $compiler = ResourceLoader::getLessCompiler( RequestContext::getMain()->getConfig() );
$this->assertNotNull( $compiler->compileFile( $this->file ) );
}
$expect = file_get_contents( $cssFile );
$content = file_get_contents( $lessFile );
- $result = ResourceLoader::getLessCompiler()->compile( $content, $lessFile );
+ $result = ResourceLoader::getLessCompiler( RequestContext::getMain()->getConfig() )
+ ->compile( $content, $lessFile );
$this->assertEquals( $expect, $result );
}
}
$rl->register( $case['modules'] );
+ $module = new ResourceLoaderStartUpModule();
$this->assertEquals(
ltrim( $case['out'], "\n" ),
- ResourceLoaderStartUpModule::getModuleRegistrations( $context ),
+ $module->getModuleRegistrations( $context ),
$case['msg']
);
}
$context = self::getResourceLoaderContext();
$rl = $context->getResourceLoader();
$rl->register( $modules );
+ $module = new ResourceLoaderStartUpModule();
$this->assertEquals(
'mw.loader.addSource({"local":{"loadScript":"/w/load.php","apiScript":"/w/api.php"}});'
. 'mw.loader.register(['
. '["test.min","1388534400",["test.blank"],null,"local",'
. '"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"'
. ']]);',
- ResourceLoaderStartUpModule::getModuleRegistrations( $context ),
+ $module->getModuleRegistrations( $context ),
'Minified output'
);
}
$context = self::getResourceLoaderContext();
$rl = $context->getResourceLoader();
$rl->register( $modules );
+ $module = new ResourceLoaderStartUpModule();
$this->assertEquals(
'mw.loader.addSource( {
"local": {
"return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
]
] );',
- ResourceLoaderStartUpModule::getModuleRegistrations( $context ),
+ $module->getModuleRegistrations( $context ),
'Unminified output'
);
}