MediaWiki REL1_34
ResourceLoaderUserStylesModule.php
Go to the documentation of this file.
1<?php
30
31 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
32 protected $targets = [ 'desktop', 'mobile' ];
33
38 protected function getPages( ResourceLoaderContext $context ) {
39 $config = $this->getConfig();
40 $user = $context->getUserObj();
41 if ( $user->isAnon() ) {
42 return [];
43 }
44
45 // Use localised/normalised variant to ensure $excludepage matches
46 $userPage = $user->getUserPage()->getPrefixedDBkey();
47 $pages = [];
48
49 if ( $config->get( 'AllowUserCss' ) ) {
50 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
51 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
52 }
53
54 // User group pages are maintained site-wide and enabled with site JS/CSS.
55 if ( $config->get( 'UseSiteCss' ) ) {
56 foreach ( $user->getEffectiveGroups() as $group ) {
57 if ( $group == '*' ) {
58 continue;
59 }
60 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
61 }
62 }
63
64 // This is obsolete since 1.32 (T112474). It was formerly used by
65 // OutputPage to implement previewing of user CSS and JS.
66 // @todo: Remove it once we're sure nothing else is using the parameter
67 $excludepage = $context->getRequest()->getVal( 'excludepage' );
68 if ( isset( $pages[$excludepage] ) ) {
69 unset( $pages[$excludepage] );
70 }
71
72 return $pages;
73 }
74
78 public function getType() {
79 return self::LOAD_STYLES;
80 }
81
87 public function getGroup() {
88 return 'user';
89 }
90}
Context object that contains information about the state of a specific ResourceLoader web request.
Module for user customizations styles.
getPages(ResourceLoaderContext $context)
Abstraction for ResourceLoader modules which pull from wiki pages.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
$context
Definition load.php:45