38 if ( isset( $this->configVars[$hash] ) ) {
39 return $this->configVars[$hash];
60 $namespaceIds = $wgContLang->getNamespaceIds();
61 $caseSensitiveNamespaces = [];
63 $namespaceIds[$wgContLang->lc(
$name )] = $index;
65 $caseSensitiveNamespaces[] = $index;
71 'wgLoadScript' =>
wfScript(
'load' ),
74 'stylepath' => $conf->get(
'StylePath' ),
76 'wgArticlePath' => $conf->get(
'ArticlePath' ),
77 'wgScriptPath' => $conf->get(
'ScriptPath' ),
78 'wgScriptExtension' =>
'.php',
80 'wgSearchType' => $conf->get(
'SearchType' ),
81 'wgVariantArticlePath' => $conf->get(
'VariantArticlePath' ),
84 'wgActionPaths' => (
object)$conf->get(
'ActionPaths' ),
85 'wgServer' => $conf->get(
'Server' ),
86 'wgServerName' => $conf->get(
'ServerName' ),
87 'wgUserLanguage' =>
$context->getLanguage(),
88 'wgContentLanguage' => $wgContLang->getCode(),
89 'wgTranslateNumerals' => $conf->get(
'TranslateNumerals' ),
90 'wgVersion' => $conf->get(
'Version' ),
91 'wgEnableAPI' => $conf->get(
'EnableAPI' ),
92 'wgEnableWriteAPI' => $conf->get(
'EnableWriteAPI' ),
93 'wgMainPageTitle' => $mainPage->getPrefixedText(),
94 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
95 'wgNamespaceIds' => $namespaceIds,
97 'wgSiteName' => $conf->get(
'Sitename' ),
98 'wgDBname' => $conf->get(
'DBname' ),
99 'wgExtraSignatureNamespaces' => $conf->get(
'ExtraSignatureNamespaces' ),
101 'wgExtensionAssetsPath' => $conf->get(
'ExtensionAssetsPath' ),
103 'wgCookiePrefix' => $conf->get(
'CookiePrefix' ),
104 'wgCookieDomain' => $conf->get(
'CookieDomain' ),
105 'wgCookiePath' => $conf->get(
'CookiePath' ),
106 'wgCookieExpiration' => $conf->get(
'CookieExpiration' ),
107 'wgResourceLoaderMaxQueryLength' => $conf->get(
'ResourceLoaderMaxQueryLength' ),
108 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces,
110 'wgResourceLoaderStorageVersion' => $conf->get(
'ResourceLoaderStorageVersion' ),
111 'wgResourceLoaderStorageEnabled' => $conf->get(
'ResourceLoaderStorageEnabled' ),
112 'wgResourceLoaderLegacyModules' => self::getLegacyModules(),
113 'wgForeignUploadTargets' => $conf->get(
'ForeignUploadTargets' ),
114 'wgEnableUploads' => $conf->get(
'EnableUploads' ),
119 $this->configVars[$hash] =
$vars;
120 return $this->configVars[$hash];
131 static $dependencyCache = [];
135 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 ) {
179 $implicitDependencies = self::getImplicitDependencies( $registryData, $dependency );
180 $dependencies = array_diff( $dependencies, $implicitDependencies );
183 $data[
'dependencies'] = array_values( $dependencies );
196 $target = $context->
getRequest()->getVal(
'target',
'desktop' );
199 $byPassTargetFilter = $this->
getConfig()->get(
'EnableJavaScriptTest' ) && $target ===
'test';
207 $moduleTargets = $module->getTargets();
208 if ( !$byPassTargetFilter && !in_array( $target, $moduleTargets ) ) {
212 if ( $module->isRaw() ) {
222 "Module '{module}' produced an invalid version hash: '{version}'.",
233 $skipFunction = $module->getSkipFunction();
238 $registryData[
$name] = [
240 'dependencies' => $module->getDependencies( $context ),
241 'group' => $module->getGroup(),
242 'source' => $module->getSource(),
243 'skip' => $skipFunction,
247 self::compileUnresolvedDependencies( $registryData );
254 foreach ( $registryData
as $name => $data ) {
259 $data[
'dependencies'],
262 $data[
'source'] ===
'local' ? null : $data[
'source'],
286 return [
'jquery',
'mediawiki' ];
293 if ( $wgIncludeLegacyJavaScript ) {
294 $legacyModules[] =
'mediawiki.legacy.wikibits';
297 return $legacyModules;
311 $moduleNames = self::getStartupModules();
318 'debug' => $context->
getDebug() ?
'true' :
'false',
319 'version' => $rl->getCombinedVersion( $context, $moduleNames ),
332 if ( $context->
getOnly() !==
'scripts' ) {
333 return '/* Requires only=script */';
336 $out = file_get_contents(
"$IP/resources/src/startup.js" );
338 $pairs = array_map(
function (
$value ) {
344 '$VARS.wgLegacyJavaScriptGlobals' => $this->
getConfig()->get(
'LegacyJavaScriptGlobals' ),
346 '$VARS.baseModulesUri' => self::getStartupModulesUrl( $context ),
348 $pairs[
'$CODE.registrations()'] = str_replace(
354 return strtr(
$out, $pairs );
372 $summary = parent::getDefinitionSummary( $context );
377 'wgLegacyJavaScriptGlobals' => $this->
getConfig()->get(
'LegacyJavaScriptGlobals' ),
382 filemtime(
"$IP/resources/src/startup.js" ),
397 $rl->preloadModuleInfo( $rl->getModuleNames(),
$context );
404 $this->versionHash[$context->
getHash()] = null;
406 return $rl->getCombinedVersion( $context, $rl->getModuleNames() );
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
the array() calling protocol came about after MediaWiki 1.4rc1.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
static getImplicitDependencies(array $registryData, $moduleName)
Recursively get all explicit and implicit dependencies for to the given module.
getAllModuleHashes(ResourceLoaderContext $context)
Helper method for getDefinitionSummary().
error also a ContextSource you ll probably need to make sure the header is varied on such as when responding to a resource loader request or generating HTML output & $resourceLoader
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.
static compileUnresolvedDependencies(array &$registryData)
Optimize the dependency tree in $this->modules.
getModuleRegistrations(ResourceLoaderContext $context)
Get registration code for all modules.
static getSkinNames()
Fetch the set of available skins.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
when a variable name is used in a it is silently declared as a new local masking the global
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
static isCapitalized($index)
Is the namespace first-letter capitalized?
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.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
static makePackedModulesString($modules)
Convert an array of module names to a packed query string.
getConfigSettings($context)
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$wgIncludeLegacyJavaScript
Whether to ensure the mediawiki.legacy library is loaded before other modules.
static getStartupModules()
Base modules required for the base environment of ResourceLoader.
getScript(ResourceLoaderContext $context)
wfUrlProtocols($includeProtocolRelative=true)
Returns a regular expression of url protocols.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static convertByteClassToUnicodeClass($byteClass)
Utility method for converting a character sequence from bytes to Unicode.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie...
static filter($filter, $data, array $options=[])
Run JavaScript or CSS data through a filter, caching the filtered result for future calls...
static makeLoaderSourcesScript($id, $properties=null)
Returns JS code which calls mw.loader.addSource() with the given parameters.
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 legalChars()
Get a regex character class describing the legal characters in a link.
getHash()
All factors that uniquely identify this request, except 'modules'.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
static getStartupModulesUrl(ResourceLoaderContext $context)
Get the load URL of the startup modules.
static getLegacyModules()
Object passed around to modules which contains information about the state of a specific loader reque...