Move MySQL charset maps to separate class
This allows us to load it only when needed Issue #11731 Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
3e8145a4a5
commit
cd4008b3d7
@ -8,6 +8,7 @@
|
||||
use PMA\libraries\RecentFavoriteTable;
|
||||
use PMA\libraries\URL;
|
||||
use PMA\libraries\Sanitize;
|
||||
use PMA\libraries\Charsets;
|
||||
|
||||
/**
|
||||
* Gets some core libraries and displays a top message if required
|
||||
@ -311,8 +312,8 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
|
||||
echo ' <li id="li_select_mysql_charset">';
|
||||
echo ' ' , __('Server charset:') , ' '
|
||||
. ' <span lang="en" dir="ltr">';
|
||||
echo ' ' , $mysql_charsets_descriptions[$mysql_charset_map['utf-8']];
|
||||
echo ' (' , $mysql_charset_map['utf-8'] , ')'
|
||||
echo ' ' , $mysql_charsets_descriptions[Charsets::$mysql_charset_map['utf-8']];
|
||||
echo ' (' , Charsets::$mysql_charset_map['utf-8'] , ')'
|
||||
. ' </span>'
|
||||
. ' </li>'
|
||||
. ' </ul>'
|
||||
|
||||
48
libraries/Charsets.php
Normal file
48
libraries/Charsets.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* MySQL charset metadata and manipulations
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
namespace PMA\libraries;
|
||||
|
||||
/**
|
||||
* Class used to manage MySQL charsets
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
class Charsets
|
||||
{
|
||||
|
||||
/**
|
||||
* MySQL charsets map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $mysql_charset_map = array(
|
||||
'big5' => 'big5',
|
||||
'cp-866' => 'cp866',
|
||||
'euc-jp' => 'ujis',
|
||||
'euc-kr' => 'euckr',
|
||||
'gb2312' => 'gb2312',
|
||||
'gbk' => 'gbk',
|
||||
'iso-8859-1' => 'latin1',
|
||||
'iso-8859-2' => 'latin2',
|
||||
'iso-8859-7' => 'greek',
|
||||
'iso-8859-8' => 'hebrew',
|
||||
'iso-8859-8-i' => 'hebrew',
|
||||
'iso-8859-9' => 'latin5',
|
||||
'iso-8859-13' => 'latin7',
|
||||
'iso-8859-15' => 'latin1',
|
||||
'koi8-r' => 'koi8r',
|
||||
'shift_jis' => 'sjis',
|
||||
'tis-620' => 'tis620',
|
||||
'utf-8' => 'utf8',
|
||||
'windows-1250' => 'cp1250',
|
||||
'windows-1251' => 'cp1251',
|
||||
'windows-1252' => 'latin1',
|
||||
'windows-1256' => 'cp1256',
|
||||
'windows-1257' => 'cp1257',
|
||||
);
|
||||
}
|
||||
@ -1021,32 +1021,3 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
include 'libraries/config/user_preferences.forms.php';
|
||||
include_once 'libraries/config/page_settings.forms.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @global array MySQL charsets map
|
||||
*/
|
||||
$GLOBALS['mysql_charset_map'] = array(
|
||||
'big5' => 'big5',
|
||||
'cp-866' => 'cp866',
|
||||
'euc-jp' => 'ujis',
|
||||
'euc-kr' => 'euckr',
|
||||
'gb2312' => 'gb2312',
|
||||
'gbk' => 'gbk',
|
||||
'iso-8859-1' => 'latin1',
|
||||
'iso-8859-2' => 'latin2',
|
||||
'iso-8859-7' => 'greek',
|
||||
'iso-8859-8' => 'hebrew',
|
||||
'iso-8859-8-i' => 'hebrew',
|
||||
'iso-8859-9' => 'latin5',
|
||||
'iso-8859-13' => 'latin7',
|
||||
'iso-8859-15' => 'latin1',
|
||||
'koi8-r' => 'koi8r',
|
||||
'shift_jis' => 'sjis',
|
||||
'tis-620' => 'tis620',
|
||||
'utf-8' => 'utf8',
|
||||
'windows-1250' => 'cp1250',
|
||||
'windows-1251' => 'cp1251',
|
||||
'windows-1252' => 'latin1',
|
||||
'windows-1256' => 'cp1256',
|
||||
'windows-1257' => 'cp1257',
|
||||
);
|
||||
|
||||
@ -15,6 +15,7 @@ use PMA\libraries\properties\options\items\NumberPropertyItem;
|
||||
use PMA\libraries\properties\options\groups\OptionsPropertyMainGroup;
|
||||
use PMA\libraries\properties\options\groups\OptionsPropertyRootGroup;
|
||||
use PMA\libraries\properties\options\groups\OptionsPropertySubgroup;
|
||||
use PMA\libraries\Charsets;
|
||||
use PMA\libraries\DatabaseInterface;
|
||||
use PMA\libraries\plugins\ExportPlugin;
|
||||
use PMA\libraries\Util;
|
||||
@ -624,7 +625,7 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter()
|
||||
{
|
||||
global $crlf, $mysql_charset_map;
|
||||
global $crlf;
|
||||
|
||||
$foot = '';
|
||||
|
||||
@ -665,7 +666,6 @@ class ExportSql extends ExportPlugin
|
||||
public function exportHeader()
|
||||
{
|
||||
global $crlf, $cfg;
|
||||
global $mysql_charset_map;
|
||||
|
||||
if (isset($GLOBALS['sql_compatibility'])) {
|
||||
$tmp_compat = $GLOBALS['sql_compatibility'];
|
||||
@ -739,13 +739,13 @@ class ExportSql extends ExportPlugin
|
||||
// so that a utility like the mysql client can interpret
|
||||
// the file correctly
|
||||
if (isset($GLOBALS['charset'])
|
||||
&& isset($mysql_charset_map[$GLOBALS['charset']])
|
||||
&& isset(Charsets::$mysql_charset_map[$GLOBALS['charset']])
|
||||
) {
|
||||
// we got a charset from the export dialog
|
||||
$set_names = $mysql_charset_map[$GLOBALS['charset']];
|
||||
$set_names = Charsets::$mysql_charset_map[$GLOBALS['charset']];
|
||||
} else {
|
||||
// by default we use the connection charset
|
||||
$set_names = $mysql_charset_map['utf-8'];
|
||||
$set_names = Charsets::$mysql_charset_map['utf-8'];
|
||||
}
|
||||
if ($set_names == 'utf8' && PMA_MYSQL_INT_VERSION > 50503) {
|
||||
$set_names = 'utf8mb4';
|
||||
|
||||
@ -451,7 +451,6 @@ class ExportSqlTest extends PMATestCase
|
||||
$GLOBALS['sql_disable_fk'] = true;
|
||||
$GLOBALS['sql_use_transaction'] = true;
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
$GLOBALS['mysql_charset_map']['utf-8'] = true;
|
||||
$GLOBALS['sql_utc_time'] = true;
|
||||
$GLOBALS['old_tz'] = 'GMT';
|
||||
$GLOBALS['asfile'] = 'yes';
|
||||
@ -501,7 +500,6 @@ class ExportSqlTest extends PMATestCase
|
||||
$GLOBALS['sql_use_transaction'] = true;
|
||||
$GLOBALS['sql_include_comments'] = true;
|
||||
$GLOBALS['charset'] = 'utf-8';
|
||||
$GLOBALS['mysql_charset_map']['utf-8'] = true;
|
||||
|
||||
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user