MediaWiki master
UserStylesModule.php
Go to the documentation of this file.
1<?php
24
28
36
37 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
38
43 protected function getPages( Context $context ) {
44 $user = $context->getUserIdentity();
45 if ( !$user || !$user->isRegistered() ) {
46 return [];
47 }
48
49 $config = $this->getConfig();
50 $pages = [];
51
53 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
54 // Use localised/normalised variant to ensure $excludepage matches
55 $userPage = $titleFormatter->getPrefixedDBkey( new TitleValue( NS_USER, $user->getName() ) );
56 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
57 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
58 }
59
60 // User group pages are maintained site-wide and enabled with site JS/CSS.
62 $effectiveGroups = MediaWikiServices::getInstance()->getUserGroupManager()
63 ->getUserEffectiveGroups( $user );
64 foreach ( $effectiveGroups as $group ) {
65 if ( $group == '*' ) {
66 continue;
67 }
68 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
69 }
70 }
71
72 return $pages;
73 }
74
78 public function getType() {
79 return self::LOAD_STYLES;
80 }
81
87 public function getGroup() {
88 return self::GROUP_USER;
89 }
90}
const NS_USER
Definition Defines.php:66
A class containing constants representing the names of configuration variables.
const UseSiteCss
Name constant for the UseSiteCss setting, for use with Config::get()
const AllowUserCss
Name constant for the AllowUserCss setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Context object that contains information about the state of a specific ResourceLoader web request.
Definition Context.php:45
getUserIdentity()
Get the possibly-cached UserIdentity object for the specified username.
Definition Context.php:278
Module for user customizations styles.
Abstraction for ResourceLoader modules which pull from wiki pages.
string null $group
Group of module.
Represents the target of a wiki link.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".