summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build_number2
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php5
-rw-r--r--modules/g2_import/helpers/g2_import.php95
-rw-r--r--modules/g2_import/helpers/g2_import_task.php6
4 files changed, 64 insertions, 44 deletions
diff --git a/.build_number b/.build_number
index ce9a62d4..1df3b5cb 100644
--- a/.build_number
+++ b/.build_number
@@ -3,4 +3,4 @@
; process. You don't need to edit it. In fact..
;
; DO NOT EDIT THIS FILE BY HAND!
-build_number=132
+build_number=135
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index cf68d911..5c4995c9 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -100,6 +100,11 @@ class Admin_g2_import_Controller extends Admin_Controller {
foreach (glob("{$path_prefix}*") as $file) {
if (is_dir($file) && !is_link($file)) {
$directories[] = $file;
+
+ // If we find an embed.php, include it as well
+ if (file_exists("$file/embed.php")) {
+ $directories[] = "$file/embed.php";
+ }
}
}
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index e9c19c9d..22a054ac 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -448,49 +448,8 @@ class g2_import_Core {
$album = ORM::factory("item");
$album->type = "album";
$album->parent_id = self::map($g2_album->getParentId());
- $album->name = $g2_album->getPathComponent();
- $album->title = self::_decode_html_special_chars($g2_album->getTitle());
- $album->title or $album->title = $album->name;
- $album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
- $album->owner_id = self::map($g2_album->getOwnerId());
- try {
- $album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
- } catch (Exception $e) {
- // @todo log
- $album->view_count = 0;
- }
- $album->created = $g2_album->getCreationTimestamp();
-
- $order_map = array(
- "originationTimestamp" => "captured",
- "creationTimestamp" => "created",
- "description" => "description",
- "modificationTimestamp" => "updated",
- "orderWeight" => "weight",
- "pathComponent" => "name",
- "summary" => "description",
- "title" => "title",
- "viewCount" => "view_count");
- $direction_map = array(
- 1 => "ASC",
- ORDER_ASCENDING => "ASC",
- ORDER_DESCENDING => "DESC");
- // Only consider G2's first sort order
- $g2_order = explode("|", $g2_album->getOrderBy() . "");
- $g2_order = $g2_order[0];
- if (empty($g2_order)) {
- $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy'));
- }
- $g2_order_direction = explode("|", $g2_album->getOrderDirection() . "");
- $g2_order_direction = $g2_order_direction[0];
- if (empty($g2_order_direction)) {
- $g2_order_direction =
- g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection'));
- }
- if (array_key_exists($g2_order, $order_map)) {
- $album->sort_column = $order_map[$g2_order];
- $album->sort_order = $direction_map[$g2_order_direction];
- }
+
+ g2_import::set_album_values($album, $g2_album);
try {
$album->save();
@@ -513,6 +472,56 @@ class g2_import_Core {
}
/**
+ * Transfer over all the values from a G2 album to a G3 album.
+ */
+ static function set_album_values($album, $g2_album) {
+ $album->name = $g2_album->getPathComponent();
+ $album->title = self::_decode_html_special_chars($g2_album->getTitle());
+ $album->title or $album->title = $album->name;
+ $album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
+ $album->owner_id = self::map($g2_album->getOwnerId());
+ try {
+ $album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ } catch (Exception $e) {
+ // @todo log
+ $album->view_count = 0;
+ }
+ $album->created = $g2_album->getCreationTimestamp();
+
+ $order_map = array(
+ "originationTimestamp" => "captured",
+ "creationTimestamp" => "created",
+ "description" => "description",
+ "modificationTimestamp" => "updated",
+ "orderWeight" => "weight",
+ "pathComponent" => "name",
+ "summary" => "description",
+ "title" => "title",
+ "viewCount" => "view_count");
+ $direction_map = array(
+ 1 => "ASC",
+ ORDER_ASCENDING => "ASC",
+ ORDER_DESCENDING => "DESC");
+ // G2 sorts can either be <sort> or <presort>|<sort>. Right now we can't
+ // map presorts so ignore them.
+ $g2_order = explode("|", $g2_album->getOrderBy() . "");
+ $g2_order = end($g2_order);
+ if (empty($g2_order)) {
+ $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy'));
+ }
+ $g2_order_direction = explode("|", $g2_album->getOrderDirection() . "");
+ $g2_order_direction = $g2_order_direction[0];
+ if (empty($g2_order_direction)) {
+ $g2_order_direction =
+ g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection'));
+ }
+ if (array_key_exists($g2_order, $order_map)) {
+ $album->sort_column = $order_map[$g2_order];
+ $album->sort_order = $direction_map[$g2_order_direction];
+ }
+ }
+
+ /**
* Set the highlight properly for a single album
*/
static function set_album_highlight(&$queue) {
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 5e908676..31615a55 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -127,6 +127,12 @@ class g2_import_task_Core {
$g2_root_id = g2(GalleryCoreApi::getDefaultAlbumId());
$tree = g2(GalleryCoreApi::fetchAlbumTree());
$task->set("queue", $queue = array($g2_root_id => $tree));
+
+ // Update the root album to reflect the Gallery2 root album.
+ $root_album = item::root();
+ g2_import::set_album_values(
+ $root_album, g2(GalleryCoreApi::loadEntitiesById($g2_root_id)));
+ $root_album->save();
}
$log_message = g2_import::import_album($queue);
if ($log_message) {