summaryrefslogtreecommitdiff
path: root/modules/g2_import/helpers/g2_import.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-12 05:48:15 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-12 05:48:15 +0000
commitfdb17d75cebed56be0011eea2abba237320ceddf (patch)
tree9a5fdf3a8fd19d595b8f76a3d924501cc826eba1 /modules/g2_import/helpers/g2_import.php
parentc397cc73bef3bf2a092e1f0ddf73fd415db49da3 (diff)
Import keywords as tags.
Refactor the general flow of g2_import_task::import() to simplify it and make it more sensible. It had gotten a little overgrown. It's still a little overgrown, but I don't see an easy way to simplify it from here.
Diffstat (limited to 'modules/g2_import/helpers/g2_import.php')
-rw-r--r--modules/g2_import/helpers/g2_import.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index bea0328e..482f4089 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -236,7 +236,6 @@ class g2_import_Core {
$album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
$album->created = $g2_album->getCreationTimestamp();
- // @todo support "keywords", "originationTimestamp", and "random" sort orders.
$order_map = array(
"originationTimestamp" => "captured",
"creationTimestamp" => "created",
@@ -256,9 +255,9 @@ class g2_import_Core {
}
$album->save();
+ self::import_keywords_as_tags($g2_album->getKeywords(), $album);
self::set_map($g2_album_id, $album->id);
- // @todo import keywords as tags
// @todo import album highlights
}
@@ -304,6 +303,10 @@ class g2_import_Core {
break;
}
+ if (!empty($item)) {
+ self::import_keywords_as_tags($g2_item->getKeywords(), $item);
+ }
+
if (isset($item)) {
self::set_map($g2_item_id, $item->id);
}
@@ -355,6 +358,19 @@ class g2_import_Core {
// have an id for each individual tag mapping anyway so it'd be hard to set up the mapping.
}
+ static function import_keywords_as_tags($keywords, $item) {
+ if (!module::is_installed("tag")) {
+ return;
+ }
+
+ foreach (preg_split("/[,;]/", $keywords) as $keyword) {
+ $keyword = trim($keyword);
+ if ($keyword) {
+ tag::add($item, $keyword);
+ }
+ }
+ }
+
/**
* If the thumbnails and resizes created for the Gallery2 photo match the dimensions of the
* ones we expect to create for Gallery3, then copy the files over instead of recreating them.