MediaWiki master
UserStylesModule.php
Go to the documentation of this file.
1<?php
10
14
22
24 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
25
30 protected function getPages( Context $context ) {
31 $user = $context->getUserIdentity();
32 $tempUserConfig = MediaWikiServices::getInstance()->getTempUserConfig();
33 if ( !$user || !$user->isRegistered() || $tempUserConfig->isTempName( $user->getName() ) ) {
34 return [];
35 }
36
37 $config = $this->getConfig();
38 $pages = [];
39
41 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
42 // Use localised/normalised variant to ensure $excludepage matches
43 $userPage = $titleFormatter->getPrefixedDBkey( new TitleValue( NS_USER, $user->getName() ) );
44 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
45 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
46 }
47
48 // User group pages are maintained site-wide and enabled with site JS/CSS.
50 $effectiveGroups = MediaWikiServices::getInstance()->getUserGroupManager()
51 ->getUserEffectiveGroups( $user );
52 foreach ( $effectiveGroups as $group ) {
53 if ( $group == '*' ) {
54 continue;
55 }
56 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
57 }
58 }
59
60 return $pages;
61 }
62
66 public function getType() {
67 return self::LOAD_STYLES;
68 }
69
75 public function getGroup() {
76 return self::GROUP_USER;
77 }
78}
const NS_USER
Definition Defines.php:53
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:32
getUserIdentity()
Get the possibly-cached UserIdentity object for the specified username.
Definition Context.php:255
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.".