16 'ResourceLoaderSources' => [],
17 'ResourceModuleSkinStyles' => [],
18 'ResourceModules' => [],
19 'EnableJavaScriptTest' =>
false,
20 'ResourceLoaderDebug' =>
false,
21 'LoadScript' =>
'/w/load.php',
29 'target' =>
'phpunit',
41 'test.top' => [
'position' =>
'top' ],
42 'test.private.top' => [
'group' =>
'private',
'position' =>
'top' ],
43 'test.private.bottom' => [
'group' =>
'private',
'position' =>
'bottom' ],
46 'test.styles.mixed' => [],
48 'test.styles.mixed.user' => [
'group' =>
'user' ],
49 'test.styles.mixed.user.empty' => [
'group' =>
'user',
'isKnownEmpty' =>
true ],
50 'test.styles.private' => [
'group' =>
'private',
'styles' =>
'.private{}' ],
53 'test.scripts.top' => [
'position' =>
'top' ],
54 'test.scripts.mixed.user' => [
'group' =>
'user' ],
55 'test.scripts.mixed.user.empty' => [
'group' =>
'user',
'isKnownEmpty' =>
true ],
56 'test.scripts.raw' => [
'isRaw' =>
true ],
58 return array_map(
function (
$options ) {
68 $this->assertInternalType(
'array', $client->getDocumentAttributes() );
81 $context->getResourceLoader()->register( self::makeSampleModules() );
84 $client->setModules( [
86 'test.private.bottom',
91 $client->setModuleStyles( [
93 'test.styles.mixed.user.empty',
94 'test.styles.private',
96 'test.unregistered.styles',
98 $client->setModuleScripts( [
100 'test.scripts.mixed.user.empty',
102 'test.unregistered.scripts',
107 'test.private.top' =>
'loading',
108 'test.private.bottom' =>
'loading',
109 'test.styles.pure' =>
'ready',
110 'test.styles.mixed.user.empty' =>
'ready',
111 'test.styles.private' =>
'ready',
112 'test.scripts' =>
'loading',
113 'test.scripts.top' =>
'loading',
114 'test.scripts.mixed.user.empty' =>
'ready',
117 'top' => [
'test.top' ],
118 'bottom' => [
'test' ],
125 'top' => [
'test.scripts.top' ],
126 'bottom' => [
'test.scripts' ],
129 'styles' => [
'test.styles.private' ],
131 'top' => [
'test.private.top' ],
132 'bottom' => [
'test.private.bottom' ],
138 $this->assertEquals( $expected, $access->getData() );
150 $context->getResourceLoader()->register( self::makeSampleModules() );
153 $client->setConfig( [
'key' =>
'value' ] );
154 $client->setModules( [
158 $client->setModuleStyles( [
160 'test.styles.private',
162 $client->setModuleScripts( [
165 $client->setExemptStates( [
166 'test.exempt' =>
'ready',
170 $expected =
'<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' .
"\n"
171 .
'<script>(window.RLQ=window.RLQ||[]).push(function(){'
172 .
'mw.config.set({"key":"value"});'
173 .
'mw.loader.state({"test.exempt":"ready","test.private.top":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.scripts.top":"loading"});'
174 .
'mw.loader.implement("test.private.top@{blankVer}",function($,jQuery,require,module){},{"css":[]});'
175 .
'mw.loader.load(["test.top"]);'
176 .
'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts.top\u0026only=scripts\u0026skin=fallback");'
177 .
'});</script>' .
"\n"
178 .
'<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' .
"\n"
179 .
'<style>.private{}</style>' .
"\n"
180 .
'<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
182 $expected = self::expandVariables( $expected );
184 $this->assertEquals( $expected, $client->getHeadHtml() );
193 $context->getResourceLoader()->register( self::makeSampleModules() );
196 $client->setConfig( [
'key' =>
'value' ] );
197 $client->setModules( [
199 'test.private.bottom',
201 $client->setModuleScripts( [
206 $expected =
'<script>(window.RLQ=window.RLQ||[]).push(function(){'
207 .
'mw.loader.implement("test.private.bottom@{blankVer}",function($,jQuery,require,module){},{"css":[]});'
208 .
'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts\u0026only=scripts\u0026skin=fallback");'
209 .
'mw.loader.load(["test"]);'
212 $expected = self::expandVariables( $expected );
214 $this->assertEquals( $expected, $client->getBodyHtml() );
222 'modules' => [
'test.unknown' ],
228 'modules' => [
'test.styles.private' ],
230 'output' =>
'<style>.private{}</style>',
234 'modules' => [
'test.private.top' ],
236 'output' =>
'<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.private.top@{blankVer}",function($,jQuery,require,module){},{"css":[]});});</script>',
241 'modules' => [
'test.scripts.raw' ],
243 'output' =>
'<script async="" src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback"></script>',
247 'modules' => [
'test.scripts.mixed.user' ],
249 'output' =>
'<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts.mixed.user\u0026only=scripts\u0026skin=fallback\u0026user=Example\u0026version=0a56zyi");});</script>',
252 'context' => [
'debug' =>
true ],
253 'modules' => [
'test.styles.pure',
'test.styles.mixed' ],
255 'output' =>
'<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' .
"\n"
256 .
'<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.mixed&only=styles&skin=fallback"/>',
260 'modules' => [
'test.styles.noscript' ],
262 'output' =>
'<noscript><link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.noscript&only=styles&skin=fallback"/></noscript>',
281 $context = self::makeContext( $extraQuery );
282 $context->getResourceLoader()->register( self::makeSampleModules() );
284 $expected = self::expandVariables( $expected );
285 $this->assertEquals( $expected, (
string)$actual );
testGetData()
ResourceLoaderClientHtml::__construct ResourceLoaderClientHtml::setModules ResourceLoaderClientHtml::...
testGetDocumentAttributes()
ResourceLoaderClientHtml::getDocumentAttributes.
the array() calling protocol came about after MediaWiki 1.4rc1.
static makeSampleModules()
static makeContext($extraQuery=[])
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
testGetHeadHtml()
ResourceLoaderClientHtml::setConfig ResourceLoaderClientHtml::setExemptStates ResourceLoaderClientHtm...
static expandVariables($text)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Bootstrap a ResourceLoader client on an HTML page.
testMakeLoad(array $extraQuery, array $modules, $type, $expected)
provideMakeLoad ResourceLoaderClientHtml::makeLoad ResourceLoaderClientHtml::makeContext ResourceLoad...
testGetBodyHtml()
ResourceLoaderClientHtml::getBodyHtml ResourceLoaderClientHtml::getLoad.
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 makeModule(array $options=[])
static makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery=[])
Explicily load or embed modules on a page.
static newFromObject($object)
Return the same object, without access restrictions.
A Config instance which stores all settings as a member variable.
Dynamic JavaScript and CSS resource loading system.
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 one of or reset 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
Object passed around to modules which contains information about the state of a specific loader reque...