From e77ba1d7512b3d7f4c3cd12bb499e0e296c485ae Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 9 Jun 2009 13:36:36 +0200 Subject: fix gallery2 import with multisite config --- modules/g2_import/controllers/admin_g2_import.php | 18 +++++++++++++++--- modules/g2_import/helpers/g2_import.php | 15 ++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index f2969f49..968d97cd 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -44,13 +44,20 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = $this->_get_import_form(); if ($form->validate()) { $embed_path = $form->configure_g2_import->embed_path->value; + $multi_path = $form->configure_g2_import->multi_path->value; + if (!is_file($embed_path) && file_exists("$embed_path/embed.php")) { $embed_path = "$embed_path/embed.php"; } + + if (!empty($multi_path) && !is_file($multi_path) && file_exists("$multi_path/config.php")) { + $multi_path = "$multi_path/embed.php"; + } - if (g2_import::is_valid_embed_path($embed_path)) { + if (g2_import::is_valid_embed_path($embed_path, $multi_path)) { message::success("Gallery 2 path saved."); module::set_var("g2_import", "embed_path", $embed_path); + module::set_var("g2_import", "multi_path", $multi_path); url::redirect("admin/g2_import"); } else { $form->configure_g2_import->embed_path->add_error("invalid", 1); @@ -67,11 +74,16 @@ class Admin_g2_import_Controller extends Admin_Controller { $form = new Forge( "admin/g2_import/save", "", "post", array("id" => "gAdminConfigureG2ImportForm")); $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")) + $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file (in case of multisite config, use the path to the 'master')")) ->value(module::get_var("g2_import", "embed_path", "")); + + $group->input("multi_path")->label(t("Filesystem path to your Gallery 2 multisite instance config (leave empty if not applicable)")) + ->value(module::get_var("g2_import", "multi_path", "")); + $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); + $group->submit("")->value(t("Save")); 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 51dc8705..f68bd9c4 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -44,15 +44,15 @@ class g2_import_Core { g2_import::$init = g2_import::init_embed($embed_path); } - static function is_valid_embed_path($embed_path) { - return file_exists($embed_path) && g2_import::init_embed($embed_path); + static function is_valid_embed_path($embed_path, $multi_path) { + return file_exists($embed_path) && (empty($multi_path) || file_exists($multi_path)) && g2_import::init_embed($embed_path, $multi_path); } /** * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. */ - static function init_embed($embed_path) { - if (!is_file($embed_path)) { + static function init_embed($embed_path, $multi_path) { + if (!is_file($embed_path) || (!empty($multi_path) && !is_dir($multi_path)) { return false; } @@ -70,6 +70,11 @@ class g2_import_Core { mkdir($mod_path); $base_dir = dirname($embed_path); + if (!empty($multi_path)) + $config_dir = dirname($multi_path); + else + $config_dir = $base_dir + file_put_contents( "$mod_path/embed.php", str_replace( @@ -103,7 +108,7 @@ class g2_import_Core { "\$gallery =& new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", - "define('GALLERY_CONFIG_DIR', '$base_dir');", + "define('GALLERY_CONFIG_DIR', '$config_dir');", "\$gallery =& new G2_Gallery();"), array_merge(array("\n"), file("$base_dir/bootstrap.inc")))); -- cgit v1.2.3 From 657e17361db19ac1878b2a6d93595a763aef8b15 Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 9 Jun 2009 16:16:18 +0200 Subject: fix previous commit --- modules/g2_import/helpers/g2_import.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index f68bd9c4..1ff63e36 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -37,11 +37,13 @@ class g2_import_Core { } $embed_path = module::get_var("g2_import", "embed_path"); + $multi_path = module::get_var("g2_import", "multi_path"); + if (empty($embed_path)) { throw new Exception("@todo G2_IMPORT_NOT_CONFIGURED"); } - g2_import::$init = g2_import::init_embed($embed_path); + g2_import::$init = g2_import::init_embed($embed_path, $multi_path); } static function is_valid_embed_path($embed_path, $multi_path) { @@ -52,7 +54,7 @@ class g2_import_Core { * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. */ static function init_embed($embed_path, $multi_path) { - if (!is_file($embed_path) || (!empty($multi_path) && !is_dir($multi_path)) { + if (!is_file($embed_path) || (!empty($multi_path) && !is_dir($multi_path))) { return false; } @@ -73,7 +75,7 @@ class g2_import_Core { if (!empty($multi_path)) $config_dir = dirname($multi_path); else - $config_dir = $base_dir + $config_dir = $base_dir; file_put_contents( "$mod_path/embed.php", -- cgit v1.2.3 From 315969e24e3ce4cbf06e5160e4738c083b2338be Mon Sep 17 00:00:00 2001 From: Marc Poulhiès Date: Wed, 10 Jun 2009 16:57:29 +0200 Subject: fix init_embed. test was not correct --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 648f3809..01e07eba 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -54,7 +54,7 @@ class g2_import_Core { * Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls. */ static function init_embed($embed_path, $multi_path) { - if (!is_file($embed_path) || (!empty($multi_path) && !is_dir($multi_path))) { + if (!is_file($embed_path) && (empty($multi_path) || is_dir($multi_path))) { return false; } -- cgit v1.2.3 From df538b6492914947d52284f3f7b00b7c5d6fffdf Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 12 Jun 2009 03:48:36 +0800 Subject: Trap exceptions from movie::create() and mark those movies as corrupt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Poulhiès --- modules/g2_import/helpers/g2_import.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 01e07eba..33cfc158 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -432,13 +432,19 @@ class g2_import_Core { case "GalleryMovieItem": // @todo we should transcode other types into FLV if (in_array($g2_item->getMimeType(), array("video/mp4", "video/x-flv"))) { - $item = movie::create( - $parent, - $g2_path, - $g2_item->getPathComponent(), - $g2_item->getTitle(), - self::extract_description($g2_item), - self::map($g2_item->getOwnerId())); + try { + $item = movie::create( + $parent, + $g2_path, + $g2_item->getPathComponent(), + $g2_item->getTitle(), + self::extract_description($g2_item), + self::map($g2_item->getOwnerId())); + } catch (Exception $e) { + Kohana::log("alert", "Corrupt movie $g2_path\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + $corrupt = 1; + } } break; -- cgit v1.2.3 From 15adde714d667be984c2357cd0bf3fae5691ff5c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 12 Jun 2009 03:50:24 +0800 Subject: add a missing 'break' after running tests which caused tests not to run. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Poulhiès --- index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/index.php b/index.php index b2170fb1..50c08886 100644 --- a/index.php +++ b/index.php @@ -62,6 +62,7 @@ if (PHP_SAPI == "cli") { @mkdir("test/var/logs", 0777, true); define("VARPATH", realpath("test/var") . "/"); @copy("var/database.php", VARPATH . "database.php"); + break; default: print "Usage: php index.php { upgrade | package | test }\n"; -- cgit v1.2.3 From cf687fe15248b4d14f5fefc6eddd91f5dcafe3c2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 12 Jun 2009 03:50:50 +0800 Subject: Rename theme_details to theme_options. These changes got left out of 68fd196d66e2d21f571ff3b5a673f18cd129abf9 leaving us in a temporarily broken state. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Poulhiès --- modules/g2_import/views/admin_g2_import.html.php | 4 ++-- modules/gallery/helpers/gallery_menu.php | 4 ++-- modules/gallery/helpers/theme.php | 2 +- modules/gallery/views/admin_block_welcome.html.php | 4 ++-- modules/gallery/views/admin_theme_details.html.php | 6 ------ modules/gallery/views/admin_theme_options.html.php | 6 ++++++ 6 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 modules/gallery/views/admin_theme_details.html.php create mode 100644 modules/gallery/views/admin_theme_options.html.php diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 85525a81..c0ee2b17 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -52,7 +52,7 @@ Using the same value will speed up your import.", array("g2_pixels" => $g2_sizes["thumb"]["size"], "g3_pixels" => $thumb_size, - "url" => url::site("admin/theme_details"))) ?> + "url" => url::site("admin/theme_options"))) ?> @@ -61,7 +61,7 @@ Using the same value will speed up your import.", array("g2_pixels" => $g2_sizes["resize"]["size"], "g3_pixels" => $resize_size, - "url" => url::site("admin/theme_details"))) ?> + "url" => url::site("admin/theme_options"))) ?> diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index 9729a868..fd4ec241 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -144,9 +144,9 @@ class gallery_menu_Core { ->label(t("Theme Choice")) ->url(url::site("admin/themes"))) ->append(Menu::factory("link") - ->id("theme_details") + ->id("theme_options") ->label(t("Theme Options")) - ->url(url::site("admin/theme_details")))) + ->url(url::site("admin/theme_options")))) ->append(Menu::factory("link") ->id("maintenance") ->label(t("Maintenance")) diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index af340db6..0a43f25c 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -40,7 +40,7 @@ class theme_Core { } static function get_edit_form_admin() { - $form = new Forge("admin/theme_details/save/", "", null, array("id" =>"gThemeDetailsForm")); + $form = new Forge("admin/theme_options/save/", "", null, array("id" =>"gThemeOptionsForm")); $group = $form->group("edit_theme"); $group->input("page_size")->label(t("Items per page"))->id("gPageSize") ->rules("required|valid_digit") diff --git a/modules/gallery/views/admin_block_welcome.html.php b/modules/gallery/views/admin_block_welcome.html.php index a453b006..38d2bd56 100644 --- a/modules/gallery/views/admin_block_welcome.html.php +++ b/modules/gallery/views/admin_block_welcome.html.php @@ -9,9 +9,9 @@ "language_url" => url::site("admin/languages"))) ?>
  • - choose a theme, or customize the way it looks.", + choose a theme, or customize the way it looks.", array("theme_url" => url::site("admin/themes"), - "theme_details_url" => url::site("admin/theme_details"))) ?> + "theme_options_url" => url::site("admin/theme_options"))) ?>
  • install modules to add cool features!", diff --git a/modules/gallery/views/admin_theme_details.html.php b/modules/gallery/views/admin_theme_details.html.php deleted file mode 100644 index f093b70b..00000000 --- a/modules/gallery/views/admin_theme_details.html.php +++ /dev/null @@ -1,6 +0,0 @@ - -
    -

    - - -
    diff --git a/modules/gallery/views/admin_theme_options.html.php b/modules/gallery/views/admin_theme_options.html.php new file mode 100644 index 00000000..724e6438 --- /dev/null +++ b/modules/gallery/views/admin_theme_options.html.php @@ -0,0 +1,6 @@ + +
    +

    + + +
    -- cgit v1.2.3