diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-02 20:48:47 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-07-02 20:48:47 -0700 |
commit | adb820e37c95277b07ade93b2404fb3bc213380a (patch) | |
tree | 78769fc411f2984c3f7bf77fd2006aa8cc81c6f5 | |
parent | 1c9dee93de837e7bf4a2ba038388ae1836653e0a (diff) |
Fix for ticket #359 and a partial fix for ticket #345.
In G2, text strings have the &, ", < and > replaced by &, "e;,
< and > respectively. Created the _decode_html_special_chars
method in helpers/g2_import.php to revert these character strings.
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 0a4013ca..a2d0797d 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -341,8 +341,8 @@ class g2_import_Core { $album = album::create( $parent_album, $g2_album->getPathComponent(), - $g2_album->getTitle(), - self::extract_description($g2_album), + self::_decode_html_special_chars($g2_album->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_album)), self::map($g2_album->getOwnerId())); $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); @@ -455,12 +455,14 @@ class g2_import_Core { $corrupt = 1; } try { + Kohana::log("error", "description: " . self::extract_description($g2_item)); + Kohana::log("error", "title: " . $g2_item->getTitle()); $item = photo::create( $parent, $g2_path, $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), + self::_decode_html_special_chars($g2_item->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); } catch (Exception $e) { Kohana::log( @@ -477,8 +479,8 @@ class g2_import_Core { $parent, $g2_path, $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), + self::_decode_html_special_chars($g2_item->getTitle()), + self::_decode_html_special_chars(self::extract_description($g2_item)), self::map($g2_item->getOwnerId())); } catch (Exception $e) { Kohana::log("alert", "Corrupt movie $g2_path\n" . @@ -529,6 +531,15 @@ class g2_import_Core { } /** + * g2 encoded'&', '"', '<' and '>' as '&', '"', '<' and '>' respectively. + * This function undoes that encoding. + */ + private static function _decode_html_special_chars($value) { + return str_replace(array("&", """, "<", ">"), + array("&", "\"", "<", ">"), $value); + } + + /** * Import a single comment. */ static function import_comment(&$queue) { |