Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2555,28 +2555,29 @@ |
2556 | 2556 | // Legacy Scripts |
2557 | 2557 | $scripts .= "\n" . $this->mScripts; |
2558 | 2558 | |
| 2559 | + $userScripts = array( 'user.options' ); |
| 2560 | + |
2559 | 2561 | // Add site JS if enabled |
2560 | 2562 | if ( $wgUseSiteJs ) { |
2561 | 2563 | $scripts .= $this->makeResourceLoaderLink( $sk, 'site', ResourceLoaderModule::TYPE_SCRIPTS ); |
| 2564 | + if( $wgUser->isLoggedIn() ){ |
| 2565 | + $userScripts[] = 'user.groups'; |
| 2566 | + } |
2562 | 2567 | } |
2563 | 2568 | |
2564 | | - // Add user JS if enabled - trying to load user.options as a bundle if possible |
2565 | | - $userOptionsAdded = false; |
| 2569 | + // Add user JS if enabled |
2566 | 2570 | if ( $wgAllowUserJs && $wgUser->isLoggedIn() ) { |
2567 | 2571 | $action = $wgRequest->getVal( 'action', 'view' ); |
2568 | 2572 | if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) { |
2569 | 2573 | # XXX: additional security check/prompt? |
2570 | 2574 | $scripts .= Html::inlineScript( "\n" . $wgRequest->getText( 'wpTextbox1' ) . "\n" ) . "\n"; |
2571 | 2575 | } else { |
2572 | | - $scripts .= $this->makeResourceLoaderLink( |
2573 | | - $sk, array( 'user', 'user.options' ), ResourceLoaderModule::TYPE_SCRIPTS |
2574 | | - ); |
2575 | | - $userOptionsAdded = true; |
| 2576 | + # FIXME: this means that User:Me/Common.js doesn't load when previewing |
| 2577 | + # User:Me/Vector.js, and vice versa (bug26283) |
| 2578 | + $userScripts[] = 'user'; |
2576 | 2579 | } |
2577 | 2580 | } |
2578 | | - if ( !$userOptionsAdded ) { |
2579 | | - $scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', ResourceLoaderModule::TYPE_SCRIPTS ); |
2580 | | - } |
| 2581 | + $scripts .= $this->makeResourceLoaderLink( $sk, $userScripts, ResourceLoaderModule::TYPE_SCRIPTS ); |
2581 | 2582 | |
2582 | 2583 | return $scripts; |
2583 | 2584 | } |
Index: trunk/phase3/includes/resourceloader/ResourceLoaderUserGroupsModule.php |
— | — | @@ -0,0 +1,61 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | + * http://www.gnu.org/copyleft/gpl.html |
| 18 | + * |
| 19 | + * @file |
| 20 | + * @author Trevor Parscal |
| 21 | + * @author Roan Kattouw |
| 22 | + */ |
| 23 | + |
| 24 | +/** |
| 25 | + * Module for user customizations |
| 26 | + */ |
| 27 | +class ResourceLoaderUserGroupsModule extends ResourceLoaderWikiModule { |
| 28 | + |
| 29 | + /* Protected Methods */ |
| 30 | + protected $origin = self::ORIGIN_USER_SITEWIDE; |
| 31 | + |
| 32 | + protected function getPages( ResourceLoaderContext $context ) { |
| 33 | + if ( $context->getUser() ) { |
| 34 | + $user = User::newFromName( $context->getUser() ); |
| 35 | + if( $user instanceof User ){ |
| 36 | + $pages = array(); |
| 37 | + foreach( $user->getEffectiveGroups() as $group ){ |
| 38 | + if( in_array( $group, array( '*', 'user' ) ) ){ |
| 39 | + continue; |
| 40 | + } |
| 41 | + $g = ucfirst( $group ); |
| 42 | + $pages["MediaWiki:$g.js"] = array( 'type' => 'script' ); |
| 43 | + $pages["MediaWiki:$g.css"] = array( 'type' => 'style' ); |
| 44 | + } |
| 45 | + return $pages; |
| 46 | + } |
| 47 | + } |
| 48 | + return array(); |
| 49 | + } |
| 50 | + |
| 51 | + /* Methods */ |
| 52 | + |
| 53 | + public function getGroup() { |
| 54 | + return 'user'; |
| 55 | + } |
| 56 | + |
| 57 | + public function getFlip( $context ) { |
| 58 | + global $wgContLang; |
| 59 | + |
| 60 | + return $wgContLang->getDir() !== $context->getDirection(); |
| 61 | + } |
| 62 | +} |
Property changes on: trunk/phase3/includes/resourceloader/ResourceLoaderUserGroupsModule.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 63 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -211,6 +211,7 @@ |
212 | 212 | 'ResourceLoaderFileModule' => 'includes/resourceloader/ResourceLoaderFileModule.php', |
213 | 213 | 'ResourceLoaderSiteModule' => 'includes/resourceloader/ResourceLoaderSiteModule.php', |
214 | 214 | 'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php', |
| 215 | + 'ResourceLoaderUserGroupsModule' => 'includes/resourceloader/ResourceLoaderUserGroupsModule.php', |
215 | 216 | 'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php', |
216 | 217 | 'ResourceLoaderStartUpModule' => 'includes/resourceloader/ResourceLoaderStartUpModule.php', |
217 | 218 | 'ReverseChronologicalPager' => 'includes/Pager.php', |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -546,7 +546,7 @@ |
547 | 547 | * @private |
548 | 548 | */ |
549 | 549 | function setupUserCss( OutputPage $out ) { |
550 | | - global $wgRequest; |
| 550 | + global $wgRequest, $wgUser; |
551 | 551 | global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs; |
552 | 552 | |
553 | 553 | wfProfileIn( __METHOD__ ); |
— | — | @@ -560,6 +560,9 @@ |
561 | 561 | // Per-site custom styles |
562 | 562 | if ( $wgUseSiteCss ) { |
563 | 563 | $out->addModuleStyles( 'site' ); |
| 564 | + if( $wgUser->isLoggedIn() ){ |
| 565 | + $out->addModuleStyles( 'user.groups' ); |
| 566 | + } |
564 | 567 | } |
565 | 568 | |
566 | 569 | // Per-user custom styles |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -72,6 +72,8 @@ |
73 | 73 | (maintenance/fixDoubleRedirects.php) |
74 | 74 | * (bug 23315) New body classes to allow easier styling of special pages |
75 | 75 | * (bug 27159) Make email confirmation code expiration time configurable |
| 76 | +* CSS/JS for each user group is imported from MediaWiki:Sysop.js, |
| 77 | + MediaWiki:Autoconfirmed.css, etc. |
76 | 78 | |
77 | 79 | === Bug fixes in 1.18 === |
78 | 80 | * (bug 23119) WikiError class and subclasses are now marked as deprecated |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | 'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ), |
10 | 10 | 'user' => array( 'class' => 'ResourceLoaderUserModule' ), |
11 | 11 | 'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ), |
| 12 | + 'user.groups' => array( 'class' => 'ResourceLoaderUserGroupsModule' ), |
12 | 13 | |
13 | 14 | /* Skins */ |
14 | 15 | |