1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | /** |
---|
15 | @ingroup DC_CORE |
---|
16 | @brief Dotclear helper methods |
---|
17 | |
---|
18 | Provides some Dotclear helpers |
---|
19 | */ |
---|
20 | class dcUtils |
---|
21 | { |
---|
22 | /** |
---|
23 | Static function that returns user's common name given to his |
---|
24 | <var>user_id</var>, <var>user_name</var>, <var>user_firstname</var> and |
---|
25 | <var>user_displayname</var>. |
---|
26 | |
---|
27 | @param user_id <b>string</b> User ID |
---|
28 | @param user_name <b>string</b> User's name |
---|
29 | @param user_firstname <b>string</b> User's first name |
---|
30 | @param user_displayname <b>string</b> User's display name |
---|
31 | @return <b>string</b> |
---|
32 | */ |
---|
33 | public static function getUserCN($user_id, $user_name, $user_firstname, $user_displayname) |
---|
34 | { |
---|
35 | if (!empty($user_displayname)) { |
---|
36 | return $user_displayname; |
---|
37 | } |
---|
38 | |
---|
39 | if (!empty($user_name)) { |
---|
40 | if (!empty($user_firstname)) { |
---|
41 | return $user_firstname.' '.$user_name; |
---|
42 | } else { |
---|
43 | return $user_name; |
---|
44 | } |
---|
45 | } elseif (!empty($user_firstname)) { |
---|
46 | return $user_firstname; |
---|
47 | } |
---|
48 | |
---|
49 | return $user_id; |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | Cleanup a list of IDs |
---|
54 | |
---|
55 | @param ids <b>mixed</b> ID(s) |
---|
56 | @return <b>array</b> |
---|
57 | */ |
---|
58 | public static function cleanIds($ids) |
---|
59 | { |
---|
60 | $clean_ids = array(); |
---|
61 | |
---|
62 | if (!is_array($ids)) { |
---|
63 | $ids = array($ids); |
---|
64 | } |
---|
65 | |
---|
66 | foreach($ids as $id) |
---|
67 | { |
---|
68 | $id = abs((integer) $id); |
---|
69 | |
---|
70 | if (!empty($id)) { |
---|
71 | $clean_ids[] = $id; |
---|
72 | } |
---|
73 | } |
---|
74 | return $clean_ids; |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * Compare two versions with option of using only main numbers. |
---|
79 | * |
---|
80 | * @param string $current_version Current version |
---|
81 | * @param string $required_version Required version |
---|
82 | * @param string $operator Comparison operand |
---|
83 | * @param boolean $strict Use full version |
---|
84 | * @return boolean True if comparison success |
---|
85 | */ |
---|
86 | public static function versionsCompare($current_version, $required_version, $operator='>=', $strict=true) |
---|
87 | { |
---|
88 | if ($strict) { |
---|
89 | $current_version = preg_replace('!-r(\d+)$!', '-p$1', $current_version); |
---|
90 | $required_version = preg_replace('!-r(\d+)$!', '-p$1', $required_version); |
---|
91 | } |
---|
92 | else { |
---|
93 | $current_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $current_version); |
---|
94 | $required_version = preg_replace('/^([0-9\.]+)(.*?)$/', '$1', $required_version); |
---|
95 | } |
---|
96 | |
---|
97 | return (boolean) version_compare($current_version, $required_version, $operator); |
---|
98 | } |
---|
99 | |
---|
100 | private static function appendVersion($src,$v='') |
---|
101 | { |
---|
102 | $src .= (strpos($src,'?') === false ? '?' : '&').'v='; |
---|
103 | if (defined('DC_DEV') && DC_DEV === true) { |
---|
104 | $src .= md5(uniqid()); |
---|
105 | } else { |
---|
106 | $src .= ($v === '' ? DC_VERSION : $v); |
---|
107 | } |
---|
108 | return $src; |
---|
109 | } |
---|
110 | |
---|
111 | public static function cssLoad($src,$media='screen',$v=null) |
---|
112 | { |
---|
113 | $escaped_src = html::escapeHTML($src); |
---|
114 | if ($v !== null) { |
---|
115 | $escaped_src = dcUtils::appendVersion($escaped_src,$v); |
---|
116 | } |
---|
117 | return '<link rel="stylesheet" href="'.$escaped_src.'" type="text/css" media="'.$media.'" />'."\n"; |
---|
118 | } |
---|
119 | |
---|
120 | public static function jsLoad($src,$v=null) |
---|
121 | { |
---|
122 | $escaped_src = html::escapeHTML($src); |
---|
123 | if ($v !== null) { |
---|
124 | $escaped_src = dcUtils::appendVersion($escaped_src,$v); |
---|
125 | } |
---|
126 | return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n"; |
---|
127 | } |
---|
128 | |
---|
129 | public static function jsVars($vars) |
---|
130 | { |
---|
131 | $ret = '<script type="text/javascript">'."\n". |
---|
132 | "//<![CDATA[\n"; |
---|
133 | foreach ($vars as $var => $value) { |
---|
134 | $ret .= 'var '.$var.' = '.(is_string($value) ? '"'.html::escapeJS($value).'"' : $value).';'."\n"; |
---|
135 | } |
---|
136 | $ret .= "\n//]]>\n". |
---|
137 | "</script>\n"; |
---|
138 | |
---|
139 | return $ret; |
---|
140 | } |
---|
141 | |
---|
142 | public static function jsVar($n,$v) |
---|
143 | { |
---|
144 | return dcUtils::jsVars(array($n => $v)); |
---|
145 | } |
---|
146 | |
---|
147 | /** |
---|
148 | * Locale specific array sorting function |
---|
149 | * |
---|
150 | * @param array $arr single array of strings |
---|
151 | * @param string $ns admin/public/lang |
---|
152 | * @param string $lang language to be used if $ns = 'lang' |
---|
153 | */ |
---|
154 | public static function lexicalSort(&$arr,$ns='',$lang='en_US') |
---|
155 | { |
---|
156 | if ($ns != '') { |
---|
157 | dcUtils::setLexicalLang($ns,$lang); |
---|
158 | } |
---|
159 | return usort($arr,array('dcUtils','lexicalSortHelper')); |
---|
160 | } |
---|
161 | |
---|
162 | /** |
---|
163 | * Locale specific array sorting function (preserving keys) |
---|
164 | * |
---|
165 | * @param array $arr single array of strings |
---|
166 | * @param string $ns admin/public/lang |
---|
167 | * @param string $lang language to be used if $ns = 'lang' |
---|
168 | */ |
---|
169 | public static function lexicalArraySort(&$arr,$ns='',$lang='en_US') |
---|
170 | { |
---|
171 | if ($ns != '') { |
---|
172 | dcUtils::setLexicalLang($ns,$lang); |
---|
173 | } |
---|
174 | return uasort($arr,array('dcUtils','lexicalSortHelper')); |
---|
175 | } |
---|
176 | |
---|
177 | /** |
---|
178 | * Locale specific array sorting function (sorting keys) |
---|
179 | * |
---|
180 | * @param array $arr single array of strings |
---|
181 | * @param string $ns admin/public/lang |
---|
182 | * @param string $lang language to be used if $ns = 'lang' |
---|
183 | */ |
---|
184 | public static function lexicalKeySort(&$arr,$ns='',$lang='en_US') |
---|
185 | { |
---|
186 | if ($ns != '') { |
---|
187 | dcUtils::setLexicalLang($ns,$lang); |
---|
188 | } |
---|
189 | return uksort($arr,array('dcUtils','lexicalSortHelper')); |
---|
190 | } |
---|
191 | |
---|
192 | public static function setLexicalLang($ns='',$lang='en_US') |
---|
193 | { |
---|
194 | global $core; |
---|
195 | |
---|
196 | // Switch to appropriate locale depending on $ns |
---|
197 | switch ($ns) { |
---|
198 | case 'admin': |
---|
199 | // Set locale with user prefs |
---|
200 | $user_language = $core->auth->getInfo('user_lang'); |
---|
201 | setlocale(LC_COLLATE, $user_language); |
---|
202 | break; |
---|
203 | case 'public': |
---|
204 | // Set locale with blog params |
---|
205 | $blog_language = $core->blog->settings->system->lang; |
---|
206 | setlocale(LC_COLLATE, $blog_language); |
---|
207 | break; |
---|
208 | case 'lang': |
---|
209 | // Set locale with arg |
---|
210 | setlocale(LC_COLLATE, $lang); |
---|
211 | break; |
---|
212 | } |
---|
213 | } |
---|
214 | |
---|
215 | private static function lexicalSortHelper($a,$b) |
---|
216 | { |
---|
217 | return strcoll(strtolower(dcUtils::removeDiacritics($a)),strtolower(dcUtils::removeDiacritics($b))); |
---|
218 | } |
---|
219 | |
---|
220 | // removeDiacritics function (see https://github.com/infralabs/DiacriticsRemovePHP) |
---|
221 | |
---|
222 | protected static $defaultDiacriticsRemovalMap = array( |
---|
223 | array( |
---|
224 | 'base'=>"A", |
---|
225 | 'letters'=>'/(A|Ⓐ|A|À|Á|Â|Ầ|Ấ|Ẫ|Ẩ|Ã|Ā|Ă|Ằ|Ắ|Ẵ|Ẳ|Ȧ|Ǡ|Ä|Ǟ|Ả|Å|Ǻ|Ǎ|Ȁ|Ȃ|Ạ|Ậ|Ặ|Ḁ|Ą|Ⱥ|Ɐ|[\x{0041}\x{24B6}\x{FF21}\x{00C0}\x{00C1}\x{00C2}\x{1EA6}\x{1EA4}\x{1EAA}\x{1EA8}\x{00C3}\x{0100}\x{0102}\x{1EB0}\x{1EAE}\x{1EB4}\x{1EB2}\x{0226}\x{01E0}\x{00C4}\x{01DE}\x{1EA2}\x{00C5}\x{01FA}\x{01CD}\x{0200}\x{0202}\x{1EA0}\x{1EAC}\x{1EB6}\x{1E00}\x{0104}\x{023A}\x{2C6F}])/' |
---|
226 | ), |
---|
227 | array( |
---|
228 | 'base'=>"AA", |
---|
229 | 'letters'=>'/(Ꜳ|[\x{A732}])/' |
---|
230 | ), |
---|
231 | array( |
---|
232 | 'base'=>"AE", |
---|
233 | 'letters'=>'/(Æ|Ǽ|Ǣ|[\x{00C6}\x{01FC}\x{01E2}])/' |
---|
234 | ), |
---|
235 | array( |
---|
236 | 'base'=>"AO", |
---|
237 | 'letters'=>'/(Ꜵ|[\x{A734}])/' |
---|
238 | ), |
---|
239 | array( |
---|
240 | 'base'=>"AU", |
---|
241 | 'letters'=>'/(Ꜷ|[\x{A736}])/' |
---|
242 | ), |
---|
243 | array( |
---|
244 | 'base'=>"AV", |
---|
245 | 'letters'=>'/(Ꜹ|Ꜻ|[\x{A738}\x{A73A}])/' |
---|
246 | ), |
---|
247 | array( |
---|
248 | 'base'=>"AY", |
---|
249 | 'letters'=>'/(Ꜽ|[\x{A73C}])/' |
---|
250 | ), |
---|
251 | array( |
---|
252 | 'base'=>"B", |
---|
253 | 'letters'=>'/(B|Ⓑ|B|Ḃ|Ḅ|Ḇ|Ƀ|Ƃ|Ɓ|[\x{0042}\x{24B7}\x{FF22}\x{1E02}\x{1E04}\x{1E06}\x{0243}\x{0182}\x{0181}])/' |
---|
254 | ), |
---|
255 | array( |
---|
256 | 'base'=>"C", |
---|
257 | 'letters'=>'/(C|Ⓒ|C|Ć|Ĉ|Ċ|Č|Ç|Ḉ|Ƈ|Ȼ|Ꜿ|[\x{0043}\x{24B8}\x{FF23}\x{0106}\x{0108}\x{010A}\x{010C}\x{00C7}\x{1E08}\x{0187}\x{023B}\x{A73E}])/' |
---|
258 | ), |
---|
259 | array( |
---|
260 | 'base'=>"D", |
---|
261 | 'letters'=>'/(D|Ⓓ|D|Ḋ|Ď|Ḍ|Ḑ|Ḓ|Ḏ|Đ|Ƌ|Ɗ|Ɖ|Ꝺ|Ð|[\x{0044}\x{24B9}\x{FF24}\x{1E0A}\x{010E}\x{1E0C}\x{1E10}\x{1E12}\x{1E0E}\x{0110}\x{018B}\x{018A}\x{0189}\x{A779}\x{00D0}])/' |
---|
262 | ), |
---|
263 | array( |
---|
264 | 'base'=>"DZ", |
---|
265 | 'letters'=>'/(DZ|DŽ|[\x{01F1}\x{01C4}])/' |
---|
266 | ), |
---|
267 | array( |
---|
268 | 'base'=>"Dz", |
---|
269 | 'letters'=>'/(Dz|Dž|[\x{01F2}\x{01C5}])/' |
---|
270 | ), |
---|
271 | array( |
---|
272 | 'base'=>"E", |
---|
273 | 'letters'=>'/(E|Ⓔ|E|È|É|Ê|Ề|Ế|Ễ|Ể|Ẽ|Ē|Ḕ|Ḗ|Ĕ|Ė|Ë|Ẻ|Ě|Ȅ|Ȇ|Ẹ|Ệ|Ȩ|Ḝ|Ę|Ḙ|Ḛ|Ɛ|Ǝ|[\x{0045}\x{24BA}\x{FF25}\x{00C8}\x{00C9}\x{00CA}\x{1EC0}\x{1EBE}\x{1EC4}\x{1EC2}\x{1EBC}\x{0112}\x{1E14}\x{1E16}\x{0114}\x{0116}\x{00CB}\x{1EBA}\x{011A}\x{0204}\x{0206}\x{1EB8}\x{1EC6}\x{0228}\x{1E1C}\x{0118}\x{1E18}\x{1E1A}\x{0190}\x{018E}])/' |
---|
274 | ), |
---|
275 | array( |
---|
276 | 'base'=>"F", |
---|
277 | 'letters'=>'/(F|Ⓕ|F|Ḟ|Ƒ|Ꝼ|[\x{0046}\x{24BB}\x{FF26}\x{1E1E}\x{0191}\x{A77B}])/' |
---|
278 | ), |
---|
279 | array( |
---|
280 | 'base'=>"G", |
---|
281 | 'letters'=>'/(G|Ⓖ|G|Ǵ|Ĝ|Ḡ|Ğ|Ġ|Ǧ|Ģ|Ǥ|Ɠ|Ꞡ|Ᵹ|Ꝿ|[\x{0047}\x{24BC}\x{FF27}\x{01F4}\x{011C}\x{1E20}\x{011E}\x{0120}\x{01E6}\x{0122}\x{01E4}\x{0193}\x{A7A0}\x{A77D}\x{A77E}])/' |
---|
282 | ), |
---|
283 | array( |
---|
284 | 'base'=>"H", |
---|
285 | 'letters'=>'/(H|Ⓗ|H|Ĥ|Ḣ|Ḧ|Ȟ|Ḥ|Ḩ|Ḫ|Ħ|Ⱨ|Ⱶ|Ɥ|[\x{0048}\x{24BD}\x{FF28}\x{0124}\x{1E22}\x{1E26}\x{021E}\x{1E24}\x{1E28}\x{1E2A}\x{0126}\x{2C67}\x{2C75}\x{A78D}])/' |
---|
286 | ), |
---|
287 | array( |
---|
288 | 'base'=>"I", |
---|
289 | 'letters'=>'/(I|Ⓘ|I|Ì|Í|Î|Ĩ|Ī|Ĭ|İ|Ï|Ḯ|Ỉ|Ǐ|Ȉ|Ȋ|Ị|Į|Ḭ|Ɨ|[\x{0049}\x{24BE}\x{FF29}\x{00CC}\x{00CD}\x{00CE}\x{0128}\x{012A}\x{012C}\x{0130}\x{00CF}\x{1E2E}\x{1EC8}\x{01CF}\x{0208}\x{020A}\x{1ECA}\x{012E}\x{1E2C}\x{0197}])/' |
---|
290 | ), |
---|
291 | array( |
---|
292 | 'base'=>"J", |
---|
293 | 'letters'=>'/(J|Ⓙ|J|Ĵ|Ɉ|[\x{004A}\x{24BF}\x{FF2A}\x{0134}\x{0248}])/' |
---|
294 | ), |
---|
295 | array( |
---|
296 | 'base'=>"K", |
---|
297 | 'letters'=>'/(K|Ⓚ|K|Ḱ|Ǩ|Ḳ|Ķ|Ḵ|Ƙ|Ⱪ|Ꝁ|Ꝃ|Ꝅ|Ꞣ|[\x{004B}\x{24C0}\x{FF2B}\x{1E30}\x{01E8}\x{1E32}\x{0136}\x{1E34}\x{0198}\x{2C69}\x{A740}\x{A742}\x{A744}\x{A7A2}])/' |
---|
298 | ), |
---|
299 | array( |
---|
300 | 'base'=>"L", |
---|
301 | 'letters'=>'/(L|Ⓛ|L|Ŀ|Ĺ|Ľ|Ḷ|Ḹ|Ļ|Ḽ|Ḻ|Ł|Ƚ|Ɫ|Ⱡ|Ꝉ|Ꝇ|Ꞁ|[\x{004C}\x{24C1}\x{FF2C}\x{013F}\x{0139}\x{013D}\x{1E36}\x{1E38}\x{013B}\x{1E3C}\x{1E3A}\x{0141}\x{023D}\x{2C62}\x{2C60}\x{A748}\x{A746}\x{A780}])/' |
---|
302 | ), |
---|
303 | array( |
---|
304 | 'base'=>"LJ", |
---|
305 | 'letters'=>'/(LJ|[\x{01C7}])/' |
---|
306 | ), |
---|
307 | array( |
---|
308 | 'base'=>"Lj", |
---|
309 | 'letters'=>'/(Lj|[\x{01C8}])/' |
---|
310 | ), |
---|
311 | array( |
---|
312 | 'base'=>"M", |
---|
313 | 'letters'=>'/(M|Ⓜ|M|Ḿ|Ṁ|Ṃ|Ɱ|Ɯ|[\x{004D}\x{24C2}\x{FF2D}\x{1E3E}\x{1E40}\x{1E42}\x{2C6E}\x{019C}])/' |
---|
314 | ), |
---|
315 | array( |
---|
316 | 'base'=>"N", |
---|
317 | 'letters'=>'/(N|Ⓝ|N|Ǹ|Ń|Ñ|Ṅ|Ň|Ṇ|Ņ|Ṋ|Ṉ|Ƞ|Ɲ|Ꞑ|Ꞥ|Ŋ|[\x{004E}\x{24C3}\x{FF2E}\x{01F8}\x{0143}\x{00D1}\x{1E44}\x{0147}\x{1E46}\x{0145}\x{1E4A}\x{1E48}\x{0220}\x{019D}\x{A790}\x{A7A4}\x{014A}])/' |
---|
318 | ), |
---|
319 | array( |
---|
320 | 'base'=>"NJ", |
---|
321 | 'letters'=>'/(NJ|[\x{01CA}])/' |
---|
322 | ), |
---|
323 | array( |
---|
324 | 'base'=>"Nj", |
---|
325 | 'letters'=>'/(Nj|[\x{01CB}])/' |
---|
326 | ), |
---|
327 | array( |
---|
328 | 'base'=>"O", |
---|
329 | 'letters'=>'/(O|Ⓞ|O|Ò|Ó|Ô|Ồ|Ố|Ỗ|Ổ|Õ|Ṍ|Ȭ|Ṏ|Ō|Ṑ|Ṓ|Ŏ|Ȯ|Ȱ|Ö|Ȫ|Ỏ|Ő|Ǒ|Ȍ|Ȏ|Ơ|Ờ|Ớ|Ỡ|Ở|Ợ|Ọ|Ộ|Ǫ|Ǭ|Ø|Ǿ|Ɔ|Ɵ|Ꝋ|Ꝍ|[\x{004F}\x{24C4}\x{FF2F}\x{00D2}\x{00D3}\x{00D4}\x{1ED2}\x{1ED0}\x{1ED6}\x{1ED4}\x{00D5}\x{1E4C}\x{022C}\x{1E4E}\x{014C}\x{1E50}\x{1E52}\x{014E}\x{022E}\x{0230}\x{00D6}\x{022A}\x{1ECE}\x{0150}\x{01D1}\x{020C}\x{020E}\x{01A0}\x{1EDC}\x{1EDA}\x{1EE0}\x{1EDE}\x{1EE2}\x{1ECC}\x{1ED8}\x{01EA}\x{01EC}\x{00D8}\x{01FE}\x{0186}\x{019F}\x{A74A}\x{A74C}])/' |
---|
330 | ), |
---|
331 | array( |
---|
332 | 'base'=>"OE", |
---|
333 | 'letters'=>'/(Œ|[\x{0152}])/' |
---|
334 | ), |
---|
335 | array( |
---|
336 | 'base'=>"OI", |
---|
337 | 'letters'=>'/(Ƣ|[\x{01A2}])/' |
---|
338 | ), |
---|
339 | array( |
---|
340 | 'base'=>"OO", |
---|
341 | 'letters'=>'/(Ꝏ|[\x{A74E}])/' |
---|
342 | ), |
---|
343 | array( |
---|
344 | 'base'=>"OU", |
---|
345 | 'letters'=>'/(Ȣ|[\x{0222}])/' |
---|
346 | ), |
---|
347 | array( |
---|
348 | 'base'=>"P", |
---|
349 | 'letters'=>'/(P|Ⓟ|P|Ṕ|Ṗ|Ƥ|Ᵽ|Ꝑ|Ꝓ|Ꝕ|[\x{0050}\x{24C5}\x{FF30}\x{1E54}\x{1E56}\x{01A4}\x{2C63}\x{A750}\x{A752}\x{A754}])/' |
---|
350 | ), |
---|
351 | array( |
---|
352 | 'base'=>"Q", |
---|
353 | 'letters'=>'/(Q|Ⓠ|Q|Ꝗ|Ꝙ|Ɋ|[\x{0051}\x{24C6}\x{FF31}\x{A756}\x{A758}\x{024A}])/' |
---|
354 | ), |
---|
355 | array( |
---|
356 | 'base'=>"R", |
---|
357 | 'letters'=>'/(R|Ⓡ|R|Ŕ|Ṙ|Ř|Ȑ|Ȓ|Ṛ|Ṝ|Ŗ|Ṟ|Ɍ|Ɽ|Ꝛ|Ꞧ|Ꞃ|[\x{0052}\x{24C7}\x{FF32}\x{0154}\x{1E58}\x{0158}\x{0210}\x{0212}\x{1E5A}\x{1E5C}\x{0156}\x{1E5E}\x{024C}\x{2C64}\x{A75A}\x{A7A6}\x{A782}])/' |
---|
358 | ), |
---|
359 | array( |
---|
360 | 'base'=>"S", |
---|
361 | 'letters'=>'/(S|Ⓢ|S|ẞ|Ś|Ṥ|Ŝ|Ṡ|Š|Ṧ|Ṣ|Ṩ|Ș|Ş|Ȿ|Ꞩ|Ꞅ|[\x{0053}\x{24C8}\x{FF33}\x{1E9E}\x{015A}\x{1E64}\x{015C}\x{1E60}\x{0160}\x{1E66}\x{1E62}\x{1E68}\x{0218}\x{015E}\x{2C7E}\x{A7A8}\x{A784}])/' |
---|
362 | ), |
---|
363 | array( |
---|
364 | 'base'=>"T", |
---|
365 | 'letters'=>'/(T|Ⓣ|T|Ṫ|Ť|Ṭ|Ț|Ţ|Ṱ|Ṯ|Ŧ|Ƭ|Ʈ|Ⱦ|Ꞇ|[\x{0054}\x{24C9}\x{FF34}\x{1E6A}\x{0164}\x{1E6C}\x{021A}\x{0162}\x{1E70}\x{1E6E}\x{0166}\x{01AC}\x{01AE}\x{023E}\x{A786}])/' |
---|
366 | ), |
---|
367 | array( |
---|
368 | 'base'=>"TH", |
---|
369 | 'letters'=>'/(Þ|[\x{00DE}])/' |
---|
370 | ), |
---|
371 | array( |
---|
372 | 'base'=>"TZ", |
---|
373 | 'letters'=>'/(Ꜩ|[\x{A728}])/' |
---|
374 | ), |
---|
375 | array( |
---|
376 | 'base'=>"U", |
---|
377 | 'letters'=>'/(U|Ⓤ|U|Ù|Ú|Û|Ũ|Ṹ|Ū|Ṻ|Ŭ|Ü|Ǜ|Ǘ|Ǖ|Ǚ|Ủ|Ů|Ű|Ǔ|Ȕ|Ȗ|Ư|Ừ|Ứ|Ữ|Ử|Ự|Ụ|Ṳ|Ų|Ṷ|Ṵ|Ʉ|[\x{0055}\x{24CA}\x{FF35}\x{00D9}\x{00DA}\x{00DB}\x{0168}\x{1E78}\x{016A}\x{1E7A}\x{016C}\x{00DC}\x{01DB}\x{01D7}\x{01D5}\x{01D9}\x{1EE6}\x{016E}\x{0170}\x{01D3}\x{0214}\x{0216}\x{01AF}\x{1EEA}\x{1EE8}\x{1EEE}\x{1EEC}\x{1EF0}\x{1EE4}\x{1E72}\x{0172}\x{1E76}\x{1E74}\x{0244}])/' |
---|
378 | ), |
---|
379 | array( |
---|
380 | 'base'=>"V", |
---|
381 | 'letters'=>'/(V|Ⓥ|V|Ṽ|Ṿ|Ʋ|Ꝟ|Ʌ|[\x{0056}\x{24CB}\x{FF36}\x{1E7C}\x{1E7E}\x{01B2}\x{A75E}\x{0245}])/' |
---|
382 | ), |
---|
383 | array( |
---|
384 | 'base'=>"VY", |
---|
385 | 'letters'=>'/(Ꝡ|[\x{A760}])/' |
---|
386 | ), |
---|
387 | array( |
---|
388 | 'base'=>"W", |
---|
389 | 'letters'=>'/(W|Ⓦ|W|Ẁ|Ẃ|Ŵ|Ẇ|Ẅ|Ẉ|Ⱳ|[\x{0057}\x{24CC}\x{FF37}\x{1E80}\x{1E82}\x{0174}\x{1E86}\x{1E84}\x{1E88}\x{2C72}])/' |
---|
390 | ), |
---|
391 | array( |
---|
392 | 'base'=>"X", |
---|
393 | 'letters'=>'/(X|Ⓧ|X|Ẋ|Ẍ|[\x{0058}\x{24CD}\x{FF38}\x{1E8A}\x{1E8C}])/' |
---|
394 | ), |
---|
395 | array( |
---|
396 | 'base'=>"Y", |
---|
397 | 'letters'=>'/(Y|Ⓨ|Y|Ỳ|Ý|Ŷ|Ỹ|Ȳ|Ẏ|Ÿ|Ỷ|Ỵ|Ƴ|Ɏ|Ỿ|[\x{0059}\x{24CE}\x{FF39}\x{1EF2}\x{00DD}\x{0176}\x{1EF8}\x{0232}\x{1E8E}\x{0178}\x{1EF6}\x{1EF4}\x{01B3}\x{024E}\x{1EFE}])/' |
---|
398 | ), |
---|
399 | array( |
---|
400 | 'base'=>"Z", |
---|
401 | 'letters'=>'/(Z|Ⓩ|Z|Ź|Ẑ|Ż|Ž|Ẓ|Ẕ|Ƶ|Ȥ|Ɀ|Ⱬ|Ꝣ|[\x{005A}\x{24CF}\x{FF3A}\x{0179}\x{1E90}\x{017B}\x{017D}\x{1E92}\x{1E94}\x{01B5}\x{0224}\x{2C7F}\x{2C6B}\x{A762}])/' |
---|
402 | ), |
---|
403 | array( |
---|
404 | 'base'=>"a", |
---|
405 | 'letters'=>'/(a|ⓐ|a|ẚ|à|á|â|ầ|ấ|ẫ|ẩ|ã|ā|ă|ằ|ắ|ẵ|ẳ|ȧ|ǡ|ä|ǟ|ả|å|ǻ|ǎ|ȁ|ȃ|ạ|ậ|ặ|ḁ|ą|ⱥ|ɐ|[\x{0061}\x{24D0}\x{FF41}\x{1E9A}\x{00E0}\x{00E1}\x{00E2}\x{1EA7}\x{1EA5}\x{1EAB}\x{1EA9}\x{00E3}\x{0101}\x{0103}\x{1EB1}\x{1EAF}\x{1EB5}\x{1EB3}\x{0227}\x{01E1}\x{00E4}\x{01DF}\x{1EA3}\x{00E5}\x{01FB}\x{01CE}\x{0201}\x{0203}\x{1EA1}\x{1EAD}\x{1EB7}\x{1E01}\x{0105}\x{2C65}\x{0250}])/' |
---|
406 | ), |
---|
407 | array( |
---|
408 | 'base'=>"aa", |
---|
409 | 'letters'=>'/(ꜳ|[\x{A733}])/' |
---|
410 | ), |
---|
411 | array( |
---|
412 | 'base'=>"ae", |
---|
413 | 'letters'=>'/(æ|ǽ|ǣ|[\x{00E6}\x{01FD}\x{01E3}])/' |
---|
414 | ), |
---|
415 | array( |
---|
416 | 'base'=>"ao", |
---|
417 | 'letters'=>'/(ꜵ|[\x{A735}])/' |
---|
418 | ), |
---|
419 | array( |
---|
420 | 'base'=>"au", |
---|
421 | 'letters'=>'/(ꜷ|[\x{A737}])/' |
---|
422 | ), |
---|
423 | array( |
---|
424 | 'base'=>"av", |
---|
425 | 'letters'=>'/(ꜹ|ꜻ|[\x{A739}\x{A73B}])/' |
---|
426 | ), |
---|
427 | array( |
---|
428 | 'base'=>"ay", |
---|
429 | 'letters'=>'/(ꜽ|[\x{A73D}])/' |
---|
430 | ), |
---|
431 | array( |
---|
432 | 'base'=>"b", |
---|
433 | 'letters'=>'/(b|ⓑ|b|ḃ|ḅ|ḇ|ƀ|ƃ|ɓ|[\x{0062}\x{24D1}\x{FF42}\x{1E03}\x{1E05}\x{1E07}\x{0180}\x{0183}\x{0253}])/' |
---|
434 | ), |
---|
435 | array( |
---|
436 | 'base'=>"c", |
---|
437 | 'letters'=>'/(c|ⓒ|c|ć|ĉ|ċ|č|ç|ḉ|ƈ|ȼ|ꜿ|ↄ|[\x{0063}\x{24D2}\x{FF43}\x{0107}\x{0109}\x{010B}\x{010D}\x{00E7}\x{1E09}\x{0188}\x{023C}\x{A73F}\x{2184}])/' |
---|
438 | ), |
---|
439 | array( |
---|
440 | 'base'=>"d", |
---|
441 | 'letters'=>'/(d|ⓓ|d|ḋ|ď|ḍ|ḑ|ḓ|ḏ|đ|ƌ|ɖ|ɗ|ꝺ|ð|[\x{0064}\x{24D3}\x{FF44}\x{1E0B}\x{010F}\x{1E0D}\x{1E11}\x{1E13}\x{1E0F}\x{0111}\x{018C}\x{0256}\x{0257}\x{A77A}\x{00F0}])/' |
---|
442 | ), |
---|
443 | array( |
---|
444 | 'base'=>"dz", |
---|
445 | 'letters'=>'/(dz|dž|[\x{01F3}\x{01C6}])/' |
---|
446 | ), |
---|
447 | array( |
---|
448 | 'base'=>"e", |
---|
449 | 'letters'=>'/(e|ⓔ|e|è|é|ê|ề|ế|ễ|ể|ẽ|ē|ḕ|ḗ|ĕ|ė|ë|ẻ|ě|ȅ|ȇ|ẹ|ệ|ȩ|ḝ|ę|ḙ|ḛ|ɇ|ɛ|ǝ|[\x{0065}\x{24D4}\x{FF45}\x{00E8}\x{00E9}\x{00EA}\x{1EC1}\x{1EBF}\x{1EC5}\x{1EC3}\x{1EBD}\x{0113}\x{1E15}\x{1E17}\x{0115}\x{0117}\x{00EB}\x{1EBB}\x{011B}\x{0205}\x{0207}\x{1EB9}\x{1EC7}\x{0229}\x{1E1D}\x{0119}\x{1E19}\x{1E1B}\x{0247}\x{025B}\x{01DD}])/' |
---|
450 | ), |
---|
451 | array( |
---|
452 | 'base'=>"f", |
---|
453 | 'letters'=>'/(f|ⓕ|f|ḟ|ƒ|ꝼ|[\x{0066}\x{24D5}\x{FF46}\x{1E1F}\x{0192}\x{A77C}])/' |
---|
454 | ), |
---|
455 | array( |
---|
456 | 'base'=>"g", |
---|
457 | 'letters'=>'/(g|ⓖ|g|ǵ|ĝ|ḡ|ğ|ġ|ǧ|ģ|ǥ|ɠ|ꞡ|ᵹ|ꝿ|[\x{0067}\x{24D6}\x{FF47}\x{01F5}\x{011D}\x{1E21}\x{011F}\x{0121}\x{01E7}\x{0123}\x{01E5}\x{0260}\x{A7A1}\x{1D79}\x{A77F}])/' |
---|
458 | ), |
---|
459 | array( |
---|
460 | 'base'=>"h", |
---|
461 | 'letters'=>'/(h|ⓗ|h|ĥ|ḣ|ḧ|ȟ|ḥ|ḩ|ḫ|ẖ|ħ|ⱨ|ⱶ|ɥ|[\x{0068}\x{24D7}\x{FF48}\x{0125}\x{1E23}\x{1E27}\x{021F}\x{1E25}\x{1E29}\x{1E2B}\x{1E96}\x{0127}\x{2C68}\x{2C76}\x{0265}])/' |
---|
462 | ), |
---|
463 | array( |
---|
464 | 'base'=>"hv", |
---|
465 | 'letters'=>'/(ƕ|[\x{0195}])/' |
---|
466 | ), |
---|
467 | array( |
---|
468 | 'base'=>"i", |
---|
469 | 'letters'=>'/(i|ⓘ|i|ì|í|î|ĩ|ī|ĭ|ï|ḯ|ỉ|ǐ|ȉ|ȋ|ị|į|ḭ|ɨ|ı|[\x{0069}\x{24D8}\x{FF49}\x{00EC}\x{00ED}\x{00EE}\x{0129}\x{012B}\x{012D}\x{00EF}\x{1E2F}\x{1EC9}\x{01D0}\x{0209}\x{020B}\x{1ECB}\x{012F}\x{1E2D}\x{0268}\x{0131}])/' |
---|
470 | ), |
---|
471 | array( |
---|
472 | 'base'=>"ij", |
---|
473 | 'letters'=>'/(ij|[\x{0133}])/' |
---|
474 | ), |
---|
475 | array( |
---|
476 | 'base'=>"j", |
---|
477 | 'letters'=>'/(j|ⓙ|j|ĵ|ǰ|ɉ|[\x{006A}\x{24D9}\x{FF4A}\x{0135}\x{01F0}\x{0249}])/' |
---|
478 | ), |
---|
479 | array( |
---|
480 | 'base'=>"k", |
---|
481 | 'letters'=>'/(k|ⓚ|k|ḱ|ǩ|ḳ|ķ|ḵ|ƙ|ⱪ|ꝁ|ꝃ|ꝅ|ꞣ|[\x{006B}\x{24DA}\x{FF4B}\x{1E31}\x{01E9}\x{1E33}\x{0137}\x{1E35}\x{0199}\x{2C6A}\x{A741}\x{A743}\x{A745}\x{A7A3}])/' |
---|
482 | ), |
---|
483 | array( |
---|
484 | 'base'=>"l", |
---|
485 | 'letters'=>'/(l|ⓛ|l|ŀ|ĺ|ľ|ḷ|ḹ|ļ|ḽ|ḻ|ł|ƚ|ɫ|ⱡ|ꝉ|ꞁ|ꝇ|[\x{006C}\x{24DB}\x{FF4C}\x{0140}\x{013A}\x{013E}\x{1E37}\x{1E39}\x{013C}\x{1E3D}\x{1E3B}\x{0142}\x{019A}\x{026B}\x{2C61}\x{A749}\x{A781}\x{A747}])/' |
---|
486 | ), |
---|
487 | array( |
---|
488 | 'base'=>"lj", |
---|
489 | 'letters'=>'/(lj|[\x{01C9}])/' |
---|
490 | ), |
---|
491 | array( |
---|
492 | 'base'=>"m", |
---|
493 | 'letters'=>'/(m|ⓜ|m|ḿ|ṁ|ṃ|ɱ|ɯ|[\x{006D}\x{24DC}\x{FF4D}\x{1E3F}\x{1E41}\x{1E43}\x{0271}\x{026F}])/' |
---|
494 | ), |
---|
495 | array( |
---|
496 | 'base'=>"n", |
---|
497 | 'letters'=>'/(n|ⓝ|n|ǹ|ń|ñ|ṅ|ň|ṇ|ņ|ṋ|ṉ|ƞ|ɲ|ʼn|ꞑ|ꞥ|ŋ|[\x{006E}\x{24DD}\x{FF4E}\x{01F9}\x{0144}\x{00F1}\x{1E45}\x{0148}\x{1E47}\x{0146}\x{1E4B}\x{1E49}\x{019E}\x{0272}\x{0149}\x{A791}\x{A7A5}\x{014B}])/' |
---|
498 | ), |
---|
499 | array( |
---|
500 | 'base'=>"nj", |
---|
501 | 'letters'=>'/(nj|[\x{01CC}])/' |
---|
502 | ), |
---|
503 | array( |
---|
504 | 'base'=>"o", |
---|
505 | 'letters'=>'/(o|ⓞ|o|ò|ó|ô|ồ|ố|ỗ|ổ|õ|ṍ|ȭ|ṏ|ō|ṑ|ṓ|ŏ|ȯ|ȱ|ö|ȫ|ỏ|ő|ǒ|ȍ|ȏ|ơ|ờ|ớ|ỡ|ở|ợ|ọ|ộ|ǫ|ǭ|ø|ǿ|ɔ|ꝋ|ꝍ|ɵ|[\x{006F}\x{24DE}\x{FF4F}\x{00F2}\x{00F3}\x{00F4}\x{1ED3}\x{1ED1}\x{1ED7}\x{1ED5}\x{00F5}\x{1E4D}\x{022D}\x{1E4F}\x{014D}\x{1E51}\x{1E53}\x{014F}\x{022F}\x{0231}\x{00F6}\x{022B}\x{1ECF}\x{0151}\x{01D2}\x{020D}\x{020F}\x{01A1}\x{1EDD}\x{1EDB}\x{1EE1}\x{1EDF}\x{1EE3}\x{1ECD}\x{1ED9}\x{01EB}\x{01ED}\x{00F8}\x{01FF}\x{0254}\x{A74B}\x{A74D}\x{0275}])/' |
---|
506 | ), |
---|
507 | array( |
---|
508 | 'base'=>"oe", |
---|
509 | 'letters'=>'/(œ|[\x{0153}])/' |
---|
510 | ), |
---|
511 | array( |
---|
512 | 'base'=>"oi", |
---|
513 | 'letters'=>'/(ƣ|[\x{01A3}])/' |
---|
514 | ), |
---|
515 | array( |
---|
516 | 'base'=>"ou", |
---|
517 | 'letters'=>'/(ȣ|[\x{0223}])/' |
---|
518 | ), |
---|
519 | array( |
---|
520 | 'base'=>"oo", |
---|
521 | 'letters'=>'/(ꝏ|[\x{A74F}])/' |
---|
522 | ), |
---|
523 | array( |
---|
524 | 'base'=>"p", |
---|
525 | 'letters'=>'/(p|ⓟ|p|ṕ|ṗ|ƥ|ᵽ|ꝑ|ꝓ|ꝕ|[\x{0070}\x{24DF}\x{FF50}\x{1E55}\x{1E57}\x{01A5}\x{1D7D}\x{A751}\x{A753}\x{A755}])/' |
---|
526 | ), |
---|
527 | array( |
---|
528 | 'base'=>"q", |
---|
529 | 'letters'=>'/(q|ⓠ|q|ɋ|ꝗ|ꝙ|[\x{0071}\x{24E0}\x{FF51}\x{024B}\x{A757}\x{A759}])/' |
---|
530 | ), |
---|
531 | array( |
---|
532 | 'base'=>"r", |
---|
533 | 'letters'=>'/(r|ⓡ|r|ŕ|ṙ|ř|ȑ|ȓ|ṛ|ṝ|ŗ|ṟ|ɍ|ɽ|ꝛ|ꞧ|ꞃ|[\x{0072}\x{24E1}\x{FF52}\x{0155}\x{1E59}\x{0159}\x{0211}\x{0213}\x{1E5B}\x{1E5D}\x{0157}\x{1E5F}\x{024D}\x{027D}\x{A75B}\x{A7A7}\x{A783}])/' |
---|
534 | ), |
---|
535 | array( |
---|
536 | 'base'=>"s", |
---|
537 | 'letters'=>'/(s|ⓢ|s|ś|ṥ|ŝ|ṡ|š|ṧ|ṣ|ṩ|ș|ş|ȿ|ꞩ|ꞅ|ẛ|ſ|[\x{0073}\x{24E2}\x{FF53}\x{015B}\x{1E65}\x{015D}\x{1E61}\x{0161}\x{1E67}\x{1E63}\x{1E69}\x{0219}\x{015F}\x{023F}\x{A7A9}\x{A785}\x{1E9B}\x{017F}])/' |
---|
538 | ), |
---|
539 | array( |
---|
540 | 'base'=>"ss", |
---|
541 | 'letters'=>'/(ß|[\x{00DF}])/' |
---|
542 | ), |
---|
543 | array( |
---|
544 | 'base'=>"t", |
---|
545 | 'letters'=>'/(t|ⓣ|t|ṫ|ẗ|ť|ṭ|ț|ţ|ṱ|ṯ|ŧ|ƭ|ʈ|ⱦ|ꞇ|[\x{0074}\x{24E3}\x{FF54}\x{1E6B}\x{1E97}\x{0165}\x{1E6D}\x{021B}\x{0163}\x{1E71}\x{1E6F}\x{0167}\x{01AD}\x{0288}\x{2C66}\x{A787}])/' |
---|
546 | ), |
---|
547 | array( |
---|
548 | 'base'=>"th", |
---|
549 | 'letters'=>'/(þ|[\x{00FE}])/' |
---|
550 | ), |
---|
551 | array( |
---|
552 | 'base'=>"tz", |
---|
553 | 'letters'=>'/(ꜩ|[\x{A729}])/' |
---|
554 | ), |
---|
555 | array( |
---|
556 | 'base'=>"u", |
---|
557 | 'letters'=>'/(u|ⓤ|u|ù|ú|û|ũ|ṹ|ū|ṻ|ŭ|ü|ǜ|ǘ|ǖ|ǚ|ủ|ů|ű|ǔ|ȕ|ȗ|ư|ừ|ứ|ữ|ử|ự|ụ|ṳ|ų|ṷ|ṵ|ʉ|[\x{0075}\x{24E4}\x{FF55}\x{00F9}\x{00FA}\x{00FB}\x{0169}\x{1E79}\x{016B}\x{1E7B}\x{016D}\x{00FC}\x{01DC}\x{01D8}\x{01D6}\x{01DA}\x{1EE7}\x{016F}\x{0171}\x{01D4}\x{0215}\x{0217}\x{01B0}\x{1EEB}\x{1EE9}\x{1EEF}\x{1EED}\x{1EF1}\x{1EE5}\x{1E73}\x{0173}\x{1E77}\x{1E75}\x{0289}])/' |
---|
558 | ), |
---|
559 | array( |
---|
560 | 'base'=>"v", |
---|
561 | 'letters'=>'/(v|ⓥ|v|ṽ|ṿ|ʋ|ꝟ|ʌ|[\x{0076}\x{24E5}\x{FF56}\x{1E7D}\x{1E7F}\x{028B}\x{A75F}\x{028C}])/' |
---|
562 | ), |
---|
563 | array( |
---|
564 | 'base'=>"vy", |
---|
565 | 'letters'=>'/(ꝡ|[\x{A761}])/' |
---|
566 | ), |
---|
567 | array( |
---|
568 | 'base'=>"w", |
---|
569 | 'letters'=>'/(w|ⓦ|w|ẁ|ẃ|ŵ|ẇ|ẅ|ẘ|ẉ|ⱳ|[\x{0077}\x{24E6}\x{FF57}\x{1E81}\x{1E83}\x{0175}\x{1E87}\x{1E85}\x{1E98}\x{1E89}\x{2C73}])/' |
---|
570 | ), |
---|
571 | array( |
---|
572 | 'base'=>"x", |
---|
573 | 'letters'=>'/(x|ⓧ|x|ẋ|ẍ|[\x{0078}\x{24E7}\x{FF58}\x{1E8B}\x{1E8D}])/' |
---|
574 | ), |
---|
575 | array( |
---|
576 | 'base'=>"y", |
---|
577 | 'letters'=>'/(y|ⓨ|y|ỳ|ý|ŷ|ỹ|ȳ|ẏ|ÿ|ỷ|ẙ|ỵ|ƴ|ɏ|ỿ|[\x{0079}\x{24E8}\x{FF59}\x{1EF3}\x{00FD}\x{0177}\x{1EF9}\x{0233}\x{1E8F}\x{00FF}\x{1EF7}\x{1E99}\x{1EF5}\x{01B4}\x{024F}\x{1EFF}])/' |
---|
578 | ), |
---|
579 | array( |
---|
580 | 'base'=>"z", |
---|
581 | 'letters'=>'/(z|ⓩ|z|ź|ẑ|ż|ž|ẓ|ẕ|ƶ|ȥ|ɀ|ⱬ|ꝣ|[\x{007A}\x{24E9}\x{FF5A}\x{017A}\x{1E91}\x{017C}\x{017E}\x{1E93}\x{1E95}\x{01B6}\x{0225}\x{0240}\x{2C6C}\x{A763}])/' |
---|
582 | ), |
---|
583 | ); |
---|
584 | |
---|
585 | public static function removeDiacritics($str) |
---|
586 | { |
---|
587 | $flags = "um"; |
---|
588 | for ($i = 0; $i < sizeof(dcUtils::$defaultDiacriticsRemovalMap); $i++) { |
---|
589 | $str = preg_replace( |
---|
590 | dcUtils::$defaultDiacriticsRemovalMap[$i]['letters'].$flags, |
---|
591 | dcUtils::$defaultDiacriticsRemovalMap[$i]['base'], |
---|
592 | $str); |
---|
593 | } |
---|
594 | return $str; |
---|
595 | } |
---|
596 | } |
---|