MediaWiki
REL1_34
ResourceLoaderUserModule.php
Go to the documentation of this file.
1
<?php
29
class
ResourceLoaderUserModule
extends
ResourceLoaderWikiModule
{
30
31
protected
$origin
= self::ORIGIN_USER_INDIVIDUAL;
32
protected
$targets
= [
'desktop'
,
'mobile'
];
33
38
protected
function
getPages
(
ResourceLoaderContext
$context
) {
39
$config
= $this->
getConfig
();
40
$user =
$context
->getUserObj();
41
if
( $user->isAnon() ) {
42
return
[];
43
}
44
45
// Use localised/normalised variant to ensure $excludepage matches
46
$userPage = $user->getUserPage()->getPrefixedDBkey();
47
$pages = [];
48
49
if
(
$config
->
get
(
'AllowUserJs'
) ) {
50
$pages[
"$userPage/common.js"
] = [
'type'
=>
'script'
];
51
$pages[
"$userPage/"
.
$context
->getSkin() .
'.js'
] = [
'type'
=>
'script'
];
52
}
53
54
// User group pages are maintained site-wide and enabled with site JS/CSS.
55
if
(
$config
->
get
(
'UseSiteJs'
) ) {
56
foreach
( $user->getEffectiveGroups() as
$group
) {
57
if
(
$group
==
'*'
) {
58
continue
;
59
}
60
$pages[
"MediaWiki:Group-$group.js"
] = [
'type'
=>
'script'
];
61
}
62
}
63
64
// This is obsolete since 1.32 (T112474). It was formerly used by
65
// OutputPage to implement previewing of user CSS and JS.
66
// @todo: Remove it once we're sure nothing else is using the parameter
67
$excludepage =
$context
->getRequest()->getVal(
'excludepage'
);
68
if
( isset( $pages[$excludepage] ) ) {
69
unset( $pages[$excludepage] );
70
}
71
72
return
$pages;
73
}
74
80
public
function
getGroup
() {
81
return
'user'
;
82
}
83
}
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition
ResourceLoaderContext.php:33
ResourceLoaderModule\getConfig
getConfig()
Definition
ResourceLoaderModule.php:200
ResourceLoaderModule\$config
Config $config
Definition
ResourceLoaderModule.php:39
ResourceLoaderUserModule
Module for user customizations scripts.
Definition
ResourceLoaderUserModule.php:29
ResourceLoaderUserModule\getGroup
getGroup()
Get group name.
Definition
ResourceLoaderUserModule.php:80
ResourceLoaderUserModule\$targets
$targets
Definition
ResourceLoaderUserModule.php:32
ResourceLoaderUserModule\$origin
$origin
Definition
ResourceLoaderUserModule.php:31
ResourceLoaderUserModule\getPages
getPages(ResourceLoaderContext $context)
Definition
ResourceLoaderUserModule.php:38
ResourceLoaderWikiModule
Abstraction for ResourceLoader modules which pull from wiki pages.
Definition
ResourceLoaderWikiModule.php:53
ResourceLoaderWikiModule\$group
$group
Definition
ResourceLoaderWikiModule.php:80
Config\get
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
$context
$context
Definition
load.php:45
includes
resourceloader
ResourceLoaderUserModule.php
Generated on Mon Nov 25 2024 16:05:38 for MediaWiki by
1.10.0