Index: trunk/extensions/LanguageSelector/LanguageSelector.php |
— | — | @@ -55,10 +55,10 @@ |
56 | 56 | define( 'LANGUAGE_SELECTOR_AT_TOP_OF_TEXT', 1 ); #put at the top of page content |
57 | 57 | define( 'LANGUAGE_SELECTOR_IN_TOOLBOX', 2 ); #put into toolbox |
58 | 58 | define( 'LANGUAGE_SELECTOR_AS_PORTLET', 3 ); #as portlet |
59 | | -define( 'LANGUAGE_SELECTOR_INTO_SITENOTICE', 11); #put after sitenotice text |
60 | | -define( 'LANGUAGE_SELECTOR_INTO_TITLE', 12); #put after title text |
61 | | -define( 'LANGUAGE_SELECTOR_INTO_SUBTITLE', 13); #put after subtitle text |
62 | | -define( 'LANGUAGE_SELECTOR_INTO_CATLINKS', 14); #put after catlinks text |
| 59 | +define( 'LANGUAGE_SELECTOR_INTO_SITENOTICE', 11 ); #put after sitenotice text |
| 60 | +define( 'LANGUAGE_SELECTOR_INTO_TITLE', 12 ); #put after title text |
| 61 | +define( 'LANGUAGE_SELECTOR_INTO_SUBTITLE', 13 ); #put after subtitle text |
| 62 | +define( 'LANGUAGE_SELECTOR_INTO_CATLINKS', 14 ); #put after catlinks text |
63 | 63 | |
64 | 64 | $wgLanguageSelectorLocation = LANGUAGE_SELECTOR_AT_TOP_OF_TEXT; |
65 | 65 | |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | |
77 | 77 | function wgLanguageSelectorSetHook() { |
78 | 78 | global $wgParser; |
79 | | - $wgParser->setHook('languageselector', 'wfLanguageSelectorTag' ); |
| 79 | + $wgParser->setHook( 'languageselector', 'wfLanguageSelectorTag' ); |
80 | 80 | return true; |
81 | 81 | } |
82 | 82 | |
— | — | @@ -98,34 +98,34 @@ |
99 | 99 | $wgLanguageSelectorLanguages = array_keys( Language::getLanguageNames( true ) ); |
100 | 100 | } |
101 | 101 | |
102 | | - $setlang = $wgRequest->getVal('setlang'); |
103 | | - if ($setlang && !in_array($setlang, $wgLanguageSelectorLanguages)) $setlang = NULL; //ignore invalid |
| 102 | + $setlang = $wgRequest->getVal( 'setlang' ); |
| 103 | + if ( $setlang && !in_array( $setlang, $wgLanguageSelectorLanguages ) ) |
| 104 | + $setlang = NULL; //ignore invalid |
104 | 105 | |
105 | | - if ($setlang) { |
106 | | - setcookie($wgCookiePrefix.'LanguageSelectorLanguage', $setlang, 0, $wgCookiePath); |
| 106 | + if ( $setlang ) { |
| 107 | + setcookie( $wgCookiePrefix . 'LanguageSelectorLanguage', $setlang, 0, $wgCookiePath ); |
107 | 108 | $wgLanguageSelectorRequestedLanguage = $setlang; |
108 | | - } |
109 | | - else { |
| 109 | + } else { |
110 | 110 | $wgLanguageSelectorRequestedLanguage = @$_COOKIE[$wgCookiePrefix.'LanguageSelectorLanguage']; |
111 | 111 | } |
112 | 112 | |
113 | 113 | if ( !$wgUser->isAnon() && $setlang ) { |
114 | | - if ($setlang != $wgUser->getOption('language')) { |
115 | | - $wgUser->setOption('language', $wgLanguageSelectorRequestedLanguage); |
| 114 | + if ( $setlang != $wgUser->getOption( 'language' ) ) { |
| 115 | + $wgUser->setOption( 'language', $wgLanguageSelectorRequestedLanguage ); |
116 | 116 | $wgUser->saveSettings(); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | | - if ( $wgUser->isAnon() && !$wgRequest->getVal( 'uselang' )) { |
| 120 | + if ( $wgUser->isAnon() && !$wgRequest->getVal( 'uselang' ) ) { |
121 | 121 | |
122 | 122 | //NOTE: we need this for anons, so squids don't get confused. |
123 | 123 | // but something is still wrong with caching... |
124 | | - header('Vary: Cookie', false); //hrm, this is pretty BAD. |
125 | | - header('Vary: Accept-Language', false); |
| 124 | + header( 'Vary: Cookie', false ); //hrm, this is pretty BAD. |
| 125 | + header( 'Vary: Accept-Language', false ); |
126 | 126 | |
127 | 127 | if ( $wgLanguageSelectorRequestedLanguage || $wgLanguageSelectorDetectLanguage != LANGUAGE_SELECTOR_USE_CONTENT_LANG ) { |
128 | 128 | |
129 | | - if (!class_exists('StubAutoLang')) { |
| 129 | + if ( !class_exists( 'StubAutoLang' ) ) { |
130 | 130 | class StubAutoLang extends StubObject { |
131 | 131 | function __construct() { |
132 | 132 | parent::__construct( 'wgLang' ); |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | global $wgContLanguageCode, $wgContLang, $wgLanguageSelectorDetectLanguage, $wgLanguageSelectorRequestedLanguage; |
142 | 142 | |
143 | 143 | $code = $wgLanguageSelectorRequestedLanguage; |
144 | | - if (!$code) $code = wfLanguageSelectorDetectLanguage($wgLanguageSelectorDetectLanguage); |
| 144 | + if (!$code) $code = wfLanguageSelectorDetectLanguage( $wgLanguageSelectorDetectLanguage ); |
145 | 145 | |
146 | 146 | if( $code == $wgContLanguageCode ) { |
147 | 147 | return $wgContLang; |
— | — | @@ -156,7 +156,7 @@ |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | | - if ($wgLanguageSelectorLocation != LANGUAGE_SELECTOR_MANUAL) { |
| 160 | + if ( $wgLanguageSelectorLocation != LANGUAGE_SELECTOR_MANUAL ) { |
161 | 161 | switch($wgLanguageSelectorLocation) { |
162 | 162 | case LANGUAGE_SELECTOR_AT_TOP_OF_TEXT: $wgHooks['BeforePageDisplay'][] = 'wfLanguageSelectorBeforePageDisplay'; break; |
163 | 163 | case LANGUAGE_SELECTOR_IN_TOOLBOX: $wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfLanguageSelectorSkinHook'; break; |
— | — | @@ -176,7 +176,16 @@ |
177 | 177 | if (!btn) break; |
178 | 178 | |
179 | 179 | btn.style.display = "none"; |
180 | | - sel.onchange = function() { this.parentNode.submit(); }; |
| 180 | + sel.onchange = function() { |
| 181 | + node = this.parentNode; |
| 182 | + while( true ) { |
| 183 | + if( node.tagName.toLowerCase() == "form" ) { |
| 184 | + node.submit(); |
| 185 | + break; |
| 186 | + } |
| 187 | + node = node.parentNode; |
| 188 | + } |
| 189 | + }; |
181 | 190 | |
182 | 191 | i++; |
183 | 192 | } |