MediaWiki REL1_37
ResourceLoaderUserStylesModule.php
Go to the documentation of this file.
1<?php
24
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}
MediaWikiServices is the service locator for the application scope of MediaWiki.
Context object that contains information about the state of a specific ResourceLoader web request.
getUserObj()
Get the possibly-cached User object for the specified username.
Module for user customizations styles.
getPages(ResourceLoaderContext $context)
Abstraction for ResourceLoader modules which pull from wiki pages.
string null $group
Group of module.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".