Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2300,7 +2300,7 @@ |
2301 | 2301 | sort( $modules ); |
2302 | 2302 | $query['modules'] = implode( '|', array_unique( (array) $modules ) ); |
2303 | 2303 | if ( $group === 'user' ) { |
2304 | | - $query['user'] = $wgUser->getName(); |
| 2304 | + $query['user'] = $wgUser->isLoggedIn() ? $wgUser->getName() : null; |
2305 | 2305 | } |
2306 | 2306 | // Users might change their stuff on-wiki like site or user pages, or user preferences; we need to find |
2307 | 2307 | // the highest timestamp of these user-changable modules so we can ensure cache misses upon change |
— | — | @@ -2382,16 +2382,21 @@ |
2383 | 2383 | ); |
2384 | 2384 | } |
2385 | 2385 | |
2386 | | - // Add user JS if enabled |
2387 | | - if( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) { |
| 2386 | + // Add user JS if enabled - trying to load user.options as a bundle if possible |
| 2387 | + $userOptionsAdded = false; |
| 2388 | + if ( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) { |
2388 | 2389 | $action = $wgRequest->getVal( 'action', 'view' ); |
2389 | 2390 | if( $this->mTitle && $this->mTitle->isJsSubpage() && $sk->userCanPreview( $action ) ) { |
2390 | 2391 | # XXX: additional security check/prompt? |
2391 | 2392 | $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) ); |
2392 | 2393 | } else { |
2393 | | - $scripts .= self::makeResourceLoaderLink( $sk, 'user', 'scripts' ); |
| 2394 | + $scripts .= self::makeResourceLoaderLink( $sk, array( 'user', 'user.options' ), 'scripts' ); |
| 2395 | + $userOptionsAdded = true; |
2394 | 2396 | } |
2395 | 2397 | } |
| 2398 | + if ( !$userOptionsAdded ) { |
| 2399 | + $scripts .= self::makeResourceLoaderLink( $sk, 'user.options', 'scripts' ); |
| 2400 | + } |
2396 | 2401 | $scripts .= "\n" . $this->mScripts; |
2397 | 2402 | |
2398 | 2403 | // Add site JS if enabled |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -203,6 +203,8 @@ |
204 | 204 | 'ResourceLoaderWikiModule' => 'includes/ResourceLoaderModule.php', |
205 | 205 | 'ResourceLoaderFileModule' => 'includes/ResourceLoaderModule.php', |
206 | 206 | 'ResourceLoaderSiteModule' => 'includes/ResourceLoaderModule.php', |
| 207 | + 'ResourceLoaderUserModule' => 'includes/ResourceLoaderModule.php', |
| 208 | + 'ResourceLoaderUserOptionsModule' => 'includes/ResourceLoaderModule.php', |
207 | 209 | 'ResourceLoaderStartUpModule' => 'includes/ResourceLoaderModule.php', |
208 | 210 | 'ReverseChronologicalPager' => 'includes/Pager.php', |
209 | 211 | 'Revision' => 'includes/Revision.php', |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -516,7 +516,7 @@ |
517 | 517 | |
518 | 518 | // Per-user preference styles |
519 | 519 | if ( $wgAllowUserCssPrefs ) { |
520 | | - $out->addModuleStyles( 'user.preferences' ); |
| 520 | + $out->addModuleStyles( 'user.options' ); |
521 | 521 | } |
522 | 522 | |
523 | 523 | wfProfileOut( __METHOD__ ); |
Index: trunk/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -813,7 +813,7 @@ |
814 | 814 | /** |
815 | 815 | * Module for user preference customizations |
816 | 816 | */ |
817 | | -class ResourceLoaderUserPreferencesModule extends ResourceLoaderModule { |
| 817 | +class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { |
818 | 818 | |
819 | 819 | /* Protected Members */ |
820 | 820 | |
— | — | @@ -839,40 +839,44 @@ |
840 | 840 | } |
841 | 841 | } |
842 | 842 | |
| 843 | + public function getScript( ResourceLoaderContext $context ) { |
| 844 | + $user = User::newFromName( $context->getUser() ); |
| 845 | + $options = FormatJson::encode( $user instanceof User ? $user->getOptions() : User::getDefaultOptions() ); |
| 846 | + return "mediaWiki.user.options.set( $options );"; |
| 847 | + } |
| 848 | + |
843 | 849 | public function getStyles( ResourceLoaderContext $context ) { |
844 | 850 | global $wgAllowUserCssPrefs; |
845 | 851 | if ( $wgAllowUserCssPrefs ) { |
846 | 852 | $user = User::newFromName( $context->getUser() ); |
847 | | - if ( $user === false ) { |
848 | | - $user = User::newFromId( 0 ); |
849 | | - } |
850 | | - |
| 853 | + $options = $user instanceof User ? $user->getOptions() : User::getDefaultOptions(); |
| 854 | + |
851 | 855 | $rules = array(); |
852 | | - if ( ( $underline = $user->getOption( 'underline' ) ) < 2 ) { |
853 | | - $rules[] = "a { text-decoration: " . ( $underline ? 'underline' : 'none' ) . "; }"; |
| 856 | + if ( $options['underline'] < 2 ) { |
| 857 | + $rules[] = "a { text-decoration: " . ( $options['underline'] ? 'underline' : 'none' ) . "; }"; |
854 | 858 | } |
855 | | - if ( $user->getOption( 'highlightbroken' ) ) { |
| 859 | + if ( $options['highlightbroken'] ) { |
856 | 860 | $rules[] = "a.new, #quickbar a.new { color: #CC2200; }\n"; |
857 | 861 | } else { |
858 | 862 | $rules[] = "a.new, #quickbar a.new, a.stub, #quickbar a.stub { color: inherit; }"; |
859 | 863 | $rules[] = "a.new:after, #quickbar a.new:after { content: '?'; color: #CC2200; }"; |
860 | 864 | $rules[] = "a.stub:after, #quickbar a.stub:after { content: '!'; color: #772233; }"; |
861 | 865 | } |
862 | | - if ( $user->getOption( 'justify' ) ) { |
| 866 | + if ( $options['justify'] ) { |
863 | 867 | $rules[] = "#article, #bodyContent, #mw_content { text-align: justify; }\n"; |
864 | 868 | } |
865 | | - if ( !$user->getOption( 'showtoc' ) ) { |
| 869 | + if ( !$options['showtoc'] ) { |
866 | 870 | $rules[] = "#toc { display: none; }\n"; |
867 | 871 | } |
868 | | - if ( !$user->getOption( 'editsection' ) ) { |
| 872 | + if ( !$options['editsection'] ) { |
869 | 873 | $rules[] = ".editsection { display: none; }\n"; |
870 | 874 | } |
871 | | - if ( ( $fontstyle = $user->getOption( 'editfont' ) ) !== 'default' ) { |
872 | | - $rules[] = "textarea { font-family: $fontstyle; }\n"; |
| 875 | + if ( $options['editfont'] !== 'default' ) { |
| 876 | + $rules[] = "textarea { font-family: {$options['editfont']}; }\n"; |
873 | 877 | } |
874 | 878 | return array( 'all' => implode( "\n", $rules ) ); |
875 | 879 | } |
876 | | - return array(); |
| 880 | + return array( 'all' => 'test { color: pink; }' ); |
877 | 881 | } |
878 | 882 | |
879 | 883 | public function getFlip( $context ) { |