Index: trunk/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -915,28 +915,34 @@ |
916 | 916 | } |
917 | 917 | } |
918 | 918 | |
919 | | - public function getScript( ResourceLoaderContext $context ) { |
| 919 | + /** |
| 920 | + * Fetch the context's user options, or if it doesn't match current user, |
| 921 | + * the default options. |
| 922 | + * |
| 923 | + * @param ResourceLoaderContext $context |
| 924 | + * @return array |
| 925 | + */ |
| 926 | + protected function contextUserOptions( ResourceLoaderContext $context ) { |
920 | 927 | global $wgUser; |
921 | 928 | |
922 | 929 | // Verify identity -- this is a private module |
923 | 930 | if ( $context->getUser() === $wgUser->getName() ) { |
924 | | - $options = FormatJson::encode( $wgUser->getOptions() ); |
| 931 | + return $wgUser->getOptions(); |
925 | 932 | } else { |
926 | | - $options = FormatJson::encode( User::getDefaultOptions() ); |
| 933 | + return User::getDefaultOptions(); |
927 | 934 | } |
928 | | - return "mediaWiki.user.options.set( $options );"; |
929 | 935 | } |
930 | 936 | |
| 937 | + public function getScript( ResourceLoaderContext $context ) { |
| 938 | + $encOptions = FormatJson::encode( $this->contextUserOptions( $context ) ); |
| 939 | + return "mediaWiki.user.options.set( $encOptions );"; |
| 940 | + } |
| 941 | + |
931 | 942 | public function getStyles( ResourceLoaderContext $context ) { |
932 | | - global $wgUser, $wgAllowUserCssPrefs; |
| 943 | + global $wgAllowUserCssPrefs; |
933 | 944 | |
934 | 945 | if ( $wgAllowUserCssPrefs ) { |
935 | | - // Verify identity -- this is a private module |
936 | | - if ( $context->getUser() === $wgUser->getName() ) { |
937 | | - $options = $wgUser->getOptions(); |
938 | | - } else { |
939 | | - $options = User::getDefaultOptions(); |
940 | | - } |
| 946 | + $options = $this->contextUserOptions( $context ); |
941 | 947 | |
942 | 948 | // Build CSS rules |
943 | 949 | $rules = array(); |