From a22cf8cf1c1f3eccedb01ab4629e579c95594dae Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 8 Aug 2010 10:14:29 -0700 Subject: Handle "1" as a default order direction in G2. Why would we ever do that? Dunno. Fixes ticket #1276. --- modules/g2_import/helpers/g2_import.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 4aa9e642..4817ec04 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -442,6 +442,7 @@ class g2_import_Core { "title" => "title", "viewCount" => "view_count"); $direction_map = array( + 1 => "asc", ORDER_ASCENDING => "asc", ORDER_DESCENDING => "desc"); // Only consider G2's first sort order -- cgit v1.2.3 From cdb6306d7e75451587fbc029b94ef197f42842f1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 8 Aug 2010 16:50:02 -0700 Subject: Backdate the created/updated dates for imported comments. Fixes ticket #1215. --- modules/g2_import/helpers/g2_import.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 4817ec04..8db10dc1 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -859,7 +859,6 @@ class g2_import_Core { $comment->text = self::_transform_bbcode($text); $comment->state = "published"; $comment->server_http_host = $g2_comment->getHost(); - $comment->created = $g2_comment->getDate(); try { $comment->save(); } catch (Exception $e) { @@ -868,6 +867,14 @@ class g2_import_Core { array("id" => $g2_comment_id)), $e); } + + // Backdate the creation date. We can't do this at creation time because + // Comment_Model::save() will override it. + db::update("comments") + ->set("created", $g2_comment->getDate()) + ->set("updated", $g2_comment->getDate()) + ->where("id", "=", $comment->id) + ->execute(); } /** -- cgit v1.2.3 From e85b345edaded7d4a68ae758138bcff9d0ceaefb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 8 Aug 2010 17:10:00 -0700 Subject: Visually separate the G2 comment's subject and body when we blend them into the G3 comment body. Fixes ticket #1269. --- modules/g2_import/helpers/g2_import.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 8db10dc1..306a0c50 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -838,11 +838,7 @@ class g2_import_Core { return; } - $text = $g2_comment->getSubject(); - if ($text) { - $text .= " "; - } - $text .= $g2_comment->getComment(); + $text = join("\n", array($g2_comment->getSubject(), $g2_comment->getComment())); $text = html_entity_decode($text); // Just import the fields we know about. Do this outside of the comment API for now so that -- cgit v1.2.3 From 639d31a2c1a54f31ad32208b8602a8922d336fa0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 8 Aug 2010 21:17:16 -0700 Subject: If the imported item from Gallery 2 has a preferred derivative with a rotation, then rotate the imported image accordingly. Fixes ticket #1274.. --- modules/g2_import/helpers/g2_import.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 306a0c50..f2e9dad9 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -588,6 +588,20 @@ class g2_import_Core { $item->description = self::_decode_html_special_chars(self::extract_description($g2_item)); $item->owner_id = self::map($g2_item->getOwnerId()); $item->save(); + + // If the item has a preferred derivative with a rotation, then rotate this image + // accordingly. Should we obey scale rules as well? I vote no because rotation is less + // destructive -- you lose too much data from scaling. + $g2_preferred = g2(GalleryCoreApi::fetchPreferredSource($g2_item)); + if ($g2_preferred && $g2_preferred instanceof GalleryDerivative) { + if (preg_match("/rotate\|(-?\d+)/", $g2_preferred->getDerivativeOperations(), $matches)) { + $tmpfile = tempnam(TMPPATH, "rotate"); + gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $matches[1])); + $item->set_data_file($tmpfile); + $item->save(); + unlink($tmpfile); + } + } } catch (Exception $e) { $exception_info = (string) new G2_Import_Exception( t("Corrupt image '%path'", array("path" => $g2_path)), -- cgit v1.2.3