(maintenance/fixDoubleRedirects.php)
* (bug 23315) New body classes to allow easier styling of special pages
* (bug 27159) Make email confirmation code expiration time configurable
+* CSS/JS for each user group is imported from MediaWiki:Sysop.js,
+ MediaWiki:Autoconfirmed.css, etc.
=== Bug fixes in 1.18 ===
* (bug 23119) WikiError class and subclasses are now marked as deprecated
'ResourceLoaderFileModule' => 'includes/resourceloader/ResourceLoaderFileModule.php',
'ResourceLoaderSiteModule' => 'includes/resourceloader/ResourceLoaderSiteModule.php',
'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php',
+ 'ResourceLoaderUserGroupsModule' => 'includes/resourceloader/ResourceLoaderUserGroupsModule.php',
'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php',
'ResourceLoaderStartUpModule' => 'includes/resourceloader/ResourceLoaderStartUpModule.php',
'ReverseChronologicalPager' => 'includes/Pager.php',
// Legacy Scripts
$scripts .= "\n" . $this->mScripts;
+ $userScripts = array( 'user.options' );
+
// Add site JS if enabled
if ( $wgUseSiteJs ) {
$scripts .= $this->makeResourceLoaderLink( $sk, 'site', ResourceLoaderModule::TYPE_SCRIPTS );
+ if( $wgUser->isLoggedIn() ){
+ $userScripts[] = 'user.groups';
+ }
}
- // Add user JS if enabled - trying to load user.options as a bundle if possible
- $userOptionsAdded = false;
+ // Add user JS if enabled
if ( $wgAllowUserJs && $wgUser->isLoggedIn() ) {
$action = $wgRequest->getVal( 'action', 'view' );
if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) {
# XXX: additional security check/prompt?
$scripts .= Html::inlineScript( "\n" . $wgRequest->getText( 'wpTextbox1' ) . "\n" ) . "\n";
} else {
- $scripts .= $this->makeResourceLoaderLink(
- $sk, array( 'user', 'user.options' ), ResourceLoaderModule::TYPE_SCRIPTS
- );
- $userOptionsAdded = true;
+ # FIXME: this means that User:Me/Common.js doesn't load when previewing
+ # User:Me/Vector.js, and vice versa (bug26283)
+ $userScripts[] = 'user';
}
}
- if ( !$userOptionsAdded ) {
- $scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', ResourceLoaderModule::TYPE_SCRIPTS );
- }
+ $scripts .= $this->makeResourceLoaderLink( $sk, $userScripts, ResourceLoaderModule::TYPE_SCRIPTS );
return $scripts;
}
* @private
*/
function setupUserCss( OutputPage $out ) {
- global $wgRequest;
+ global $wgRequest, $wgUser;
global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
wfProfileIn( __METHOD__ );
// Per-site custom styles
if ( $wgUseSiteCss ) {
$out->addModuleStyles( 'site' );
+ if( $wgUser->isLoggedIn() ){
+ $out->addModuleStyles( 'user.groups' );
+ }
}
// Per-user custom styles
--- /dev/null
+<?php
+/**
+ * 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
+ * @author Trevor Parscal
+ * @author Roan Kattouw
+ */
+
+/**
+ * Module for user customizations
+ */
+class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule {
+
+ /* Protected Methods */
+ protected $origin = self::ORIGIN_USER_SITEWIDE;
+
+ protected function getPages( ResourceLoaderContext $context ) {
+ if ( $context->getUser() ) {
+ $user = User::newFromName( $context->getUser() );
+ if( $user instanceof User ){
+ $pages = array();
+ foreach( $user->getEffectiveGroups() as $group ){
+ if( in_array( $group, array( '*', 'user' ) ) ){
+ continue;
+ }
+ $g = ucfirst( $group );
+ $pages["MediaWiki:$g.js"] = array( 'type' => 'script' );
+ $pages["MediaWiki:$g.css"] = array( 'type' => 'style' );
+ }
+ return $pages;
+ }
+ }
+ return array();
+ }
+
+ /* Methods */
+
+ public function getGroup() {
+ return 'user';
+ }
+
+ public function getFlip( $context ) {
+ global $wgContLang;
+
+ return $wgContLang->getDir() !== $context->getDirection();
+ }
+}
'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ),
'user' => array( 'class' => 'ResourceLoaderUserModule' ),
'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ),
+ 'user.groups' => array( 'class' => 'ResourceLoaderUserGroupsModule' ),
/* Skins */