diff options
Diffstat (limited to 'modules/g2_import')
-rw-r--r-- | modules/g2_import/controllers/admin_g2_import.php | 5 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 104 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import_event.php | 2 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import_task.php | 6 | ||||
-rw-r--r-- | modules/g2_import/views/admin_g2_import.html.php | 10 |
5 files changed, 75 insertions, 52 deletions
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 23fb29e5..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,17 +472,66 @@ 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) { // Dequeue the current album and enqueue its children list($g2_album_id, $children) = each($queue); - if (empty($children)) { - return; - } unset($queue[$g2_album_id]); - foreach ($children as $key => $value) { - $queue[$key] = $value; + if (!empty($children)) { + foreach ($children as $key => $value) { + $queue[$key] = $value; + } } $messages = array(); diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php index 0e078d08..0afa62d8 100644 --- a/modules/g2_import/helpers/g2_import_event.php +++ b/modules/g2_import/helpers/g2_import_event.php @@ -34,7 +34,7 @@ class g2_import_event_Core { ->get("settings_menu") ->append(Menu::factory("link") ->id("g2_import") - ->label(t("Gallery 2 Import")) + ->label(t("Gallery 2 import")) ->url(url::site("admin/g2_import"))); } } 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) { diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index cf5e4755..9c4eb840 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -30,9 +30,13 @@ $("document").ready(function() { .tabs("select", 1) <? endif ?> ; + + // Show the tabs after the page has loaded to prevent Firefox from rendering the + // unstyled page and then flashing. + $("#g-admin-g2-import-tabs").show(); }); </script> - <div id="g-admin-g2-import-tabs" class="g-block-content"> + <div id="g-admin-g2-import-tabs" class="g-block-content" style="display: none"> <ul> <li> <a href="#g-admin-g2-import-configure"><?= t("1. Configure Gallery2 path") ?></a> @@ -112,8 +116,8 @@ $("document").ready(function() { </p> <? endif ?> </div> - <div id="g-admin-g2-import-notes"> - <ul class="enumeration"> + <div id="g-admin-g2-import-notes" class="g-text"> + <ul> <li> <?= t("Gallery 3 does not support per-user / per-item permissions. <b>Review permissions!</b>") ?> </li> |