'ResourceLoaderUploadDialogModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUploadDialogModule.php',
'ResourceLoaderUserCSSPrefsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php',
'ResourceLoaderUserDefaultsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserDefaultsModule.php',
- 'ResourceLoaderUserGroupsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserGroupsModule.php',
'ResourceLoaderUserModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserModule.php',
'ResourceLoaderUserOptionsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserOptionsModule.php',
'ResourceLoaderUserTokensModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserTokensModule.php',
$links[] = $this->makeResourceLoaderLink( 'user', ResourceLoaderModule::TYPE_COMBINED );
}
- // Group JS is only enabled if site JS is enabled.
- $links[] = $this->makeResourceLoaderLink(
- 'user.groups',
- ResourceLoaderModule::TYPE_COMBINED
- );
-
return self::getHtmlFromLoaderLinks( $links );
}
// Per-site custom styles
$moduleStyles[] = 'site';
$moduleStyles[] = 'noscript';
- $moduleStyles[] = 'user.groups';
// Per-user custom styles
if ( $this->getConfig()->get( 'AllowUserCss' ) && $this->getTitle()->isCssSubpage()
+++ /dev/null
-<?php
-/**
- * ResourceLoader module for user customizations.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-/**
- * Module for user customizations
- */
-class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule {
-
- protected $origin = self::ORIGIN_USER_SITEWIDE;
- protected $targets = [ 'desktop', 'mobile' ];
-
- /**
- * @param ResourceLoaderContext $context
- * @return array
- */
- protected function getPages( ResourceLoaderContext $context ) {
- $useSiteJs = $this->getConfig()->get( 'UseSiteJs' );
- $useSiteCss = $this->getConfig()->get( 'UseSiteCss' );
- if ( !$useSiteJs && !$useSiteCss ) {
- return [];
- }
-
- $user = $context->getUserObj();
- if ( $user->isAnon() ) {
- return [];
- }
-
- $pages = [];
- foreach ( $user->getEffectiveGroups() as $group ) {
- if ( $group == '*' ) {
- continue;
- }
- if ( $useSiteJs ) {
- $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
- }
- if ( $useSiteCss ) {
- $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
- }
- }
- return $pages;
- }
-
- /**
- * Get group name
- *
- * @return string
- */
- public function getGroup() {
- return 'user';
- }
-}
class ResourceLoaderUserModule extends ResourceLoaderWikiModule {
protected $origin = self::ORIGIN_USER_INDIVIDUAL;
+ protected $targets = [ 'desktop', 'mobile' ];
/**
* Get list of pages used by this module
* @return array List of pages
*/
protected function getPages( ResourceLoaderContext $context ) {
- $allowUserJs = $this->getConfig()->get( 'AllowUserJs' );
- $allowUserCss = $this->getConfig()->get( 'AllowUserCss' );
- if ( !$allowUserJs && !$allowUserCss ) {
- return [];
- }
-
+ $config = $this->getConfig();
$user = $context->getUserObj();
if ( $user->isAnon() ) {
return [];
}
- // Needed so $excludepages works
+ // Use localised/normalised variant to ensure $excludepage matches
$userPage = $user->getUserPage()->getPrefixedDBkey();
-
$pages = [];
- if ( $allowUserJs ) {
+
+ if ( $config->get( 'AllowUserJs' ) ) {
$pages["$userPage/common.js"] = [ 'type' => 'script' ];
$pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
}
- if ( $allowUserCss ) {
+
+ if ( $config->get( 'AllowUserCss' ) ) {
$pages["$userPage/common.css"] = [ 'type' => 'style' ];
$pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ];
}
+ $useSiteJs = $config->get( 'UseSiteJs' );
+ $useSiteCss = $config->get( 'UseSiteCss' );
+ // User group pages are maintained site-wide and enabled with site JS/CSS.
+ if ( $useSiteJs || $useSiteCss ) {
+ foreach ( $user->getEffectiveGroups() as $group ) {
+ if ( $group == '*' ) {
+ continue;
+ }
+ if ( $useSiteJs ) {
+ $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
+ }
+ if ( $useSiteCss ) {
+ $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ];
+ }
+ }
+ }
+
// Hack for bug 26283: if we're on a preview page for a CSS/JS page,
// we need to exclude that page from this module. In that case, the excludepage
// parameter will be set to the name of the page we need to exclude.
// just like the keys in $pages[] above
unset( $pages[$excludepage] );
}
+
return $pages;
}
'class' => 'ResourceLoaderWikiModule',
'styles' => [ 'MediaWiki:Filepage.css' ],
],
- 'user.groups' => [ 'class' => 'ResourceLoaderUserGroupsModule' ],
+ 'user.groups' => [
+ // Merged into 'user' since MediaWiki 1.28 - kept for back-compat
+ 'dependencies' => 'user',
+ 'targets' => [ 'desktop', 'mobile' ],
+ ],
// Scripts managed by the current user (stored in their user space)
'user' => [ 'class' => 'ResourceLoaderUserModule' ],