r910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r909‎ | r910 | r911 >
Date:21:32, 14 November 2002
Author:vibber
Status:old
Tags:
Comment:
X-system options for Esperanto, etc
Modified paths:
  • /trunk/phpwiki/newcodebase/GlobalFunctions.php (modified) (history)
  • /trunk/phpwiki/newcodebase/Language.php (modified) (history)
  • /trunk/phpwiki/newcodebase/LanguageEo.php (modified) (history)
  • /trunk/phpwiki/newcodebase/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phpwiki/newcodebase/GlobalFunctions.php
@@ -146,19 +146,33 @@
147147 function wfCleanFormFields( $fields )
148148 {
149149 global $HTTP_POST_VARS;
 150+ global $wgInputEncoding, $wgOutputEncoding, $wgLang;
150151
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+ }
153163 }
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+ }
158176 }
159 - global ${$fname};
160 - if ( isset( ${$fname} ) ) {
161 - ${$fname} = stripslashes( ${$fname} );
162 - }
163177 }
164178 }
165179
Index: trunk/phpwiki/newcodebase/LanguageEo.php
@@ -38,7 +38,8 @@
3939 "rememberpassword" => "Rememoru mian pasvorton de seanco al seanco",
4040 "editwidth" => "Redaktilo estu plenlarĝa",
4141 "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"
4344 );
4445
4546 # Se eble, trovu Esperantajn libroservoj traserĉeblaj laŭ ISBN
@@ -1081,12 +1082,12 @@
10821083 return Language::getMessage($key);
10831084 }
10841085
1085 - function iconv( $in, $out, $string ) {
 1086+ function iconv( $in, $out, $string ) {
10861087 # For most languages, this is a wrapper for iconv
10871088 # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
10881089 # Ni ankaŭ konvertu X-sistemajn surogotajn
10891090 if( $in == "X" ) {
1090 - $xu = array (
 1091+ $xu = array (
10911092 "xx" => "x" , "xX" => "x" ,
10921093 "Xx" => "X" , "XX" => "XX" ,
10931094 "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" ,
@@ -1105,6 +1106,18 @@
11061107 return preg_replace ( "/([cghjsux]x)(?=(?:xx)*[^x\$])/ei" , "\$xu[\"\$1\"]" , $string ) ;
11071108 } else if( $out == "X" ) {
11081109 # 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 ) ;
11091122 }
11101123 return iconv( $in, $out, $string );
11111124 }
@@ -1142,6 +1155,10 @@
11431156 return $s;
11441157 }
11451158
 1159+ function getAltEncoding() {
 1160+ return "X";
 1161+ }
 1162+
11461163 }
11471164
11481165 ?>
Index: trunk/phpwiki/newcodebase/Language.php
@@ -1149,6 +1149,15 @@
11501150 return $s;
11511151 }
11521152
 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+
11531162 }
11541163
11551164 include_once( "Language" . ucfirst( $wgLanguageCode ) . ".php" );
Index: trunk/phpwiki/newcodebase/OutputPage.php
@@ -88,13 +88,14 @@
8989 function output()
9090 {
9191 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
92 - global $wgInputEncoding, $wgOutputEncoding;
 92+ global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
9393 $sk = $wgUser->getSkin();
9494
9595 header( "Expires: 0" );
9696 header( "Cache-Control: no-cache" );
9797 header( "Pragma: no-cache" );
9898 header( "Content-type: text/html; charset={$wgOutputEncoding}" );
 99+ header( "Content-language: {$wgLanguageCode}" );
99100
100101 if ( "" != $this->mRedirect ) {
101102 header( "Location: {$this->mRedirect}" );
@@ -130,12 +131,12 @@
131132
132133 function out( $ins )
133134 {
134 - global $wgInputEncoding, $wgOutputEncoding;
 135+ global $wgInputEncoding, $wgOutputEncoding, $wgLang;
135136
136137 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
137138 $outs = $ins;
138139 } else {
139 - $outs = iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
 140+ $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
140141 if ( false === $outs ) { $outs = $ins; }
141142 }
142143 print $outs;
@@ -144,9 +145,15 @@
145146 function setEncodings()
146147 {
147148 global $HTTP_SERVER_VARS, $wgInputEncoding, $wgOutputEncoding;
 149+ global $wgUser, $wgLang;
148150
149151 $wgInputEncoding = strtolower( $wgInputEncoding );
150152 $s = $HTTP_SERVER_VARS['HTTP_ACCEPT_CHARSET'];
 153+
 154+ if( $wgUser->getOption( 'altencoding' ) ) {
 155+ $wgOutputEncoding = $wgLang->getAltEncoding();
 156+ return;
 157+ }
151158
152159 if ( "" == $s ) {
153160 $wgOutputEncoding = strtolower( $wgOutputEncoding );

Status & tagging log