Update of /cvsroot/php-blog/serendipity/include/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29182/include/admin
Modified Files:
import.inc.php
Log Message:
More flexibility in users choosing their charsets (for utf8_decode) and
if they prefer not to decode htmlentities via strtr.
Would be cool if someone could review those changes :-D
Index: import.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/admin/import.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- import.inc.php 15 Feb 2005 11:15:30 -0000 1.9
+++ import.inc.php 21 Feb 2005 18:52:55 -0000 1.10
@@ -14,7 +14,82 @@
/* For later use */
class Serendipity_Import {
+ var $trans_table = '';
+
function getImportNotes() { return ""; }
+
+ function getCharsets($utf8_default = true) {
+ $charsets = array();
+
+ if (!$utf8_default) {
+ $charsets['native'] = LANG_CHARSET;
+ }
+
+ if (LANG_CHARSET != 'UTF-8') {
+ $charsets['UTF-8'] = 'UTF-8';
+ }
+
+ if (LANG_CHARSET != 'ISO-8859-1') {
+ $charset['ISO-8859-1'] = 'ISO-8859-1';
+ }
+
+ if ($utf8_default) {
+ $charsets['native'] = LANG_CHARSET;
+ }
+
+ return $charsets;
+ }
+
+ function decode($string) {
+ switch($this->data['charset']) {
+ case 'native':
+ return $string;
+
+ case 'ISO-8859-1':
+ if (function_exists('iconv')) {
+ return iconv('ISO-8859-1', LANG_CHARSET, $string);
+ } elseif (function_exists('recode')) {
+ return recode('iso-8859-1..' . LANG_CHARSET, $string);
+ } else {
+ return $string;
+ }
+
+ case 'UTF-8':
+ default:
+ return utf8_decode($string);
+ }
+ }
+
+ function strtr($data) {
+ return strtr($this->decode($data), $this->trans_table);
+ }
+
+ function strtrRecursive($data) {
+ foreach ($data as $key => $val) {
+ if (is_array($val)) {
+ $data[$key] = $this->strtrRecursive($val);
+ } else {
+ $data[$key] = $this->strtr($val);
+ }
+ }
+
+ return $data;
+ }
+
+ function getTransTable() {
+ if (!serendipity_db_bool($this->data['use_strtr'])) {
+ $this->trans_table = array();
+ return true;
+ }
+
+ // We need to convert interesting characters to HTML entities, except for those with special relevance to HTML.
+ $this->trans_table = get_html_translation_table(HTML_ENTITIES);
+ foreach (get_html_translation_table(HTML_SPECIALCHARS) as $char => $encoded) {
+ if (isset($this->trans_table[$char])) {
+ unset($this->trans_table[$char]);
+ }
+ }
+ }
}
if ( isset($serendipity['GET']['importFrom']) ) {
@@ -88,7 +163,7 @@
}
}
closedir($dir);
- natsort($list);
+ ksort($list);
?>
<?php echo IMPORT_WELCOME ?>.<br />
<?php echo IMPORT_WHAT_CAN ?>. <br />
|