MediaWiki
REL1_37
ResourceLoaderUserStylesModule.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\MediaWikiServices
;
24
31
class
ResourceLoaderUserStylesModule
extends
ResourceLoaderWikiModule
{
32
33
protected
$origin
= self::ORIGIN_USER_INDIVIDUAL;
34
protected
$targets
= [
'desktop'
,
'mobile'
];
35
40
protected
function
getPages
(
ResourceLoaderContext
$context ) {
41
$config
= $this->
getConfig
();
42
$user = $context->
getUserObj
();
43
if
( $user->isAnon() ) {
44
return
[];
45
}
46
47
// Use localised/normalised variant to ensure $excludepage matches
48
$userPage = $user->getUserPage()->getPrefixedDBkey();
49
$pages = [];
50
51
if
(
$config
->
get
(
'AllowUserCss'
) ) {
52
$pages[
"$userPage/common.css"
] = [
'type'
=>
'style'
];
53
$pages[
"$userPage/"
. $context->
getSkin
() .
'.css'
] = [
'type'
=>
'style'
];
54
}
55
56
// User group pages are maintained site-wide and enabled with site JS/CSS.
57
if
(
$config
->
get
(
'UseSiteCss'
) ) {
58
$effectiveGroups = MediaWikiServices::getInstance()->getUserGroupManager()
59
->getUserEffectiveGroups( $user );
60
foreach
( $effectiveGroups as
$group
) {
61
if
(
$group
==
'*'
) {
62
continue
;
63
}
64
$pages[
"MediaWiki:Group-$group.css"
] = [
'type'
=>
'style'
];
65
}
66
}
67
68
// This is obsolete since 1.32 (T112474). It was formerly used by
69
// OutputPage to implement previewing of user CSS and JS.
70
// @todo: Remove it once we're sure nothing else is using the parameter
71
$excludepage = $context->
getRequest
()->getVal(
'excludepage'
);
72
unset( $pages[$excludepage] );
73
74
return
$pages;
75
}
76
80
public
function
getType
() {
81
return
self::LOAD_STYLES;
82
}
83
89
public
function
getGroup
() {
90
return
'user'
;
91
}
92
}
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
ResourceLoaderUserStylesModule
Module for user customizations styles.
Definition
ResourceLoaderUserStylesModule.php:31
ResourceLoaderUserStylesModule\$origin
$origin
Definition
ResourceLoaderUserStylesModule.php:33
ResourceLoaderUserStylesModule\getGroup
getGroup()
Get group name.
Definition
ResourceLoaderUserStylesModule.php:89
ResourceLoaderUserStylesModule\$targets
$targets
Definition
ResourceLoaderUserStylesModule.php:34
ResourceLoaderUserStylesModule\getType
getType()
Definition
ResourceLoaderUserStylesModule.php:80
ResourceLoaderUserStylesModule\getPages
getPages(ResourceLoaderContext $context)
Definition
ResourceLoaderUserStylesModule.php:40
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
ResourceLoaderUserStylesModule.php
Generated on Fri Apr 5 2024 23:40:45 for MediaWiki by
1.9.8