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