summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php18
-rw-r--r--modules/g2_import/helpers/g2_import.php19
2 files changed, 28 insertions, 9 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 a6c21489..01e07eba 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -37,22 +37,24 @@ 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) {
- 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 +72,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 +110,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("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"),
file("$base_dir/bootstrap.inc"))));