Initial import.
[openemr.git] / interface / main / myadmin / libraries / mysql_charsets.lib.php
blob52c76cc4fd5ee7cb3ece24787a042250cb02ddcd
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 if (PMA_MYSQL_INT_VERSION >= 40100){
7 $res = PMA_mysql_query('SHOW CHARACTER SET;', $userlink)
8 or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW CHARACTER SET;');
10 $mysql_charsets = array();
11 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
12 $mysql_charsets[] = $row['Charset'];
13 $mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen'];
14 $mysql_charsets_descriptions[$row['Charset']] = $row['Description'];
16 @mysql_free_result($res);
17 unset($res, $row);
19 $res = PMA_mysql_query('SHOW COLLATION;', $userlink)
20 or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW COLLATION;');
22 sort($mysql_charsets, SORT_STRING);
24 $mysql_collations = array_flip($mysql_charsets);
25 $mysql_default_collations = array();;
26 while ($row = PMA_mysql_fetch_array($res, MYSQL_ASSOC)) {
27 if (!is_array($mysql_collations[$row['Charset']])) {
28 $mysql_collations[$row['Charset']] = array($row['Collation']);
29 } else {
30 $mysql_collations[$row['Charset']][] = $row['Collation'];
32 if ((isset($row['D']) && $row['D'] == 'Y') || (isset($row['Default']) && $row['Default'] == 'Yes')) {
33 $mysql_default_collations[$row['Charset']] = $row['Collation'];
37 $mysql_collations_count = 0;
38 foreach($mysql_collations AS $key => $value) {
39 $mysql_collations_count += count($mysql_collations[$key]);
40 sort($mysql_collations[$key], SORT_STRING);
41 reset($mysql_collations[$key]);
44 @mysql_free_result($res);
45 unset($res, $row);
47 function PMA_getCollationDescr($collation) {
48 if ($collation == 'binary') {
49 return $GLOBALS['strBinary'];
51 $parts = explode('_', $collation);
52 if (count($parts) == 1) {
53 $parts[1] = 'general';
54 } elseif ($parts[1] == 'ci' || $parts[1] == 'cs') {
55 $parts[2] = $parts[1];
56 $parts[1] = 'general';
58 $descr = '';
59 switch ($parts[1]) {
60 case 'bulgarian':
61 $descr = $GLOBALS['strBulgarian'];
62 break;
63 case 'ci':
64 $descr = $GLOBALS['strCaseInsensitive'];
65 break;
66 case 'cs':
67 $descr = $GLOBALS['strCaseSensitive'];
68 break;
69 case 'croatian':
70 $descr = $GLOBALS['strCroatian'];
71 break;
72 case 'czech':
73 $descr = $GLOBALS['strCzech'];
74 break;
75 case 'danish':
76 $descr = $GLOBALS['strDanish'];
77 break;
78 case 'english':
79 $descr = $GLOBALS['strEnglish'];
80 break;
81 case 'estonian':
82 $descr = $GLOBALS['strEstonian'];
83 break;
84 case 'german1':
85 $descr = $GLOBALS['strGerman'] . ' (' . $GLOBALS['strDictionary'] . ')';
86 break;
87 case 'german2':
88 $descr = $GLOBALS['strGerman'] . ' (' . $GLOBALS['strPhoneBook'] . ')';
89 break;
90 case 'hungarian':
91 $descr = $GLOBALS['strHungarian'];
92 break;
93 case 'lithuanian':
94 $descr = $GLOBALS['strLithuanian'];
95 break;
96 case 'swedish':
97 $descr = $GLOBALS['strSwedish'];
98 break;
99 case 'turkish':
100 $descr = $GLOBALS['strTurkish'];
101 break;
102 case 'ukrainian':
103 $descr = $GLOBALS['strUkrainian'];
104 break;
105 case 'bin':
106 $is_bin = TRUE;
107 case 'general':
108 switch ($parts[0]) {
109 // Unicode charsets
110 case 'ucs2':
111 case 'utf8':
112 $descr = $GLOBALS['strUnicode'] . ' (' . $GLOBALS['strMultilingual'] . ')';
113 break;
114 // West European charsets
115 case 'ascii':
116 case 'cp850':
117 case 'dec8':
118 case 'hp8':
119 case 'latin1':
120 case 'macroman':
121 $descr = $GLOBALS['strWestEuropean'] . ' (' . $GLOBALS['strMultilingual'] . ')';
122 break;
123 // Central European charsets
124 case 'cp1250':
125 case 'cp852':
126 case 'latin2':
127 case 'macce':
128 $descr = $GLOBALS['strCentralEuropean'] . ' (' . $GLOBALS['strMultilingual'] . ')';
129 break;
130 // Russian charsets
131 case 'cp866':
132 case 'koi8r':
133 $descr = $GLOBALS['strRussian'];
134 break;
135 // Simplified Chinese charsets
136 case 'gb2312':
137 case 'gbk':
138 $descr = $GLOBALS['strSimplifiedChinese'];
139 break;
140 // Japanese charsets
141 case 'sjis':
142 case 'ujis':
143 $descr = $GLOBALS['strJapanese'];
144 break;
145 // Baltic charsets
146 case 'cp1257':
147 case 'latin7':
148 $descr = $GLOBALS['strBaltic'] . ' (' . $GLOBALS['strMultilingual'] . ')';
149 break;
150 // Other
151 case 'armscii8':
152 case 'armscii':
153 $descr = $GLOBALS['strArmenian'];
154 break;
155 case 'big5':
156 $descr = $GLOBALS['strTraditionalChinese'];
157 break;
158 case 'cp1251':
159 $descr = $GLOBALS['strCyrillic'] . ' (' . $GLOBALS['strMultilingual'] . ')';
160 break;
161 case 'cp1256':
162 $descr = $GLOBALS['strArabic'];
163 break;
164 case 'euckr':
165 $descr = $GLOBALS['strKorean'];
166 break;
167 case 'hebrew':
168 $descr = $GLOBALS['strHebrew'];
169 break;
170 case 'greek':
171 $descr = $GLOBALS['strGreek'];
172 break;
173 case 'koi8u':
174 $descr = $GLOBALS['strUkrainian'];
175 break;
176 case 'latin5':
177 $descr = $GLOBALS['strTurkish'];
178 break;
179 case 'swe7':
180 $descr = $GLOBALS['strSwedish'];
181 break;
182 case 'tis620':
183 $descr = $GLOBALS['strThai'];
184 break;
185 default:
186 $descr = $GLOBALS['strUnknown'];
187 break;
189 if (!empty($is_bin)) {
190 $descr .= ', ' . $GLOBALS['strBinary'];
192 break;
193 default: return '';
195 if (!empty($parts[2])) {
196 if ($parts[2] == 'ci') {
197 $descr .= ', ' . $GLOBALS['strCaseInsensitive'];
198 } elseif ($parts[2] == 'cs') {
199 $descr .= ', ' . $GLOBALS['strCaseSensitive'];
202 return $descr;