MediaWiki master
UserStylesModule.php
Go to the documentation of this file.
1<?php
24
28
36
38 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
39
44 protected function getPages( Context $context ) {
45 $user = $context->getUserIdentity();
46 $tempUserConfig = MediaWikiServices::getInstance()->getTempUserConfig();
47 if ( !$user || !$user->isRegistered() || $tempUserConfig->isTempName( $user->getName() ) ) {
48 return [];
49 }
50
51 $config = $this->getConfig();
52 $pages = [];
53
55 $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
56 // Use localised/normalised variant to ensure $excludepage matches
57 $userPage = $titleFormatter->getPrefixedDBkey( new TitleValue( NS_USER, $user->getName() ) );
58 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
59 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
60 }
61
62 // User group pages are maintained site-wide and enabled with site JS/CSS.
64 $effectiveGroups = MediaWikiServices::getInstance()->getUserGroupManager()
65 ->getUserEffectiveGroups( $user );
66 foreach ( $effectiveGroups as $group ) {
67 if ( $group == '*' ) {
68 continue;
69 }
70 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
71 }
72 }
73
74 return $pages;
75 }
76
80 public function getType() {
81 return self::LOAD_STYLES;
82 }
83
89 public function getGroup() {
90 return self::GROUP_USER;
91 }
92}
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:46
getUserIdentity()
Get the possibly-cached UserIdentity object for the specified username.
Definition Context.php:284
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.".