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 $tempUserConfig = MediaWikiServices::getInstance()->getTempUserConfig();
46 if ( !$user || !$user->isRegistered() || $tempUserConfig->isTempName( $user->getName() ) ) {
47 return [];
48 }
49
50 $config = $this->getConfig();
51 $pages = [];
52
54 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
55 // Use localised/normalised variant to ensure $excludepage matches
56 $userPage = $titleFormatter->getPrefixedDBkey( new TitleValue( NS_USER, $user->getName() ) );
57 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
58 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
59 }
60
61 // User group pages are maintained site-wide and enabled with site JS/CSS.
63 $effectiveGroups = MediaWikiServices::getInstance()->getUserGroupManager()
64 ->getUserEffectiveGroups( $user );
65 foreach ( $effectiveGroups as $group ) {
66 if ( $group == '*' ) {
67 continue;
68 }
69 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
70 }
71 }
72
73 return $pages;
74 }
75
79 public function getType() {
80 return self::LOAD_STYLES;
81 }
82
88 public function getGroup() {
89 return self::GROUP_USER;
90 }
91}
const NS_USER
Definition Defines.php:67
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.".