Index: trunk/phpwiki/newcodebase/GlobalFunctions.php |
— | — | @@ -146,19 +146,33 @@ |
147 | 147 | function wfCleanFormFields( $fields ) |
148 | 148 | { |
149 | 149 | global $HTTP_POST_VARS; |
| 150 | + global $wgInputEncoding, $wgOutputEncoding, $wgLang; |
150 | 151 | |
151 | | - if ( ! get_magic_quotes_gpc() ) { |
152 | | - return; |
| 152 | + if ( get_magic_quotes_gpc() ) { |
| 153 | + foreach ( $fields as $fname ) { |
| 154 | + if ( isset( $HTTP_POST_VARS[$fname] ) ) { |
| 155 | + $HTTP_POST_VARS[$fname] = stripslashes( |
| 156 | + $HTTP_POST_VARS[$fname] ); |
| 157 | + } |
| 158 | + global ${$fname}; |
| 159 | + if ( isset( ${$fname} ) ) { |
| 160 | + ${$fname} = stripslashes( ${$fname} ); |
| 161 | + } |
| 162 | + } |
153 | 163 | } |
154 | | - foreach ( $fields as $fname ) { |
155 | | - if ( isset( $HTTP_POST_VARS[$fname] ) ) { |
156 | | - $HTTP_POST_VARS[$fname] = stripslashes( |
157 | | - $HTTP_POST_VARS[$fname] ); |
| 164 | + if ( $wgInputEncoding != $wgOutputEncoding ) { |
| 165 | + foreach ( $fields as $fname ) { |
| 166 | + if ( isset( $HTTP_POST_VARS[$fname] ) ) { |
| 167 | + $HTTP_POST_VARS[$fname] = $wgLang->iconv( |
| 168 | + $wgOutputEncoding, $wgInputEncoding, |
| 169 | + $HTTP_POST_VARS[$fname] ); |
| 170 | + } |
| 171 | + global ${$fname}; |
| 172 | + if ( isset( ${$fname} ) ) { |
| 173 | + ${$fname} = $wgLang->iconv( |
| 174 | + $wgOutputEncoding, $wgInputEncoding, ${$fname} ); |
| 175 | + } |
158 | 176 | } |
159 | | - global ${$fname}; |
160 | | - if ( isset( ${$fname} ) ) { |
161 | | - ${$fname} = stripslashes( ${$fname} ); |
162 | | - } |
163 | 177 | } |
164 | 178 | } |
165 | 179 | |
Index: trunk/phpwiki/newcodebase/LanguageEo.php |
— | — | @@ -38,7 +38,8 @@ |
39 | 39 | "rememberpassword" => "Rememoru mian pasvorton de seanco al seanco", |
40 | 40 | "editwidth" => "Redaktilo estu plenlarĝa", |
41 | 41 | "editondblclick" => "Redaktu per duobla alklako (JavaScript)", |
42 | | - "watchdefault" => "Watch new and modified articles" |
| 42 | + "watchdefault" => "Priatentu paĝojn de vi redaktintajn", |
| 43 | + "altencoding" => "Montru supersignojn per X-sistemo" |
43 | 44 | ); |
44 | 45 | |
45 | 46 | # Se eble, trovu Esperantajn libroservoj traserĉeblaj laŭ ISBN |
— | — | @@ -1081,12 +1082,12 @@ |
1082 | 1083 | return Language::getMessage($key); |
1083 | 1084 | } |
1084 | 1085 | |
1085 | | - function iconv( $in, $out, $string ) { |
| 1086 | + function iconv( $in, $out, $string ) { |
1086 | 1087 | # For most languages, this is a wrapper for iconv |
1087 | 1088 | # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv() |
1088 | 1089 | # Ni ankaŭ konvertu X-sistemajn surogotajn |
1089 | 1090 | if( $in == "X" ) { |
1090 | | - $xu = array ( |
| 1091 | + $xu = array ( |
1091 | 1092 | "xx" => "x" , "xX" => "x" , |
1092 | 1093 | "Xx" => "X" , "XX" => "XX" , |
1093 | 1094 | "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" , |
— | — | @@ -1105,6 +1106,18 @@ |
1106 | 1107 | return preg_replace ( "/([cghjsux]x)(?=(?:xx)*[^x\$])/ei" , "\$xu[\"\$1\"]" , $string ) ; |
1107 | 1108 | } else if( $out == "X" ) { |
1108 | 1109 | # FIXME: For output |
| 1110 | + $ux = array ( |
| 1111 | + #"x" => "xx" , "X" => "Xx" , |
| 1112 | + "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" , |
| 1113 | + "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" , |
| 1114 | + "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" , |
| 1115 | + "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" , |
| 1116 | + "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" , |
| 1117 | + "\xc5\xac" => "Ux" , "\xc5\xad" => "ux" |
| 1118 | + ) ; |
| 1119 | + # Double Xs only if they follow cxapelutaj literoj or other Xs. It's not canon, but it's a lot prettier |
| 1120 | + return strtr ( $string , $ux ) ; |
| 1121 | + #return $textregs[1] . preg_replace ( "/((?:^|[^cghjsux])x)x(?!x)/i" , "\$1" , $text ) ; |
1109 | 1122 | } |
1110 | 1123 | return iconv( $in, $out, $string ); |
1111 | 1124 | } |
— | — | @@ -1142,6 +1155,10 @@ |
1143 | 1156 | return $s; |
1144 | 1157 | } |
1145 | 1158 | |
| 1159 | + function getAltEncoding() { |
| 1160 | + return "X"; |
| 1161 | + } |
| 1162 | + |
1146 | 1163 | } |
1147 | 1164 | |
1148 | 1165 | ?> |
Index: trunk/phpwiki/newcodebase/Language.php |
— | — | @@ -1149,6 +1149,15 @@ |
1150 | 1150 | return $s; |
1151 | 1151 | } |
1152 | 1152 | |
| 1153 | + function getAltEncoding() { |
| 1154 | + # Some languages may have an alternate char encoding option |
| 1155 | + # (Esperanto X-coding, Japanese furigana conversion, etc) |
| 1156 | + # If 'altencoding' is checked in user prefs, this is used |
| 1157 | + # instead of the default $wgOutputEncoding set in LocalSettings.php |
| 1158 | + global $wgOutputEncoding; |
| 1159 | + return $wgOutputEncoding; |
| 1160 | + } |
| 1161 | + |
1153 | 1162 | } |
1154 | 1163 | |
1155 | 1164 | include_once( "Language" . ucfirst( $wgLanguageCode ) . ".php" ); |
Index: trunk/phpwiki/newcodebase/OutputPage.php |
— | — | @@ -88,13 +88,14 @@ |
89 | 89 | function output() |
90 | 90 | { |
91 | 91 | global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration; |
92 | | - global $wgInputEncoding, $wgOutputEncoding; |
| 92 | + global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode; |
93 | 93 | $sk = $wgUser->getSkin(); |
94 | 94 | |
95 | 95 | header( "Expires: 0" ); |
96 | 96 | header( "Cache-Control: no-cache" ); |
97 | 97 | header( "Pragma: no-cache" ); |
98 | 98 | header( "Content-type: text/html; charset={$wgOutputEncoding}" ); |
| 99 | + header( "Content-language: {$wgLanguageCode}" ); |
99 | 100 | |
100 | 101 | if ( "" != $this->mRedirect ) { |
101 | 102 | header( "Location: {$this->mRedirect}" ); |
— | — | @@ -130,12 +131,12 @@ |
131 | 132 | |
132 | 133 | function out( $ins ) |
133 | 134 | { |
134 | | - global $wgInputEncoding, $wgOutputEncoding; |
| 135 | + global $wgInputEncoding, $wgOutputEncoding, $wgLang; |
135 | 136 | |
136 | 137 | if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) { |
137 | 138 | $outs = $ins; |
138 | 139 | } else { |
139 | | - $outs = iconv( $wgInputEncoding, $wgOutputEncoding, $ins ); |
| 140 | + $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins ); |
140 | 141 | if ( false === $outs ) { $outs = $ins; } |
141 | 142 | } |
142 | 143 | print $outs; |
— | — | @@ -144,9 +145,15 @@ |
145 | 146 | function setEncodings() |
146 | 147 | { |
147 | 148 | global $HTTP_SERVER_VARS, $wgInputEncoding, $wgOutputEncoding; |
| 149 | + global $wgUser, $wgLang; |
148 | 150 | |
149 | 151 | $wgInputEncoding = strtolower( $wgInputEncoding ); |
150 | 152 | $s = $HTTP_SERVER_VARS['HTTP_ACCEPT_CHARSET']; |
| 153 | + |
| 154 | + if( $wgUser->getOption( 'altencoding' ) ) { |
| 155 | + $wgOutputEncoding = $wgLang->getAltEncoding(); |
| 156 | + return; |
| 157 | + } |
151 | 158 | |
152 | 159 | if ( "" == $s ) { |
153 | 160 | $wgOutputEncoding = strtolower( $wgOutputEncoding ); |