Remove old Esperanto character conversion support

Deletes LanguageEo.php class which only had remains of the server-side
character conversion (sx <-> ŝ, etc). This is being obsoleted in favor
of client-side IMEs provided by UniversalLanguageSelector extension.

Removes deprecated $wgEditEncoding, which was only used for this.

Turns Language::recodeInput() and Language::recordForEdit() into no-ops
for any old or extension code that happened to still use them.

Bug: T62677
Change-Id: Ib647353538d258dee941f2f7c571191060bc9c7d
This commit is contained in:
Brion Vibber 2014-01-31 08:42:05 -08:00 committed by Brion VIBBER
parent 1b6d9eeaea
commit 3b5f60f2c8
9 changed files with 18 additions and 175 deletions

View file

@ -16,6 +16,9 @@ production.
* $wgForeignUploadTargets now defaults to `[ 'local' ]`, where `'local'`
signifies local uploads. A value of `[]` (empty array) now means that
no upload targets are allowed, effectively disabling the upload dialog.
* The deprecated $wgEditEncoding variable has been removed; it was only used
for Esperanto language character conversion. You are now recommended to use
input methods provided by the UniversalLanguageSelector extension.
=== New features in 1.28 ===
* User::isBot() method for checking if an account is a bot role account.

View file

@ -664,7 +664,6 @@ $wgAutoloadLocalClasses = [
'LanguageConverter' => __DIR__ . '/languages/LanguageConverter.php',
'LanguageCu' => __DIR__ . '/languages/classes/LanguageCu.php',
'LanguageDsb' => __DIR__ . '/languages/classes/LanguageDsb.php',
'LanguageEo' => __DIR__ . '/languages/classes/LanguageEo.php',
'LanguageEs' => __DIR__ . '/languages/classes/LanguageEs.php',
'LanguageEt' => __DIR__ . '/languages/classes/LanguageEt.php',
'LanguageFi' => __DIR__ . '/languages/classes/LanguageFi.php',

View file

@ -2882,15 +2882,6 @@ $wgDummyLanguageCodes = [
'zh-yue' => 'yue',
];
/**
* Character set for use in the article edit box. Language-specific encodings
* may be defined.
*
* This historic feature is one of the first that was added by former MediaWiki
* team leader Brion Vibber, and is used to support the Esperanto x-system.
*/
$wgEditEncoding = '';
/**
* Set this to true to replace Arabic presentation forms with their standard
* forms in the U+0600-U+06FF block. This only works if $wgLanguageCode is

View file

@ -3026,7 +3026,7 @@ class EditPage {
* @param string $summary The text of the summary to display
*/
protected function showSummaryInput( $isSubjectPreview, $summary = "" ) {
global $wgOut, $wgContLang;
global $wgOut;
# Add a class if 'missingsummary' is triggered to allow styling of the summary line
$summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
if ( $isSubjectPreview ) {
@ -3038,7 +3038,6 @@ class EditPage {
return;
}
}
$summary = $wgContLang->recodeForEdit( $summary );
$labelText = wfMessage( $isSubjectPreview ? 'subject' : 'summary' )->parse();
list( $label, $input ) = $this->getSummaryInput(
$summary,
@ -4175,11 +4174,9 @@ HTML
* @return string
*/
protected function safeUnicodeOutput( $text ) {
global $wgContLang;
$codedText = $wgContLang->recodeForEdit( $text );
return $this->checkUnicodeCompliantBrowser()
? $codedText
: $this->makeSafe( $codedText );
? $text
: $this->makesafe( $text );
}
/**

View file

@ -705,7 +705,6 @@ $ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' );
* @var Language $wgContLang
*/
$wgContLang = Language::factory( $wgLanguageCode );
$wgContLang->initEncoding();
$wgContLang->initContLang();
// Now that variant lists may be available...

View file

@ -567,19 +567,16 @@ class WebRequest {
* Fetch a text string from the given array or return $default if it's not
* set. Carriage returns are stripped from the text, and with some language
* modules there is an input transliteration applied. This should generally
* be used for form "<textarea>" and "<input>" fields. Used for
* user-supplied freeform text input (for which input transformations may
* be required - e.g. Esperanto x-coding).
* be used for form "<textarea>" and "<input>" fields, and for
* user-supplied freeform text input.
*
* @param string $name
* @param string $default Optional
* @return string
*/
public function getText( $name, $default = '' ) {
global $wgContLang;
$val = $this->getVal( $name, $default );
return str_replace( "\r\n", "\n",
$wgContLang->recodeInput( $val ) );
return str_replace( "\r\n", "\n", $val );
}
/**

View file

@ -139,8 +139,6 @@ class MovePageForm extends UnlistedSpecialPage {
* parameters, like the second argument to OutputPage::wrapWikiMsg().
*/
function showForm( $err ) {
global $wgContLang;
$this->getSkin()->setRelevantTitle( $this->oldTitle );
$out = $this->getOutput();
@ -316,7 +314,7 @@ class MovePageForm extends UnlistedSpecialPage {
'title' => [
'id' => 'wpNewTitleMain',
'name' => 'wpNewTitleMain',
'value' => $wgContLang->recodeForEdit( $newTitle->getText() ),
'value' => $newTitle->getText(),
// Inappropriate, since we're expecting the user to input a non-existent page's title
'suggestions' => false,
],

View file

@ -2577,9 +2577,6 @@ class Language {
* @return string
*/
public function iconv( $in, $out, $string ) {
# This is a wrapper for iconv in all languages except esperanto,
# which does some nasty x-conversions beforehand
# Even with //IGNORE iconv can whine about illegal characters in
# *input* string. We just ignore those too.
# REF: http://bugs.php.net/bug.php?id=37166
@ -2929,46 +2926,29 @@ class Language {
}
}
/**
* @deprecated No-op since 1.28
*/
function initEncoding() {
# Some languages may have an alternate char encoding option
# (Esperanto X-coding, Japanese furigana conversion, etc)
# If this language is used as the primary content language,
# an override to the defaults can be set here on startup.
// No-op.
}
/**
* @param string $s
* @return string
* @deprecated No-op since 1.28
*/
function recodeForEdit( $s ) {
# For some languages we'll want to explicitly specify
# which characters make it into the edit box raw
# or are converted in some way or another.
global $wgEditEncoding;
if ( $wgEditEncoding == '' || $wgEditEncoding == 'UTF-8' ) {
return $s;
} else {
return $this->iconv( 'UTF-8', $wgEditEncoding, $s );
}
return $s;
}
/**
* @param string $s
* @return string
* @deprecated No-op since 1.28
*/
function recodeInput( $s ) {
# Take the previous into account.
global $wgEditEncoding;
if ( $wgEditEncoding != '' ) {
$enc = $wgEditEncoding;
} else {
$enc = 'UTF-8';
}
if ( $enc == 'UTF-8' ) {
return $s;
} else {
return $this->iconv( $enc, 'UTF-8', $s );
}
return $s;
}
/**

View file

@ -1,121 +0,0 @@
<?php
/**
* Esperanto (Esperanto) specific code.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @author Brion Vibber <brion@pobox.com>
* @ingroup Language
*/
/**
* Esperanto (Esperanto)
*
* @ingroup Language
*/
class LanguageEo extends Language {
/**
* Wrapper for charset conversions.
*
* In most languages, this calls through to standard system iconv(), but
* for Esperanto we're also adding a special pseudo-charset to convert
* accented characters to/from the ASCII-friendly "X" surrogate coding:
*
* cx = ĉ cxx = cx
* gx = ĝ gxx = gx
* hx = ĥ hxx = hx
* jx = ĵ jxx = jx
* sx = ŝ sxx = sx
* ux = ŭ uxx = ux
* xx = x
*
* http://en.wikipedia.org/wiki/Esperanto_orthography#X-system
* http://eo.wikipedia.org/wiki/X-sistemo
*
* X-conversion is applied, in either direction, between "utf-8" and "x" charsets;
* this comes into effect when input is run through $wgRequest->getText() and the
* $wgEditEncoding is set to 'x'.
*
* In the long run, this should be moved out of here and into the client-side
* editor behavior; the original server-side translation system dates to 2002-2003
* when many browsers with really bad Unicode support were still in use.
*
* @param string $in Input character set
* @param string $out Output character set
* @param string $string Text to be converted
* @return string
*/
public function iconv( $in, $out, $string ) {
if ( strcasecmp( $in, 'x' ) == 0 && strcasecmp( $out, 'utf-8' ) == 0 ) {
return preg_replace_callback(
'/([cghjsu]x?)((?:xx)*)(?!x)/i',
[ $this, 'strrtxuCallback' ], $string );
} elseif ( strcasecmp( $in, 'UTF-8' ) == 0 && strcasecmp( $out, 'x' ) == 0 ) {
# Double Xs only if they follow cxapelutaj literoj.
return preg_replace_callback(
'/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]|\xc5[\x9c\x9d\xac\xad])x*)/i',
[ $this, 'strrtuxCallback' ], $string );
}
return parent::iconv( $in, $out, $string );
}
/**
* @param array $matches
* @return string
*/
function strrtuxCallback( $matches ) {
static $ux = [
'x' => 'xx', 'X' => 'Xx',
"\xc4\x88" => "Cx", "\xc4\x89" => "cx",
"\xc4\x9c" => "Gx", "\xc4\x9d" => "gx",
"\xc4\xa4" => "Hx", "\xc4\xa5" => "hx",
"\xc4\xb4" => "Jx", "\xc4\xb5" => "jx",
"\xc5\x9c" => "Sx", "\xc5\x9d" => "sx",
"\xc5\xac" => "Ux", "\xc5\xad" => "ux",
];
return strtr( $matches[1], $ux );
}
/**
* @param array $matches
* @return string
*/
function strrtxuCallback( $matches ) {
static $xu = [
'xx' => 'x', 'xX' => 'x',
'Xx' => 'X', 'XX' => 'X',
"Cx" => "\xc4\x88", "CX" => "\xc4\x88",
"cx" => "\xc4\x89", "cX" => "\xc4\x89",
"Gx" => "\xc4\x9c", "GX" => "\xc4\x9c",
"gx" => "\xc4\x9d", "gX" => "\xc4\x9d",
"Hx" => "\xc4\xa4", "HX" => "\xc4\xa4",
"hx" => "\xc4\xa5", "hX" => "\xc4\xa5",
"Jx" => "\xc4\xb4", "JX" => "\xc4\xb4",
"jx" => "\xc4\xb5", "jX" => "\xc4\xb5",
"Sx" => "\xc5\x9c", "SX" => "\xc5\x9c",
"sx" => "\xc5\x9d", "sX" => "\xc5\x9d",
"Ux" => "\xc5\xac", "UX" => "\xc5\xac",
"ux" => "\xc5\xad", "uX" => "\xc5\xad",
];
return strtr( $matches[1], $xu ) . strtr( $matches[2], $xu );
}
function initEncoding() {
global $wgEditEncoding;
$wgEditEncoding = 'x';
}
}