Go to the documentation of this file.
21 use WrappedString\WrappedStringList;
74 $this->config[$key] =
$value;
115 $this->exemptStates = $states;
146 foreach ( $this->modules
as $name ) {
147 $module = $rl->getModule(
$name );
152 $group = $module->getGroup();
154 if ( $group ===
'private' ) {
165 foreach ( $this->moduleStyles
as $name ) {
166 $module = $rl->getModule(
$name );
172 $logger = $rl->getLogger();
173 $logger->warning(
'Unexpected general module "{module}" in styles queue.', [
182 $group = $module->getGroup();
184 if ( $module->isKnownEmpty(
$context ) ) {
188 if ( $group ===
'private' ) {
200 foreach ( $this->moduleScripts
as $name ) {
201 $module = $rl->getModule(
$name );
206 $group = $module->getGroup();
208 if ( $module->isKnownEmpty(
$context ) ) {
227 return [
'class' =>
'client-nojs' ];
252 'document.documentElement.className = document.documentElement.className'
253 .
'.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );'
257 if ( $this->config ) {
258 $chunks[] = ResourceLoader::makeInlineScript(
259 ResourceLoader::makeConfigSetScript( $this->config )
264 $states = array_merge( $this->exemptStates,
$data[
'states'] );
266 $chunks[] = ResourceLoader::makeInlineScript(
267 ResourceLoader::makeLoaderStateScript( $states )
272 if (
$data[
'embed'][
'general'] ) {
274 $data[
'embed'][
'general'],
280 if (
$data[
'general'] ) {
281 $chunks[] = ResourceLoader::makeInlineScript(
287 if (
$data[
'scripts'] ) {
295 if (
$data[
'styles'] ) {
303 if (
$data[
'embed'][
'styles'] ) {
305 $data[
'embed'][
'styles'],
312 $startupQuery = $this->target ? [
'target' =>
$this->target ] : [];
319 return WrappedStringList::join(
"\n", $chunks );
338 array $extraQuery = []
345 if ( $group !==
'user' && $group !==
'private' ) {
346 $req->setVal(
'user',
null );
363 array $extraQuery = []
378 return new WrappedStringList(
"\n", $chunks );
384 $module = $rl->getModule(
$name );
386 $rl->getLogger()->warning(
'Unknown module "{module}"', [
'module' =>
$name ] );
389 $sortedModules[$module->getSource()][$module->getGroup()][
$name] = $module;
392 foreach ( $sortedModules
as $source => $groups ) {
393 foreach ( $groups
as $group => $grpModules ) {
395 $context->setModules( array_keys( $grpModules ) );
397 if ( $group ===
'private' ) {
401 $rl->makeModuleResponse(
$context, $grpModules )
404 $chunks[] = ResourceLoader::makeInlineScript(
405 $rl->makeModuleResponse(
$context, $grpModules )
413 foreach ( $grpModules
as $key => $module ) {
414 $isRaw |= $module->isRaw();
422 if ( $group ===
'user' ) {
436 'async' => !isset( $extraQuery[
'sync'] ),
440 $chunk = ResourceLoader::makeInlineScript(
446 if ( $group ==
'noscript' ) {
454 return new WrappedStringList(
"\n", $chunks );
Object passed around to modules which contains information about the state of a specific loader reque...
WebRequest clone which takes values from a provided array.
Bootstrap a ResourceLoader client on an HTML page.
__construct(ResourceLoaderContext $context, $target=null)
static makeContext(ResourceLoaderContext $mainContext, $group, $type, array $extraQuery=[])
getContext( $group, $type)
setModuleScripts(array $modules)
Ensure the scripts of one or more modules are loaded.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
this hook is for auditing only $req
setExemptStates(array $states)
Set state of special modules that are handled by the caller manually.
Allows to change the fields on the form that will be generated $name
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
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
ResourceLoaderContext $context
ResourceLoader $resourceLoader
setConfig(array $vars)
Set mw.config variables.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
getLoad( $modules, $only, array $extraQuery=[])
Allows changing specific properties of a context object, without changing the main one.
static inlineStyle( $contents, $media='all')
Output a "<style>" tag with the given contents for the given media type (if any).
static makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery=[])
Explicily load or embed modules on a page.
setModules(array $modules)
Ensure one or more modules are loaded.
static linkedStyle( $url, $media='all')
Output a "<link rel=stylesheet>" linking to the given URL for the given media type (if any).
setModuleStyles(array $modules)
Ensure the styles of one or more modules are loaded.
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
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
the array() calling protocol came about after MediaWiki 1.4rc1.
getHeadHtml()
The order of elements in the head is as follows: