From 5040adebb5c4e1e491fbb6c3b98783f5809020a3 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Fri, 22 Apr 2011 16:30:37 -0700
Subject: Totally revamp the G2 Import UI to make it sexxxy. Fixes #1683.
---
modules/g2_import/controllers/admin_g2_import.php | 44 ++++--
modules/g2_import/helpers/g2_import.php | 21 ++-
modules/g2_import/helpers/g2_import_task.php | 2 +-
modules/g2_import/views/admin_g2_import.html.php | 162 +++++++++++++---------
4 files changed, 151 insertions(+), 78 deletions(-)
(limited to 'modules/g2_import')
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 33186fb5..55a75a3b 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -24,23 +24,42 @@ class Admin_g2_import_Controller extends Admin_Controller {
g2_import::init();
}
- if (class_exists("GalleryCoreApi")) {
- $g2_stats = g2_import::stats();
- $g2_sizes = g2_import::common_sizes();
- }
-
$view = new Admin_View("admin.html");
$view->page_title = t("Gallery 2 import");
$view->content = new View("admin_g2_import.html");
+
+ if (class_exists("GalleryCoreApi")) {
+ $view->content->g2_stats = $g2_stats = g2_import::g2_stats();
+ $view->content->g3_stats = $g3_stats = g2_import::g3_stats();
+ $view->content->g2_sizes = g2_import::common_sizes();
+ $view->content->g2_version = g2_import::version();
+
+ // Don't count tags because we don't track them in g2_map
+ $view->content->g2_resource_count =
+ $g2_stats["users"] + $g2_stats["groups"] + $g2_stats["albums"] +
+ $g2_stats["photos"] + $g2_stats["movies"] + $g2_stats["comments"];
+ $view->content->g3_resource_count =
+ $g3_stats["user"] + $g3_stats["group"] + $g3_stats["album"] +
+ $g3_stats["item"] + $g3_stats["comment"] + $g3_stats["tag"];
+ }
+
$view->content->form = $this->_get_import_form();
$view->content->version = "";
+ $view->content->thumb_size = module::get_var("gallery", "thumb_size");
+ $view->content->resize_size = module::get_var("gallery", "resize_size");
if (g2_import::is_initialized()) {
- $view->content->g2_stats = $g2_stats;
- $view->content->g2_sizes = $g2_sizes;
- $view->content->thumb_size = module::get_var("gallery", "thumb_size");
- $view->content->resize_size = module::get_var("gallery", "resize_size");
- $view->content->version = g2_import::version();
+ if ((bool)ini_get("eaccelerator.enable") || (bool)ini_get("xcache.cacher")) {
+ message::warning(t("The eAccelerator and XCache PHP performance extensions are known to cause issues. If you're using either of those and are having problems, please disable them while you do your import. Add the following lines: %lines
to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n php_value eaccelerator.enable 0\n php_value xcache.cacher off\n php_value xcache.optimizer off\n\n")));
+ }
+
+ foreach (array("notification", "search", "exif") as $module_id) {
+ if (module::is_active($module_id)) {
+ message::warning(
+ t("Deactivating the %module_id module during your import will make it faster",
+ array("url" => url::site("admin/modules"), "module_id" => $module_id)));
+ }
+ }
} else if (g2_import::is_configured()) {
$view->content->form->configure_g2_import->embed_path->add_error("invalid", 1);
}
@@ -76,14 +95,15 @@ class Admin_g2_import_Controller extends Admin_Controller {
}
private function _get_import_form() {
+ $embed_path = module::get_var("g2_import", "embed_path", "");
$form = new Forge(
"admin/g2_import/save", "", "post", array("id" => "g-admin-configure-g2-import-form"));
$group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import"));
$group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file"))
- ->value(module::get_var("g2_import", "embed_path", ""));
+ ->value($embed_path);
$group->embed_path->error_messages(
"invalid", t("The path you entered is not a Gallery 2 installation."));
- $group->submit("")->value(t("Save"));
+ $group->submit("")->value($embed_path ? t("Change") : t("Continue"));
return $form;
}
}
\ No newline at end of file
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 22fb68c6..23fb29e5 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -219,7 +219,7 @@ class g2_import_Core {
* Return a set of statistics about the number of users, groups, albums, photos, movies and
* comments available for import from the Gallery 2 instance.
*/
- static function stats() {
+ static function g2_stats() {
global $gallery;
$root_album_id = g2(GalleryCoreApi::getDefaultAlbumId());
$stats["users"] = g2(GalleryCoreApi::fetchUserCount());
@@ -247,6 +247,25 @@ class g2_import_Core {
return $stats;
}
+ /**
+ * Return a set of statistics about the number of users, groups, albums, photos, movies and
+ * comments already imported into the Gallery 3 instance.
+ */
+ static function g3_stats() {
+ $g3_stats = array(
+ "album" => 0, "comment" => 0, "item" => 0, "user" => 0, "group" => 0, "tag" => 0);
+ foreach (db::build()
+ ->select("resource_type")
+ ->select(array("C" => 'COUNT("*")'))
+ ->from("g2_maps")
+ ->where("resource_type", "IN", array("album", "comment", "item", "user", "group"))
+ ->group_by("resource_type")
+ ->execute() as $row) {
+ $g3_stats[$row->resource_type] = $row->C;
+ }
+ return $g3_stats;
+ }
+
/**
* Import a single group.
*/
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 6bda8f17..5e908676 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -56,7 +56,7 @@ class g2_import_task_Core {
$mode = $task->get("mode");
$queue = $task->get("queue");
if (!isset($mode)) {
- $stats = g2_import::stats();
+ $stats = g2_import::g2_stats();
$stats["items"] = $stats["photos"] + $stats["movies"];
unset($stats["photos"]);
unset($stats["movies"]);
diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php
index cb13363a..20b243d5 100644
--- a/modules/g2_import/views/admin_g2_import.html.php
+++ b/modules/g2_import/views/admin_g2_import.html.php
@@ -5,20 +5,43 @@
= t("Import your Gallery 2 users, photos, movies, comments and tags into your new Gallery 3 installation.") ?>
-
- = $form ?>
-
-
-
- if (g2_import::is_initialized()): ?>
-
-
= t("Import") ?>
-
- -
- = t("Gallery version %version detected", array("version" => $version)) ?>
+
+
+
+
+ = $form ?>
+
+
+ if (isset($g2_version)): ?>
+
+ -
+ = t("Gallery version %version detected", array("version" => $g2_version)) ?>
if ($g2_sizes["thumb"]["size"] && $thumb_size != $g2_sizes["thumb"]["size"]): ?>
- -
+
-
= t("Your most common thumbnail size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 thumbnail size is set to %g3_pixels pixels. Using the same value will speed up your import.",
array("g2_pixels" => $g2_sizes["thumb"]["size"],
"g3_pixels" => $thumb_size,
@@ -27,73 +50,84 @@
endif ?>
if ($g2_sizes["resize"]["size"] && $resize_size != $g2_sizes["resize"]["size"]): ?>
-
-
+
-
= t("Your most common intermediate size in Gallery 2 is %g2_pixels pixels, but your Gallery 3 intermediate size is set to %g3_pixels pixels. Using the same value will speed up your import.",
- array("g2_pixels" => $g2_sizes["resize"]["size"],
- "g3_pixels" => $resize_size,
- "url" => html::mark_clean(url::site("admin/theme_options")))) ?>
+ array("g2_pixels" => $g2_sizes["resize"]["size"],
+ "g3_pixels" => $resize_size,
+ "url" => html::mark_clean(url::site("admin/theme_options")))) ?>
endif ?>
- -
- = t("Your Gallery 2 has the following importable data in it:") ?>
-
- = t2("1 user", "%count users", $g2_stats["users"]) ?>,
- = t2("1 group", "%count groups", $g2_stats["groups"]) ?>,
- = t2("1 album", "%count albums", $g2_stats["albums"]) ?>,
- = t2("1 photo", "%count photos", $g2_stats["photos"]) ?>,
- = t2("1 movie", "%count movies", $g2_stats["movies"]) ?>,
- = t2("1 comment", "%count comments", $g2_stats["comments"]) ?>,
- = t2("1 tagged photo/movie/album",
- "%count tagged photos/movies/albums", $g2_stats["tags"]) ?>
-
+ -
+
+ $t = array();
+ $t[] = t2("1 user", "%count users", $g2_stats["users"]);
+ $t[] = t2("1 group", "%count groups", $g2_stats["groups"]);
+ $t[] = t2("1 album", "%count albums", $g2_stats["albums"]);
+ $t[] = t2("1 photo", "%count photos/movies", $g2_stats["photos"] + $g2_stats["movies"]);
+ $t[] = t2("1 comment", "%count comments", $g2_stats["comments"]);
+ $t[] = t2("1 tagged photo/movie/album", "%count tagged photos/movies/albums",
+ $g2_stats["tags"]);
+ ?>
+ = t("Your Gallery 2 has the following importable data in it: %t0, %t1, %t2, %t3, %t4, %t5",
+ array("t0" => $t[0], "t1" => $t[1], "t2" => $t[2],
+ "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?>
-
+ if ($g3_resource_count): ?>
+
-
+
+ $t = array();
+ $t[] = t2("1 user", "%count users", $g3_stats["user"]);
+ $t[] = t2("1 group", "%count groups", $g3_stats["group"]);
+ $t[] = t2("1 album", "%count albums", $g3_stats["album"]);
+ $t[] = t2("1 photo/movie", "%count photos/movies", $g3_stats["item"]);
+ $t[] = t2("1 comment", "%count comments", $g3_stats["comment"]);
+ $t[] = t2("1 tagged photo/movie/album", "%count tagged photos/movies/albums", $g3_stats["tag"]);
+ ?>
+ = t("It looks like you've imported the following Gallery 2 data already: %t0, %t1, %t2, %t3, %t4, %t5",
+ array("t0" => $t[0], "t1" => $t[1], "t2" => $t[2],
+ "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?>
+
+ endif ?>
+
">
= t("Begin import!") ?>
+ endif ?>
+
--
cgit v1.2.3