37 if ( isset( $this->configVars[$hash] ) ) {
38 return $this->configVars[$hash];
49 $mainPage = Title::newFromText(
$context->msg(
'mainpage' )->inContentLanguage()->text() );
51 $mainPage = Title::newFromText(
'Main Page' );
60 $caseSensitiveNamespaces = [];
61 foreach ( MWNamespace::getCanonicalNamespaces() as $index => $name ) {
63 if ( !MWNamespace::isCapitalized( $index ) ) {
64 $caseSensitiveNamespaces[] = $index;
68 $illegalFileChars = $conf->get(
'IllegalFileChars' );
72 'wgLoadScript' =>
wfScript(
'load' ),
75 'stylepath' => $conf->get(
'StylePath' ),
77 'wgArticlePath' => $conf->get(
'ArticlePath' ),
78 'wgScriptPath' => $conf->get(
'ScriptPath' ),
79 'wgScriptExtension' =>
'.php',
81 'wgSearchType' => $conf->get(
'SearchType' ),
82 'wgVariantArticlePath' => $conf->get(
'VariantArticlePath' ),
85 'wgActionPaths' => (
object)$conf->get(
'ActionPaths' ),
86 'wgServer' => $conf->get(
'Server' ),
87 'wgServerName' => $conf->get(
'ServerName' ),
88 'wgUserLanguage' =>
$context->getLanguage(),
90 'wgTranslateNumerals' => $conf->get(
'TranslateNumerals' ),
91 'wgVersion' => $conf->get(
'Version' ),
92 'wgEnableAPI' => $conf->get(
'EnableAPI' ),
93 'wgEnableWriteAPI' => $conf->get(
'EnableWriteAPI' ),
94 'wgMainPageTitle' => $mainPage->getPrefixedText(),
95 'wgFormattedNamespaces' =>
$wgContLang->getFormattedNamespaces(),
96 'wgNamespaceIds' => $namespaceIds,
97 'wgContentNamespaces' => MWNamespace::getContentNamespaces(),
98 'wgSiteName' => $conf->get(
'Sitename' ),
99 'wgDBname' => $conf->get(
'DBname' ),
100 'wgExtraSignatureNamespaces' => $conf->get(
'ExtraSignatureNamespaces' ),
102 'wgExtensionAssetsPath' => $conf->get(
'ExtensionAssetsPath' ),
104 'wgCookiePrefix' => $conf->get(
'CookiePrefix' ),
105 'wgCookieDomain' => $conf->get(
'CookieDomain' ),
106 'wgCookiePath' => $conf->get(
'CookiePath' ),
107 'wgCookieExpiration' => $conf->get(
'CookieExpiration' ),
108 'wgResourceLoaderMaxQueryLength' => $conf->get(
'ResourceLoaderMaxQueryLength' ),
109 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
110 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
111 'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass( $illegalFileChars ),
112 'wgResourceLoaderStorageVersion' => $conf->get(
'ResourceLoaderStorageVersion' ),
113 'wgResourceLoaderStorageEnabled' => $conf->get(
'ResourceLoaderStorageEnabled' ),
114 'wgForeignUploadTargets' => $conf->get(
'ForeignUploadTargets' ),
115 'wgEnableUploads' => $conf->get(
'EnableUploads' ),
118 Hooks::run(
'ResourceLoaderGetConfigVars', [ &
$vars ] );
120 $this->configVars[$hash] =
$vars;
121 return $this->configVars[$hash];
132 static $dependencyCache = [];
136 if ( !isset( $dependencyCache[$moduleName] ) ) {
137 if ( !isset( $registryData[$moduleName] ) ) {
139 $dependencyCache[$moduleName] = [];
141 $data = $registryData[$moduleName];
142 $dependencyCache[$moduleName] = $data[
'dependencies'];
144 foreach ( $data[
'dependencies'] as $dependency ) {
146 $dependencyCache[$moduleName] = array_merge(
147 $dependencyCache[$moduleName],
148 self::getImplicitDependencies( $registryData, $dependency )
154 return $dependencyCache[$moduleName];
176 foreach ( $registryData as $name => &$data ) {
177 $dependencies = $data[
'dependencies'];
178 foreach ( $data[
'dependencies'] as $dependency ) {
180 $dependencies = array_diff( $dependencies, $implicitDependencies );
183 $data[
'dependencies'] = array_values( $dependencies );
195 $target =
$context->getRequest()->getVal(
'target',
'desktop' );
198 $byPassTargetFilter = $this->
getConfig()->get(
'EnableJavaScriptTest' ) && $target ===
'test';
207 $moduleTargets = $module->getTargets();
208 if ( !$byPassTargetFilter && !in_array( $target, $moduleTargets ) ) {
212 if ( $module->isRaw() ) {
221 }
catch ( Exception
$e ) {
223 MWExceptionHandler::logException(
$e );
225 'Calculating version for "{module}" failed: {exception}',
232 $states[
$name] =
'error';
237 "Module '{module}' produced an invalid version hash: '{version}'.",
248 $skipFunction = $module->getSkipFunction();
253 $registryData[
$name] = [
255 'dependencies' => $module->getDependencies(
$context ),
256 'group' => $module->getGroup(),
257 'source' => $module->getSource(),
258 'skip' => $skipFunction,
269 foreach ( $registryData as $name => $data ) {
274 $data[
'dependencies'],
277 $data[
'source'] ===
'local' ? null : $data[
'source'],
306 $url => [
'as' =>
'script' ]
316 return [
'jquery',
'mediawiki' ];
324 $legacyModules[] =
'mediawiki.legacy.wikibits';
327 return $legacyModules;
340 $rl =
$context->getResourceLoader();
342 $derivative->setModules( array_merge(
343 self::getStartupModules(),
344 self::getLegacyModules()
346 $derivative->setOnly(
'scripts' );
348 $derivative->setVersion( $rl->makeVersionQuery( $derivative ) );
350 return $rl->createLoaderURL(
'local', $derivative );
359 if (
$context->getOnly() !==
'scripts' ) {
360 return '/* Requires only=script */';
363 $out = file_get_contents(
"$IP/resources/src/startup.js" );
365 $pairs = array_map(
function (
$value ) {
371 '$VARS.wgLegacyJavaScriptGlobals' => $this->
getConfig()->get(
'LegacyJavaScriptGlobals' ),
376 $pairs[
'$CODE.registrations()'] = str_replace(
382 return strtr(
$out, $pairs );
400 $summary = parent::getDefinitionSummary(
$context );
405 'wgLegacyJavaScriptGlobals' => $this->
getConfig()->get(
'LegacyJavaScriptGlobals' ),
410 filemtime(
"$IP/resources/src/startup.js" ),
423 $rl =
$context->getResourceLoader();
425 $rl->preloadModuleInfo( $rl->getModuleNames(),
$context );
432 $this->versionHash[
$context->getHash()] =
null;
434 return $rl->getCombinedVersion(
$context, $rl->getModuleNames() );
$wgIncludeLegacyJavaScript
Whether to ensure the mediawiki.legacy library is loaded before other modules.
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Allows changing specific properties of a context object, without changing the main one.
Object passed around to modules which contains information about the state of a specific loader reque...
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
getScript(ResourceLoaderContext $context)
static getImplicitDependencies(array $registryData, $moduleName)
Recursively get all explicit and implicit dependencies for to the given module.
static getStartupModules()
Base modules required for the base environment of ResourceLoader.
getPreloadLinks(ResourceLoaderContext $context)
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
getAllModuleHashes(ResourceLoaderContext $context)
Helper method for getDefinitionSummary().
getConfigSettings( $context)
static compileUnresolvedDependencies(array &$registryData)
Optimize the dependency tree in $this->modules.
static getStartupModulesUrl(ResourceLoaderContext $context)
Get the load URL of the startup modules.
getModuleRegistrations(ResourceLoaderContext $context)
Get registration code for all modules.
static getLegacyModules()
static makeLoaderStateScript( $name, $state=null)
Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
static makeLoaderSourcesScript( $id, $loadUrl=null)
Returns JS code which calls mw.loader.addSource() with the given parameters.
static makeLoaderRegisterScript( $name, $version=null, $dependencies=null, $group=null, $source=null, $skip=null)
Returns JS code which calls mw.loader.register with the given parameters.
static filter( $filter, $data, array $options=[])
Run JavaScript or CSS data through a filter, caching the filtered result for future calls.
static getSkinNames()
Fetch the set of available skins.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext such as when responding to a resource loader request or generating HTML output & $resourceLoader
returning false will NOT prevent logging $e
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object