Fix import UTF-8 bug, thanks to jan

This commit is contained in:
Garvin Hicking 2006-10-27 09:18:19 +00:00
parent 332658f228
commit 52ecd6d0ce
7 changed files with 19 additions and 5 deletions

View File

@ -3,6 +3,10 @@
Version 1.1 ()
------------------------------------------------------------------------
* Fixed bug that prevented native imports from other blog system
to recode ISO-charsets into UTF-8. Major thanks to Jan of
blog.salid.de. (garvinhicking)
* Added functionality to reply to comments in the admin interface
(garvinhicking)

View File

@ -309,7 +309,7 @@ function serendipity_drawList() {
<tr>
<td align="right">
<input type="button" name="toggle" value="<?php echo INVERT_SELECTIONS ?>" onclick="invertSelection()" class="serendipityPrettyButton" />
<input type="submit" name="toggle" value="<?php echo DELETE_SELECTED_COMMENTS ?>" class="serendipityPrettyButton" />
<input type="submit" name="toggle" value="<?php echo DELETE_SELECTED_ENTRIES ?>" class="serendipityPrettyButton" />
</td>
</tr>
</table>

View File

@ -17,8 +17,8 @@ if (function_exists('set_time_limit')) {
/* Class construct. Each importer plugin must extend this class. */
class Serendipity_Import {
var $trans_table = '';
var $trans_table = '';
var $force_recode = true;
/**
* Return textual notes of an importer plugin
*
@ -68,8 +68,8 @@ class Serendipity_Import {
* @return string converted string
*/
function &decode($string) {
// xml_parser_* functions to recoding from ISO-8859-1/UTF-8
if (LANG_CHARSET == 'ISO-8859-1' || LANG_CHARSET == 'UTF-8') {
// xml_parser_* functions do recoding from ISO-8859-1/UTF-8
if (!$this->force_recode && (LANG_CHARSET == 'ISO-8859-1' || LANG_CHARSET == 'UTF-8')) {
return $string;
}
@ -84,6 +84,8 @@ class Serendipity_Import {
$out = iconv('ISO-8859-1', LANG_CHARSET, $string);
} elseif (function_exists('recode')) {
$out = recode('iso-8859-1..' . LANG_CHARSET, $string);
} elseif (LANG_CHARSET == 'UTF-8') {
return utf8_encode($string);
} else {
return $string;
}

View File

@ -8,6 +8,7 @@ class Serendipity_Import_Generic extends Serendipity_Import {
var $info = array('software' => IMPORT_GENERIC_RSS);
var $data = array();
var $inputFields = array();
var $force_recode = false;
function Serendipity_Import_Generic($data) {
$this->data = $data;

View File

@ -8,6 +8,7 @@ class Serendipity_Import_LiveJournalXML extends Serendipity_Import {
var $info = array('software' => 'LiveJournal XML');
var $data = array();
var $inputFields = array();
var $force_recode = false;
function Serendipity_Import_LiveJournalXML($data) {
global $serendipity;

View File

@ -154,6 +154,11 @@ class Serendipity_Import_Nucleus extends Serendipity_Import {
for ($x=0, $max_x = mysql_num_rows($res) ; $x < $max_x ; $x++ ) {
$entries[$x] = mysql_fetch_assoc($res);
echo "BODY: " . $entries[$x]['ibody'] . "<br />\n";
echo "DECODED BODY: " . $this->strtr($entries[$x]['ibody']) . "<br />\n";
die('done');
$entry = array('title' => $this->decode($entries[$x]['ititle']),
'isdraft' => ($entries[$x]['idraft'] != '1') ? 'false' : 'true',
'allow_comments' => ($entries[$x]['iclosed'] == '1' ) ? 'false' : 'true',

View File

@ -38,6 +38,7 @@ class Serendipity_Import_VoodooPad extends Serendipity_Import {
var $info = array('software' => 'VoodooPad');
var $data = array();
var $inputFields = array();
var $force_recode = false;
function Serendipity_Import_VoodooPad($data) {
$this->data = $data;