3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
19 * @author Trevor Parscal
20 * @author Roan Kattouw
24 * Module for user customizations styles.
26 * @ingroup ResourceLoader
29 class ResourceLoaderUserStylesModule
extends ResourceLoaderWikiModule
{
31 protected $origin = self
::ORIGIN_USER_INDIVIDUAL
;
32 protected $targets = [ 'desktop', 'mobile' ];
35 * @param ResourceLoaderContext $context
36 * @return array List of pages
38 protected function getPages( ResourceLoaderContext
$context ) {
39 $config = $this->getConfig();
40 $user = $context->getUserObj();
41 if ( $user->isAnon() ) {
45 // Use localised/normalised variant to ensure $excludepage matches
46 $userPage = $user->getUserPage()->getPrefixedDBkey();
49 if ( $config->get( 'AllowUserCss' ) ) {
50 $pages["$userPage/common.css"] = [ 'type' => 'style' ];
51 $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
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 == '*' ) {
60 $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
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] );
78 public function getType() {
79 return self
::LOAD_STYLES
;
87 public function getGroup() {