21use Wikimedia\WrappedStringList;
75 $this->config[$key] =
$value;
116 $this->exemptStates = $states;
145 foreach ( $this->modules as $name ) {
146 $module = $rl->getModule( $name );
152 if ( $module->isKnownEmpty(
$context ) ) {
158 if ( $module->shouldEmbedModule( $this->context ) ) {
169 foreach ( $this->moduleStyles as $name ) {
170 $module = $rl->getModule( $name );
176 $logger = $rl->getLogger();
177 $logger->error(
'Unexpected general module "{module}" in styles queue.', [
188 $group = $module->getGroup();
191 if ( !$module->isKnownEmpty(
$context ) ) {
192 if ( $module->shouldEmbedModule( $this->context ) ) {
202 foreach ( $this->moduleScripts as $name ) {
203 $module = $rl->getModule( $name );
208 $group = $module->getGroup();
210 if ( $module->isKnownEmpty(
$context ) ) {
229 return [
'class' =>
'client-nojs' ];
253 $chunks[] = Html::inlineScript(
254 'document.documentElement.className = document.documentElement.className'
255 .
'.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );'
259 if ( $this->config ) {
266 $states = array_merge( $this->exemptStates,
$data[
'states'] );
274 if (
$data[
'embed'][
'general'] ) {
276 $data[
'embed'][
'general'],
282 if (
$data[
'general'] ) {
284 Xml::encodeJsCall(
'mw.loader.load', [
$data[
'general'] ] )
289 if (
$data[
'scripts'] ) {
297 if (
$data[
'styles'] ) {
305 if (
$data[
'embed'][
'styles'] ) {
307 $data[
'embed'][
'styles'],
314 $startupQuery = isset( $this->
options[
'target'] )
323 return WrappedStringList::join(
"\n", $chunks );
342 array $extraQuery = []
345 $req =
new FauxRequest( array_merge( $mainContext->getRequest()->getValues(), $extraQuery ) );
349 if ( $group !==
'user' && $group !==
'private' ) {
350 $req->setVal(
'user',
null );
367 array $extraQuery = []
369 $rl = $mainContext->getResourceLoader();
375 if ( $mainContext->getDebug() && count(
$modules ) > 1 ) {
379 $chunks[] =
self::makeLoad( $mainContext, [ $name ], $only, $extraQuery );
381 return new WrappedStringList(
"\n", $chunks );
387 $module = $rl->getModule( $name );
389 $rl->getLogger()->warning(
'Unknown module "{module}"', [
'module' => $name ] );
392 $sortedModules[$module->getSource()][$module->getGroup()][
$name] = $module;
395 foreach ( $sortedModules as
$source => $groups ) {
396 foreach ( $groups as $group => $grpModules ) {
402 foreach ( $grpModules as $name => $module ) {
403 $shouldEmbed = $module->shouldEmbedModule(
$context );
404 if ( !$moduleSets || $moduleSets[$idx][0] !== $shouldEmbed ) {
405 $moduleSets[++$idx] = [ $shouldEmbed, [] ];
407 $moduleSets[$idx][1][
$name] = $module;
411 foreach ( $moduleSets as
list( $embed, $moduleSet ) ) {
412 $context->setModules( array_keys( $moduleSet ) );
416 $chunks[] = Html::inlineStyle(
417 $rl->makeModuleResponse(
$context, $moduleSet )
421 $rl->makeModuleResponse(
$context, $moduleSet )
427 foreach ( $moduleSet as $key => $module ) {
428 $isRaw |= $module->isRaw();
436 if ( $group ===
'user' ) {
445 $chunk = Html::linkedStyle( $url );
448 $chunk = Html::element(
'script', [
450 'async' => !isset( $extraQuery[
'sync'] ),
455 Xml::encodeJsCall(
'mw.loader.load', [ $url ] )
460 if ( $group ==
'noscript' ) {
461 $chunks[] = Html::rawElement(
'noscript', [], $chunk );
470 return new WrappedStringList(
"\n", $chunks );
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.
__construct(ResourceLoaderContext $context, array $options=[])
getHeadHtml()
The order of elements in the head is as follows:
getContext( $group, $type)
setConfig(array $vars)
Set mw.config variables.
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)
Returns an HTML script tag that runs given JS code after startup and base modules.
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 hook is for auditing only $req
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Allows to change the fields on the form that will be generated $name