Start removing the Latin-1 hacks. We're going pure UTF-8 for 1.5...
This commit is contained in:
parent
11027c83d8
commit
6f5560867c
17 changed files with 33 additions and 524 deletions
|
|
@ -163,13 +163,8 @@ require_once( "../maintenance/archives/moveCustomMessages.inc" );
|
|||
|
||||
class ConfigData {
|
||||
function getEncoded( $data ) {
|
||||
# Hackish
|
||||
global $wgUseLatin1;
|
||||
if( $wgUseLatin1 ) {
|
||||
return utf8_decode( $data ); /* to latin1 wikis */
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
# removing latin1 support, no need...
|
||||
return $data;
|
||||
}
|
||||
function getSitename() { return $this->getEncoded( $this->Sitename ); }
|
||||
function getSysopName() { return $this->getEncoded( $this->SysopName ); }
|
||||
|
|
@ -695,10 +690,8 @@ if( count( $errs ) ) {
|
|||
</dd>
|
||||
<dt>
|
||||
You may select the language for the user interface of the wiki...
|
||||
Some localizations are less complete than others. This also controls
|
||||
the character encoding; Unicode is more flexible, but Latin-1 may be
|
||||
more compatible with older browsers for some languages. Unicode will
|
||||
be used where not specified otherwise.
|
||||
Some localizations are less complete than others. Unicode (UTF-8 encoding)
|
||||
is used for all localizations.
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
|
|
@ -953,12 +946,6 @@ function writeLocalSettings( $conf ) {
|
|||
$conf->DBmysql4 = @$conf->DBmysql4 ? 'true' : 'false';
|
||||
$conf->UseImageResize = $conf->UseImageResize ? 'true' : 'false';
|
||||
$conf->PasswordSender = $conf->EmergencyContact;
|
||||
if( preg_match( '/^([a-z]+)-latin1$/', $conf->LanguageCode, $m ) ) {
|
||||
$conf->LanguageCode = $m[1];
|
||||
$conf->Latin1 = true;
|
||||
} else {
|
||||
$conf->Latin1 = false;
|
||||
}
|
||||
$zlib = ($conf->zlib ? "" : "# ");
|
||||
$magic = ($conf->ImageMagick ? "" : "# ");
|
||||
$convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
|
||||
|
|
@ -1114,7 +1101,6 @@ if ( \$wgCommandLineMode ) {
|
|||
\$wgLocalInterwiki = \$wgSitename;
|
||||
|
||||
\$wgLanguageCode = \"{$slconf['LanguageCode']}\";
|
||||
\$wgUseLatin1 = " . ($conf->Latin1 ? 'true' : 'false') . ";\n
|
||||
|
||||
\$wgProxyKey = \"$secretKey\";
|
||||
|
||||
|
|
@ -1203,7 +1189,6 @@ function getLanguageList() {
|
|||
}
|
||||
|
||||
$codes = array();
|
||||
$latin1 = array( "da", "de", "en", "es", "fr", "nl", "sv" );
|
||||
|
||||
$d = opendir( "../languages" );
|
||||
while( false !== ($f = readdir( $d ) ) ) {
|
||||
|
|
@ -1214,12 +1199,7 @@ function getLanguageList() {
|
|||
} else {
|
||||
$name = $code;
|
||||
}
|
||||
if( in_array( $code, $latin1 ) ) {
|
||||
$codes[$code] = $name . " - Unicode";
|
||||
$codes[$code.'-latin1'] = $name . " - Latin-1";
|
||||
} else {
|
||||
$codes[$code] = $name;
|
||||
}
|
||||
$codes[$code] = $name;
|
||||
}
|
||||
}
|
||||
closedir( $d );
|
||||
|
|
|
|||
|
|
@ -342,12 +342,9 @@ $wgLanguageFile = false;
|
|||
/** Treat language links as magic connectors, not inline links */
|
||||
$wgInterwikiMagic = true;
|
||||
|
||||
/** LanguageUtf8.php normally overrides this */
|
||||
$wgInputEncoding = 'ISO-8859-1';
|
||||
/** unless you set the next option to true: */
|
||||
$wgOutputEncoding = 'ISO-8859-1';
|
||||
/** Enable ISO-8859-1 compatibility mode */
|
||||
$wgUseLatin1 = false;
|
||||
/** We speak UTF-8 all the time now, unless some oddities happen */
|
||||
$wgInputEncoding = 'UTF-8';
|
||||
$wgOutputEncoding = 'UTF-8';
|
||||
$wgEditEncoding = '';
|
||||
|
||||
# Set this to eg 'ISO-8859-1' to perform character set
|
||||
|
|
|
|||
|
|
@ -284,7 +284,6 @@ class EditPage {
|
|||
global $wgAllowAnonymousMinor;
|
||||
global $wgWhitelistEdit;
|
||||
global $wgSpamRegex, $wgFilterCallback;
|
||||
global $wgUseLatin1;
|
||||
|
||||
$sk = $wgUser->getSkin();
|
||||
$isConflict = false;
|
||||
|
|
@ -470,7 +469,7 @@ class EditPage {
|
|||
$s = wfMsg( 'editing', $this->mTitle->getPrefixedText() );
|
||||
}
|
||||
$wgOut->setPageTitle( $s );
|
||||
if ( !$wgUseLatin1 && !$this->checkUnicodeCompliantBrowser() ) {
|
||||
if ( !$this->checkUnicodeCompliantBrowser() ) {
|
||||
$this->mArticle->setOldSubtitle();
|
||||
$wgOut->addWikiText( wfMsg( 'nonunicodebrowser') );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,8 @@ class FeedItem {
|
|||
* @todo document
|
||||
*/
|
||||
function xmlEncode( $string ) {
|
||||
global $wgInputEncoding, $wgContLang;
|
||||
$string = str_replace( "\r\n", "\n", $string );
|
||||
$string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
|
||||
if( strcasecmp( $wgInputEncoding, 'utf-8' ) != 0 ) {
|
||||
$string = $wgContLang->iconv( $wgInputEncoding, 'utf-8', $string );
|
||||
}
|
||||
return htmlspecialchars( $string );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Image
|
|||
*/
|
||||
function Image( $name, $recache = false ) {
|
||||
|
||||
global $wgUseSharedUploads, $wgUseLatin1, $wgSharedLatin1, $wgLang, $wgMemc, $wgDBname,
|
||||
global $wgUseSharedUploads, $wgLang, $wgMemc, $wgDBname,
|
||||
$wgSharedUploadDBname;
|
||||
|
||||
$this->name = $name;
|
||||
|
|
@ -96,12 +96,6 @@ class Image
|
|||
# looking it up in the shared repository.
|
||||
$this->name= $wgLang->ucfirst($name);
|
||||
|
||||
# Encode the filename if we're on a Latin1 wiki and the
|
||||
# shared repository is UTF-8
|
||||
if($wgUseLatin1 && !$wgSharedLatin1) {
|
||||
$this->name = utf8_encode($name);
|
||||
}
|
||||
|
||||
$this->imagePath = $this->getFullPath(true);
|
||||
$this->fileExists = file_exists( $this->imagePath);
|
||||
$this->fromSharedDirectory = true;
|
||||
|
|
@ -323,15 +317,11 @@ class Image
|
|||
*/
|
||||
function thumbUrl( $width, $subdir='thumb') {
|
||||
global $wgUploadPath, $wgUploadBaseUrl,
|
||||
$wgSharedUploadPath,$wgSharedUploadDirectory,
|
||||
$wgUseLatin1,$wgSharedLatin1;
|
||||
$wgSharedUploadPath,$wgSharedUploadDirectory;
|
||||
$name = $this->thumbName( $width );
|
||||
if($this->fromSharedDirectory) {
|
||||
$base = '';
|
||||
$path = $wgSharedUploadPath;
|
||||
if($wgUseLatin1 && !$wgSharedLatin1) {
|
||||
$name=utf8_encode($name);
|
||||
}
|
||||
} else {
|
||||
$base = $wgUploadBaseUrl;
|
||||
$path = $wgUploadPath;
|
||||
|
|
@ -350,15 +340,11 @@ class Image
|
|||
* @access private
|
||||
*/
|
||||
function thumbName( $width, $shared=false ) {
|
||||
global $wgUseLatin1,$wgSharedLatin1;
|
||||
$thumb = $width."px-".$this->name;
|
||||
if( $this->extension == 'svg' ) {
|
||||
# Rasterize SVG vector images to PNG
|
||||
$thumb .= '.png';
|
||||
}
|
||||
if( $shared && $wgUseLatin1 && !$wgSharedLatin1) {
|
||||
$thumb=utf8_encode($thumb);
|
||||
}
|
||||
return $thumb;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -484,22 +484,11 @@ class Parser
|
|||
*/
|
||||
function tidy ( $text ) {
|
||||
global $wgTidyConf, $wgTidyBin, $wgTidyOpts;
|
||||
global $wgInputEncoding, $wgOutputEncoding;
|
||||
$fname = 'Parser::tidy';
|
||||
wfProfileIn( $fname );
|
||||
|
||||
$cleansource = '';
|
||||
$opts = '';
|
||||
switch(strtoupper($wgOutputEncoding)) {
|
||||
case 'ISO-8859-1':
|
||||
$opts .= ($wgInputEncoding == $wgOutputEncoding)? ' -latin1':' -raw';
|
||||
break;
|
||||
case 'UTF-8':
|
||||
$opts .= ($wgInputEncoding == $wgOutputEncoding)? ' -utf8':' -raw';
|
||||
break;
|
||||
default:
|
||||
$opts .= ' -raw';
|
||||
}
|
||||
$opts = ' -utf8';
|
||||
|
||||
$wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'.
|
||||
' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>'.
|
||||
|
|
|
|||
|
|
@ -400,13 +400,13 @@ class Revision {
|
|||
* @return string
|
||||
*/
|
||||
function compressRevisionText( &$text ) {
|
||||
global $wgCompressRevisions, $wgUseLatin1;
|
||||
global $wgCompressRevisions;
|
||||
$flags = array();
|
||||
if( !$wgUseLatin1 ) {
|
||||
# Revisions not marked this way will be converted
|
||||
# on load if $wgLegacyCharset is set in the future.
|
||||
$flags[] = 'utf-8';
|
||||
}
|
||||
|
||||
# Revisions not marked this way will be converted
|
||||
# on load if $wgLegacyCharset is set in the future.
|
||||
$flags[] = 'utf-8';
|
||||
|
||||
if( $wgCompressRevisions ) {
|
||||
if( function_exists( 'gzdeflate' ) ) {
|
||||
$text = gzdeflate( $text );
|
||||
|
|
|
|||
|
|
@ -255,13 +255,11 @@ wfProfileOut( $fname.'-User' );
|
|||
wfProfileIn( $fname.'-language2' );
|
||||
|
||||
function setupLangObj(&$langclass) {
|
||||
global $wgUseLatin1, $IP;
|
||||
global $IP;
|
||||
|
||||
if( ! class_exists( $langclass ) ) {
|
||||
# Default to English/UTF-8, or for non-UTF-8, to latin-1
|
||||
# Default to English/UTF-8
|
||||
$baseclass = 'LanguageUtf8';
|
||||
if( $wgUseLatin1 )
|
||||
$baseclass = 'LanguageLatin1';
|
||||
require_once( "$IP/languages/$baseclass.php" );
|
||||
$lc = strtolower(substr($langclass, 8));
|
||||
$snip = "
|
||||
|
|
|
|||
|
|
@ -186,16 +186,7 @@ function xmlsafe( $string ) {
|
|||
* Invalid UTF-8 sequences or forbidden control characters will make our
|
||||
* XML output invalid, so be sure to strip them out.
|
||||
*/
|
||||
global $wgUseLatin1;
|
||||
if( $wgUseLatin1 ) {
|
||||
/**
|
||||
* We know the UTF-8 is valid since we converted outselves.
|
||||
* Just check for forbidden controls...
|
||||
*/
|
||||
$string = preg_replace( '/[\x00-\x08\x0b-\x1f]/', '', $string );
|
||||
} else {
|
||||
$string = UtfNormal::cleanUp( $string );
|
||||
}
|
||||
$string = UtfNormal::cleanUp( $string );
|
||||
|
||||
$string = htmlspecialchars( $string );
|
||||
wfProfileOut( $fname );
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ class WikiRevision {
|
|||
var $comment = "";
|
||||
|
||||
function setTitle( $text ) {
|
||||
$text = $this->fixEncoding( $text );
|
||||
$this->title = Title::newFromText( $text );
|
||||
}
|
||||
|
||||
|
|
@ -135,29 +134,19 @@ class WikiRevision {
|
|||
}
|
||||
|
||||
function setUsername( $user ) {
|
||||
$this->user_text = $this->fixEncoding( $user );
|
||||
$this->user_text = $user;
|
||||
}
|
||||
|
||||
function setUserIP( $ip ) {
|
||||
$this->user_text = $this->fixEncoding( $ip );
|
||||
$this->user_text = $ip;
|
||||
}
|
||||
|
||||
function setText( $text ) {
|
||||
$this->text = $this->fixEncoding( $text );
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
function setComment( $text ) {
|
||||
$this->comment = $this->fixEncoding( $text );
|
||||
}
|
||||
|
||||
function fixEncoding( $data ) {
|
||||
global $wgContLang, $wgInputEncoding;
|
||||
|
||||
if( strcasecmp( $wgInputEncoding, "utf-8" ) == 0 ) {
|
||||
return $data;
|
||||
} else {
|
||||
return $wgContLang->iconv( "utf-8", $wgInputEncoding, $data );
|
||||
}
|
||||
$this->comment = $text;
|
||||
}
|
||||
|
||||
function getTitle() {
|
||||
|
|
|
|||
|
|
@ -371,12 +371,9 @@ function rcFormatDiff( $row ) {
|
|||
}
|
||||
$oldtext = $oldrev->getText();
|
||||
|
||||
global $wgUseLatin1;
|
||||
if( !$wgUseLatin1 ) {
|
||||
# Old entries may contain illegal characters
|
||||
# which will damage output
|
||||
$oldtext = UtfNormal::cleanUp( $oldtext );
|
||||
}
|
||||
# Old entries may contain illegal characters
|
||||
# which will damage output
|
||||
$oldtext = UtfNormal::cleanUp( $oldtext );
|
||||
|
||||
global $wgFeedDiffCutoff;
|
||||
if( strlen( $newtext ) > $wgFeedDiffCutoff ||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class LoginForm {
|
|||
*/
|
||||
function addNewAccountInternal() {
|
||||
global $wgUser, $wgOut;
|
||||
global $wgMaxNameChars, $wgUseLatin1;
|
||||
global $wgMaxNameChars;
|
||||
global $wgMemc, $wgAccountCreationThrottle, $wgDBname, $wgIP;
|
||||
global $wgMinimalPasswordLength;
|
||||
|
||||
|
|
@ -212,7 +212,6 @@ class LoginForm {
|
|||
$wgUser->isIP( $name ) ||
|
||||
(strpos( $name, '/' ) !== false) ||
|
||||
(strlen( $name ) > $wgMaxNameChars) ||
|
||||
($wgUseLatin1 && preg_match( "/[\x80-\xA0]/", $name )) ||
|
||||
ucFirst($name) != $u->getName() )
|
||||
{
|
||||
$this->mainLoginForm( wfMsg( 'noname' ) );
|
||||
|
|
|
|||
|
|
@ -1113,8 +1113,7 @@ class Title {
|
|||
return false;
|
||||
}
|
||||
|
||||
global $wgUseLatin1;
|
||||
if( !$wgUseLatin1 && false !== strpos( $t, UTF8_REPLACEMENT ) ) {
|
||||
if( false !== strpos( $t, UTF8_REPLACEMENT ) ) {
|
||||
# Contained illegal UTF-8 sequences or forbidden Unicode chars.
|
||||
wfProfileOut( $fname );
|
||||
return false;
|
||||
|
|
@ -1244,14 +1243,6 @@ class Title {
|
|||
return false;
|
||||
}
|
||||
|
||||
if( $wgUseLatin1 && $this->mInterwiki != '' ) {
|
||||
# On a Latin-1 wiki, numbered character entities may have
|
||||
# left us with a mix of 8-bit and UTF-8 characters, and
|
||||
# some of those might be Windows-1252 special chars.
|
||||
# Normalize interwikis to pure UTF-8.
|
||||
$t = Title::mergeLatin1Utf8( $t );
|
||||
}
|
||||
|
||||
# Fill fields
|
||||
$this->mDbkeyform = $t;
|
||||
$this->mUrlform = wfUrlencode( $t );
|
||||
|
|
@ -1870,84 +1861,5 @@ class Title {
|
|||
&& $this->getDbkey() == $title->getDbkey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Windows-1252 extended codepoints to their real Unicode points.
|
||||
* @param int $codepoint
|
||||
* @return int
|
||||
* @access private
|
||||
*/
|
||||
function cp1252toUnicode( $codepoint ) {
|
||||
# Mappings from:
|
||||
# http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
|
||||
static $cp1252 = array(
|
||||
0x80 => 0x20AC, #EURO SIGN
|
||||
0x81 => UNICODE_REPLACEMENT,
|
||||
0x82 => 0x201A, #SINGLE LOW-9 QUOTATION MARK
|
||||
0x83 => 0x0192, #LATIN SMALL LETTER F WITH HOOK
|
||||
0x84 => 0x201E, #DOUBLE LOW-9 QUOTATION MARK
|
||||
0x85 => 0x2026, #HORIZONTAL ELLIPSIS
|
||||
0x86 => 0x2020, #DAGGER
|
||||
0x87 => 0x2021, #DOUBLE DAGGER
|
||||
0x88 => 0x02C6, #MODIFIER LETTER CIRCUMFLEX ACCENT
|
||||
0x89 => 0x2030, #PER MILLE SIGN
|
||||
0x8A => 0x0160, #LATIN CAPITAL LETTER S WITH CARON
|
||||
0x8B => 0x2039, #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
|
||||
0x8C => 0x0152, #LATIN CAPITAL LIGATURE OE
|
||||
0x8D => UNICODE_REPLACEMENT,
|
||||
0x8E => 0x017D, #LATIN CAPITAL LETTER Z WITH CARON
|
||||
0x8F => UNICODE_REPLACEMENT,
|
||||
0x90 => UNICODE_REPLACEMENT,
|
||||
0x91 => 0x2018, #LEFT SINGLE QUOTATION MARK
|
||||
0x92 => 0x2019, #RIGHT SINGLE QUOTATION MARK
|
||||
0x93 => 0x201C, #LEFT DOUBLE QUOTATION MARK
|
||||
0x94 => 0x201D, #RIGHT DOUBLE QUOTATION MARK
|
||||
0x95 => 0x2022, #BULLET
|
||||
0x96 => 0x2013, #EN DASH
|
||||
0x97 => 0x2014, #EM DASH
|
||||
0x98 => 0x02DC, #SMALL TILDE
|
||||
0x99 => 0x2122, #TRADE MARK SIGN
|
||||
0x9A => 0x0161, #LATIN SMALL LETTER S WITH CARON
|
||||
0x9B => 0x203A, #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
|
||||
0x9C => 0x0153, #LATIN SMALL LIGATURE OE
|
||||
0x9D => UNICODE_REPLACEMENT,
|
||||
0x9E => 0x017E, #LATIN SMALL LETTER Z WITH CARON
|
||||
0x9F => 0x0178, #LATIN CAPITAL LETTER Y WITH DIAERESIS
|
||||
);
|
||||
return isset( $cp1252[$codepoint] )
|
||||
? $cp1252[$codepoint]
|
||||
: $codepoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* HACKHACKHACK
|
||||
* Take a string containing a mix of CP1252 characters and UTF-8 and try
|
||||
* to convert it completely to UTF-8.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
* @access private
|
||||
*/
|
||||
function mergeLatin1Utf8( $string ) {
|
||||
return preg_replace_callback(
|
||||
# Windows CP1252 extends ISO-8859-1 by putting extra characters
|
||||
# into the high control chars area. We have to convert these
|
||||
# to their proper Unicode counterparts.
|
||||
'/([\x80-\x9f])/u',
|
||||
create_function( '$matches',
|
||||
'return codepointToUtf8(
|
||||
Title::cp1252toUnicode(
|
||||
utf8ToCodepoint( $matches[1] ) ) );' ),
|
||||
preg_replace_callback(
|
||||
# Up-convert everything from 8-bit to UTF-8, then
|
||||
# filter the valid-looking UTF-8 back from the
|
||||
# double-converted form.
|
||||
'/((?:[\xc0-\xdf][\x80-\xbf]
|
||||
|[\xe0-\xef][\x80-\xbf]{2}
|
||||
|[\xf0-\xf7][\x80-\xbf]{3})+)/ux',
|
||||
create_function( '$matches',
|
||||
'return utf8_decode( $matches[1] );' ),
|
||||
utf8_encode( $string ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class WebRequest {
|
|||
*/
|
||||
function getGPCVal( &$arr, $name, $default ) {
|
||||
if( isset( $arr[$name] ) ) {
|
||||
global $wgUseLatin1, $wgServer, $wgContLang;
|
||||
global $wgServer, $wgContLang;
|
||||
$data = $arr[$name];
|
||||
if( isset( $_GET[$name] ) &&
|
||||
!is_array( $data ) &&
|
||||
|
|
@ -120,10 +120,8 @@ class WebRequest {
|
|||
$data = $wgContLang->checkTitleEncoding( $data );
|
||||
}
|
||||
}
|
||||
if( !$wgUseLatin1 ) {
|
||||
require_once( 'normal/UtfNormal.php' );
|
||||
$data = $this->normalizeUnicode( $data );
|
||||
}
|
||||
require_once( 'normal/UtfNormal.php' );
|
||||
$data = $this->normalizeUnicode( $data );
|
||||
return $data;
|
||||
} else {
|
||||
return $default;
|
||||
|
|
@ -381,15 +379,8 @@ class WebRequest {
|
|||
|
||||
# Safari sends filenames in HTML-encoded Unicode form D...
|
||||
# Horrid and evil! Let's try to make some kind of sense of it.
|
||||
global $wgUseLatin1;
|
||||
if( $wgUseLatin1 ) {
|
||||
$name = utf8_encode( $name );
|
||||
}
|
||||
$name = wfMungeToUtf8( $name );
|
||||
$name = UtfNormal::cleanUp( $name );
|
||||
if( $wgUseLatin1 ) {
|
||||
$name = utf8_decode( $name );
|
||||
}
|
||||
wfDebug( "WebRequest::getFileName() '" . $_FILES[$key]['name'] . "' normalized to '$name'\n" );
|
||||
return $name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,12 +70,6 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
|
|||
$wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
|
||||
$wgOut->errorpage( 'badtitle', 'badtitletext' );
|
||||
} else if ( $wgTitle->getInterwiki() != '' ) {
|
||||
if( $wgUseLatin1 ) {
|
||||
# Conversion from UTF-8 may truncate or corrupt non-Latin links.
|
||||
# Grab a fresh copy without doing the automated conversion checks.
|
||||
$interwiki = Title::newFromUrl( $_REQUEST['title'] );
|
||||
if( !is_null( $interwiki ) ) $wgTitle = $interwiki;
|
||||
}
|
||||
if( $rdfrom = $wgRequest->getVal( 'rdfrom' ) ) {
|
||||
$url = $wgTitle->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,308 +0,0 @@
|
|||
<?php
|
||||
# Copyright (C) 2004 Brion Vibber <brion@pobox.com>
|
||||
# http://www.mediawiki.org/
|
||||
#
|
||||
# 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.,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
#
|
||||
# Latin-1 compatibility layer hack.
|
||||
#
|
||||
# Enable by setting "$wgUseLatin1 = true;" in LocalSettings.php
|
||||
# (Preferably at install time so you get the messages right!)
|
||||
#
|
||||
# This will replace anything that can't be described in Latin-1 with
|
||||
# an ugly question mark (?) so don't use this mode on languages that
|
||||
# aren't suited to it!
|
||||
|
||||
# This file and LanguageUtf8.php may be included from within functions, so
|
||||
# we need to have global statements
|
||||
global $wgInputEncoding, $wgOutputEncoding;
|
||||
|
||||
$wgInputEncoding = "ISO-8859-1";
|
||||
$wgOutputEncoding = "ISO-8859-1";
|
||||
|
||||
function utf8_decode_array( $arr ) {
|
||||
if( !is_array( $arr ) ) {
|
||||
wfDebugDieBacktrace( "utf8_decode_array given non-array" );
|
||||
}
|
||||
return array_map( "utf8_decode", $arr );
|
||||
}
|
||||
|
||||
#
|
||||
# This is a proxy object; the Language instance handed to us speaks
|
||||
# UTF-8, while the wiki outside speaks Latin-1. We translate as
|
||||
# necessary so neither knows the other is in the wrong charset.
|
||||
#
|
||||
class LanguageLatin1 {
|
||||
var $lang;
|
||||
|
||||
function LanguageLatin1( &$language ) {
|
||||
$this->lang =& $language;
|
||||
}
|
||||
|
||||
function getDefaultUserOptions() {
|
||||
return $this->lang->getDefaultUserOptions();
|
||||
}
|
||||
|
||||
function getBookstoreList() {
|
||||
return utf8_decode_array( $this->lang->getBookstoreList() );
|
||||
}
|
||||
|
||||
function getNamespaces() {
|
||||
return utf8_decode_array( $this->lang->getNamespaces() );
|
||||
}
|
||||
|
||||
function getNsText( $index ) {
|
||||
return utf8_decode( $this->lang->getNsText( $index ) );
|
||||
}
|
||||
|
||||
function getNsIndex( $text ) {
|
||||
return $this->lang->getNsIndex( utf8_encode( $text ) );
|
||||
}
|
||||
|
||||
function specialPage( $name ) {
|
||||
# At least one function calls this with Special:Undelete/Article_title, so it needs encoding
|
||||
return utf8_decode( $this->lang->specialPage( utf8_encode( $name ) ) );
|
||||
}
|
||||
|
||||
function getQuickbarSettings() {
|
||||
return utf8_decode_array( $this->lang->getQuickbarSettings() );
|
||||
}
|
||||
|
||||
function getSkinNames() {
|
||||
return utf8_decode_array( $this->lang->getSkinNames() );
|
||||
}
|
||||
|
||||
function getMathNames() {
|
||||
return utf8_decode_array( $this->lang->getMathNames() );
|
||||
}
|
||||
|
||||
function getDateFormats() {
|
||||
return utf8_decode_array( $this->lang->getDateFormats() );
|
||||
}
|
||||
|
||||
function getUserToggles() {
|
||||
return utf8_decode_array( $this->lang->getUserToggles() );
|
||||
}
|
||||
|
||||
function getUserToggle( $tog ) {
|
||||
return utf8_decode( $this->lang->getUserToggle( $tog ) );
|
||||
}
|
||||
|
||||
function getLanguageNames() {
|
||||
return utf8_decode_array( $this->lang->getLanguageNames() );
|
||||
}
|
||||
|
||||
function getLanguageName( $code ) {
|
||||
return utf8_decode( $this->lang->getLanguageName( $code ) );
|
||||
}
|
||||
|
||||
function getMonthName( $key ) {
|
||||
return utf8_decode( $this->lang->getMonthName( $key ) );
|
||||
}
|
||||
|
||||
function getMonthNameGen( $key ) {
|
||||
return utf8_decode( $this->lang->getMonthNameGen( $key ) );
|
||||
}
|
||||
|
||||
function getMonthAbbreviation( $key ) {
|
||||
return utf8_decode( $this->lang->getMonthAbbreviation( $key ) );
|
||||
}
|
||||
|
||||
function getWeekdayName( $key ) {
|
||||
return utf8_decode( $this->lang->getWeekdayName( $key ) );
|
||||
}
|
||||
|
||||
function userAdjust( $ts ) {
|
||||
return $this->lang->userAdjust( $ts );
|
||||
}
|
||||
|
||||
function date( $ts, $adj = false ) {
|
||||
return utf8_decode( $this->lang->date( $ts, $adj ) );
|
||||
}
|
||||
|
||||
function time( $ts, $adj = false, $seconds = false ) {
|
||||
return utf8_decode( $this->lang->time( $ts, $adj ) );
|
||||
}
|
||||
|
||||
function timeanddate( $ts, $adj = false ) {
|
||||
return utf8_decode( $this->lang->timeanddate( $ts, $adj ) );
|
||||
}
|
||||
|
||||
function rfc1123( $ts ) {
|
||||
# ASCII by definition
|
||||
return $this->lang->rfc1123( $ts );
|
||||
}
|
||||
|
||||
function getValidSpecialPages() {
|
||||
return utf8_decode_array( $this->lang->getValidSpecialPages() );
|
||||
}
|
||||
|
||||
function getSysopSpecialPages() {
|
||||
return utf8_decode_array( $this->lang->getSysopSpecialPages() );
|
||||
}
|
||||
|
||||
function getDeveloperSpecialPages() {
|
||||
return utf8_decode_array( $this->lang->getDeveloperSpecialPages() );
|
||||
}
|
||||
|
||||
function getMessage( $key ) {
|
||||
return utf8_decode( $this->lang->getMessage( $key ) );
|
||||
}
|
||||
|
||||
function getAllMessages() {
|
||||
return utf8_decode_array( $this->lang->getAllMessages() );
|
||||
}
|
||||
|
||||
function iconv( $in, $out, $string ) {
|
||||
# Use 8-bit version
|
||||
return Language::iconv( $in, $out, $string );
|
||||
}
|
||||
|
||||
function ucfirst( $string ) {
|
||||
# Use 8-bit version
|
||||
return Language::ucfirst( $string );
|
||||
}
|
||||
|
||||
function lcfirst( $s ) {
|
||||
# Use 8-bit version
|
||||
return Language::lcfirst( $s );
|
||||
}
|
||||
|
||||
function checkTitleEncoding( $s ) {
|
||||
# Use 8-bit version
|
||||
return Language::checkTitleEncoding( $s );
|
||||
}
|
||||
|
||||
function stripForSearch( $in ) {
|
||||
# Use 8-bit version
|
||||
return Language::stripForSearch( $in );
|
||||
}
|
||||
|
||||
function firstChar( $s ) {
|
||||
# Use 8-bit version
|
||||
return Language::firstChar( $s );
|
||||
}
|
||||
|
||||
function initEncoding() {
|
||||
# Not sure if this should be handled
|
||||
$this->lang->initEncoding();
|
||||
}
|
||||
|
||||
function setAltEncoding() {
|
||||
# Not sure if this should be handled
|
||||
$this->lang->setAltEncoding();
|
||||
}
|
||||
|
||||
function recodeForEdit( $s ) {
|
||||
# Use 8-bit version
|
||||
return Language::recodeForEdit( $s );
|
||||
}
|
||||
|
||||
function recodeInput( $s ) {
|
||||
# Use 8-bit version
|
||||
return Language::recodeInput( $s );
|
||||
}
|
||||
|
||||
function isRTL() {
|
||||
# boolean
|
||||
return $this->lang->isRTL();
|
||||
}
|
||||
|
||||
function linkPrefixExtension() {
|
||||
# boolean
|
||||
return $this->lang->linkPrefixExtension();
|
||||
}
|
||||
|
||||
function &getMagicWords() {
|
||||
return utf8_decode_array( $this->lang->getMagicWords() );
|
||||
}
|
||||
|
||||
function getMagic( &$mw ) {
|
||||
# Not sure how to handle this.
|
||||
# A moot point perhaps as few language files currently
|
||||
# assign localised magic words, and none of the ones we
|
||||
# need backwards compatibility for.
|
||||
return $this->lang->getMagic( $mw );
|
||||
}
|
||||
|
||||
function emphasize( $text ) {
|
||||
# It's unlikely that the emphasis markup itself will
|
||||
# include any non-ASCII chars.
|
||||
return $this->lang->emphasize( $text );
|
||||
}
|
||||
|
||||
function formatNum( $number ) {
|
||||
# Probably not necessary...
|
||||
return utf8_decode( $this->lang->formatNum( $number ) );
|
||||
}
|
||||
|
||||
function listToText( $l ) {
|
||||
# It's unlikely that the list markup itself will
|
||||
# include any non-ASCII chars. (?)
|
||||
return $this->lang->listToText( $l );
|
||||
}
|
||||
|
||||
function truncate( $string, $length, $ellipsis = "" ) {
|
||||
return Language::truncate( $string, $length, $ellipsis );
|
||||
}
|
||||
|
||||
function convertGrammar( $word, $case ) {
|
||||
return $word;
|
||||
}
|
||||
|
||||
function getPreferredVariant() {
|
||||
return $this->lang->getPreferredVariant();
|
||||
}
|
||||
|
||||
function segmentForDiff( $text ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
function unsegmentForDiff( $text ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
function convert( $text, $isTitle=false ) {
|
||||
return utf8_decode( $this->lang->convert( utf8_encode( $text ), $isTitle ) );
|
||||
}
|
||||
|
||||
function getVariantname( $code ) {
|
||||
return utf8_decode( $this->lang->getVariantname( $code ) );
|
||||
}
|
||||
|
||||
function getVariants() {
|
||||
return $this->lang->getVariants();
|
||||
}
|
||||
|
||||
function convertForSearchResult( $termsArray ) {
|
||||
return $termsArray;
|
||||
}
|
||||
|
||||
function getExtraHashOptions() {
|
||||
return '';
|
||||
}
|
||||
|
||||
function linkTrail() {
|
||||
return $this->lang->linkTrail();
|
||||
}
|
||||
|
||||
function getLangObj() {
|
||||
return $this->lang;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -291,7 +291,6 @@ class ParserTest {
|
|||
'wgSitename' => 'MediaWiki',
|
||||
'wgLanguageCode' => 'en',
|
||||
'wgContLanguageCode' => 'en',
|
||||
'wgUseLatin1' => false,
|
||||
'wgDBprefix' => 'parsertest',
|
||||
'wgDefaultUserOptions' => array(),
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue