21use WrappedString\WrappedStringList;
74 $this->config[$key] =
$value;
115 $this->exemptStates = $states;
146 foreach ( $this->modules
as $name ) {
152 if ( $module->shouldEmbedModule( $this->context ) ) {
163 foreach ( $this->moduleStyles
as $name ) {
164 $module = $rl->getModule(
$name );
170 $logger = $rl->getLogger();
171 $logger->error(
'Unexpected general module "{module}" in styles queue.', [
181 $group = $module->getGroup();
183 if ( $module->isKnownEmpty(
$context ) ) {
187 if ( $module->shouldEmbedModule( $this->context ) ) {
199 foreach ( $this->moduleScripts
as $name ) {
200 $module = $rl->getModule(
$name );
205 $group = $module->getGroup();
207 if ( $module->isKnownEmpty(
$context ) ) {
226 return [
'class' =>
'client-nojs' ];
250 $chunks[] = Html::inlineScript(
251 'document.documentElement.className = document.documentElement.className'
252 .
'.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );'
256 if ( $this->config ) {
263 $states = array_merge( $this->exemptStates,
$data[
'states'] );
271 if (
$data[
'embed'][
'general'] ) {
273 $data[
'embed'][
'general'],
279 if (
$data[
'general'] ) {
281 Xml::encodeJsCall(
'mw.loader.load', [
$data[
'general'] ] )
286 if (
$data[
'scripts'] ) {
294 if (
$data[
'styles'] ) {
302 if (
$data[
'embed'][
'styles'] ) {
304 $data[
'embed'][
'styles'],
311 $startupQuery = $this->target ? [
'target' =>
$this->target ] : [];
318 return WrappedStringList::join(
"\n", $chunks );
337 array $extraQuery = []
344 if ( $group !==
'user' && $group !==
'private' ) {
345 $req->setVal(
'user',
null );
362 array $extraQuery = []
376 return new WrappedStringList(
"\n", $chunks );
382 $module = $rl->getModule(
$name );
384 $rl->getLogger()->warning(
'Unknown module "{module}"', [
'module' =>
$name ] );
387 $sortedModules[$module->getSource()][$module->getGroup()][
$name] = $module;
390 foreach ( $sortedModules
as $source => $groups ) {
391 foreach ( $groups
as $group => $grpModules ) {
397 foreach ( $grpModules
as $name => $module ) {
398 $shouldEmbed = $module->shouldEmbedModule(
$context );
399 if ( !$moduleSets || $moduleSets[$idx][0] !== $shouldEmbed ) {
400 $moduleSets[++$idx] = [ $shouldEmbed, [] ];
402 $moduleSets[$idx][1][
$name] = $module;
406 foreach ( $moduleSets
as list( $embed, $moduleSet ) ) {
407 $context->setModules( array_keys( $moduleSet ) );
411 $chunks[] = Html::inlineStyle(
412 $rl->makeModuleResponse(
$context, $moduleSet )
416 $rl->makeModuleResponse(
$context, $moduleSet )
422 foreach ( $moduleSet
as $key => $module ) {
423 $isRaw |= $module->isRaw();
431 if ( $group ===
'user' ) {
440 $chunk = Html::linkedStyle( $url );
443 $chunk = Html::element(
'script', [
445 'async' => !isset( $extraQuery[
'sync'] ),
450 Xml::encodeJsCall(
'mw.loader.load', [ $url ] )
455 if ( $group ==
'noscript' ) {
456 $chunks[] = Html::rawElement(
'noscript', [], $chunk );
465 return new WrappedStringList(
"\n", $chunks );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Allows changing specific properties of a context object, without changing the main one.
WebRequest clone which takes values from a provided array.
Bootstrap a ResourceLoader client on an HTML page.
setModules(array $modules)
Ensure one or more modules are loaded.
getLoad( $modules, $only, array $extraQuery=[])
ResourceLoader $resourceLoader
setModuleScripts(array $modules)
Ensure the scripts of one or more modules are loaded.
getHeadHtml()
The order of elements in the head is as follows:
getContext( $group, $type)
setConfig(array $vars)
Set mw.config variables.
__construct(ResourceLoaderContext $context, $target=null)
ResourceLoaderContext $context
setExemptStates(array $states)
Set state of special modules that are handled by the caller manually.
static makeContext(ResourceLoaderContext $mainContext, $group, $type, array $extraQuery=[])
static makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery=[])
Explicily load or embed modules on a page.
setModuleStyles(array $modules)
Ensure the styles of one or more modules are loaded.
Object passed around to modules which contains information about the state of a specific loader reque...
Dynamic JavaScript and CSS resource loading system.
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 makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
static makeInlineScript( $script)
Construct an inline script tag with given JS code.
getModule( $name)
Get the ResourceLoaderModule object for a given module name.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
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
this hook is for auditing only $req
the array() calling protocol came about after MediaWiki 1.4rc1.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
Allows to change the fields on the form that will be generated $name
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
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data