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