From e0764333830fcd16f0b8b3c4e31ff9288349edda Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 12 Jun 2009 18:08:14 -0700 Subject: Support imports from multisite G2 installs. --- modules/g2_import/helpers/g2_import.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 4a4c8247..19d02f25 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -69,7 +69,18 @@ class g2_import_Core { @dir::unlink($mod_path); mkdir($mod_path); - $base_dir = dirname($embed_path); + $config_dir = dirname($embed_path); + if (filesize($embed_path) > 200) { + // Regular install + $base_dir = $config_dir; + } else { + // Multisite install. Line 2 of embed.php will be something like: + // require('/usr/home/bharat/public_html/gallery2/embed.php'); + $lines = file($embed_path); + preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches); + $base_dir = $matches[1]; + } + file_put_contents( "$mod_path/embed.php", str_replace( @@ -104,7 +115,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();", "\$gallery = new G2_Gallery();"), array_merge(array("\n"), -- cgit v1.2.3