Index: trunk/extensions/LanguageSelector/LanguageSelector.php |
— | — | @@ -45,7 +45,6 @@ |
46 | 46 | /** |
47 | 47 | * Languages to offer in the language selector. Per default, this includes all languages MediaWiki knows |
48 | 48 | * about by virtue of $wgLanguageNames. A shorter list may be more usable, though. |
49 | | -* If the Polyglot extension is installed, $wgPolyglotLanguages is used as fallback. |
50 | 49 | */ |
51 | 50 | $wgLanguageSelectorLanguages = null; |
52 | 51 | |
— | — | @@ -87,10 +86,10 @@ |
88 | 87 | $dir = dirname(__FILE__) . '/'; |
89 | 88 | $wgExtensionMessagesFiles['LanguageSelector'] = $dir . 'LanguageSelector.i18n.php'; |
90 | 89 | $wgJSAutoloadClasses['LanguageSelector'] = 'extensions/LanguageSelector/LanguageSelector.js'; |
| 90 | +$wgAutoloadClasses['StubAutoLang'] = $dir . 'StubAutoLang.php'; |
91 | 91 | |
92 | | -function wfLanguageSelectorSetHook() { |
93 | | - global $wgParser; |
94 | | - $wgParser->setHook( 'languageselector', 'wfLanguageSelectorTag' ); |
| 92 | +function wfLanguageSelectorSetHook( $parser ) { |
| 93 | + $parser->setHook( 'languageselector', 'wfLanguageSelectorTag' ); |
95 | 94 | return true; |
96 | 95 | } |
97 | 96 | |
— | — | @@ -105,10 +104,6 @@ |
106 | 105 | } |
107 | 106 | |
108 | 107 | if ( $wgLanguageSelectorLanguages === null ) { |
109 | | - $wgLanguageSelectorLanguages = @$GLOBALS['wgPolyglotLanguages']; |
110 | | - } |
111 | | - |
112 | | - if ( $wgLanguageSelectorLanguages === null ) { |
113 | 108 | $wgLanguageSelectorLanguages = array_keys( Language::getLanguageNames( !$wgLanguageSelectorShowAll ) ); |
114 | 109 | sort( $wgLanguageSelectorLanguages ); |
115 | 110 | } |
— | — | @@ -134,42 +129,9 @@ |
135 | 130 | } |
136 | 131 | |
137 | 132 | if ( !$wgRequest->getVal( 'uselang' ) && $wgUser->isAnon() ) { |
138 | | - |
139 | | - //NOTE: we need this for anons, so squids don't get confused. |
140 | | - // but something is still wrong with caching... |
141 | | - header( 'Vary: Cookie', false ); //hrm, this is pretty BAD. |
142 | | - header( 'Vary: Accept-Language', false ); |
143 | | - |
144 | 133 | if ( $wgLanguageSelectorRequestedLanguage || $wgLanguageSelectorDetectLanguage != LANGUAGE_SELECTOR_USE_CONTENT_LANG ) { |
145 | | - |
146 | | - if ( !class_exists( 'StubAutoLang' ) ) { |
147 | | - class StubAutoLang extends StubObject { |
148 | | - function __construct() { |
149 | | - parent::__construct( 'wgLang' ); |
150 | | - } |
151 | | - |
152 | | - function __call( $name, $args ) { |
153 | | - return $this->_call( $name, $args ); |
154 | | - } |
155 | | - |
156 | | - //partially copied from StubObject.php. There should be a better way... |
157 | | - function _newObject() { |
158 | | - global $wgContLanguageCode, $wgContLang, $wgLanguageSelectorDetectLanguage, $wgLanguageSelectorRequestedLanguage; |
159 | | - |
160 | | - $code = $wgLanguageSelectorRequestedLanguage; |
161 | | - if (!$code) $code = wfLanguageSelectorDetectLanguage( $wgLanguageSelectorDetectLanguage ); |
162 | | - |
163 | | - if( $code == $wgContLanguageCode ) { |
164 | | - return $wgContLang; |
165 | | - } else { |
166 | | - $obj = Language::factory( $code ); |
167 | | - return $obj; |
168 | | - } |
169 | | - } |
170 | | - } |
171 | | - } |
172 | | - |
173 | 134 | $wgLang = new StubAutoLang; |
| 135 | + $wgLang->setRequestedLanguage( $wgLanguageSelectorRequestedLanguage ); |
174 | 136 | } |
175 | 137 | } |
176 | 138 | |
— | — | @@ -204,11 +166,8 @@ |
205 | 167 | return true; |
206 | 168 | } |
207 | 169 | |
208 | | -function wfLanguageSelectorGetCacheVaryCookies( &$cookies ) { |
209 | | - global $wgCookiePrefix; |
210 | | - |
| 170 | +function wfLanguageSelectorGetCacheVaryCookies( $out, &$cookies ) { |
211 | 171 | $cookies[] = $wgCookiePrefix.'LanguageSelectorLanguage'; |
212 | | - |
213 | 172 | return true; |
214 | 173 | } |
215 | 174 | |
Index: trunk/extensions/LanguageSelector/StubAutoLang.php |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class StubAutoLang extends StubObject { |
| 5 | + protected $requestedLanguage; |
| 6 | + |
| 7 | + function __construct() { |
| 8 | + parent::__construct( 'wgLang' ); |
| 9 | + } |
| 10 | + |
| 11 | + function __call( $name, $args ) { |
| 12 | + return $this->_call( $name, $args ); |
| 13 | + } |
| 14 | + |
| 15 | + function setRequestedLanguage( $code ) { |
| 16 | + $this->requestedLanguage = $code; |
| 17 | + } |
| 18 | + |
| 19 | + //partially copied from StubObject.php. There should be a better way... |
| 20 | + function _newObject() { |
| 21 | + global $wgContLanguageCode, $wgContLang, $wgLanguageSelectorDetectLanguage; |
| 22 | + |
| 23 | + $code = $this->requestedLanguage; |
| 24 | + if (!$code) $code = wfLanguageSelectorDetectLanguage( $wgLanguageSelectorDetectLanguage ); |
| 25 | + |
| 26 | + if( $code == $wgContLanguageCode ) { |
| 27 | + return $wgContLang; |
| 28 | + } else { |
| 29 | + $obj = Language::factory( $code ); |
| 30 | + return $obj; |
| 31 | + } |
| 32 | + } |
| 33 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/LanguageSelector/StubAutoLang.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 34 | + native |