diff options
-rw-r--r-- | modules/akismet/helpers/akismet_menu.php | 6 | ||||
-rw-r--r-- | modules/g2_import/controllers/admin_g2_import.php | 18 | ||||
-rw-r--r-- | modules/g2_import/helpers/g2_import.php | 34 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_menu.php | 3 | ||||
-rw-r--r-- | modules/gallery/libraries/Admin_View.php | 1 | ||||
-rw-r--r-- | modules/gallery/libraries/Menu.php | 31 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 1 |
7 files changed, 52 insertions, 42 deletions
diff --git a/modules/akismet/helpers/akismet_menu.php b/modules/akismet/helpers/akismet_menu.php index 2862fd40..ebd948d6 100644 --- a/modules/akismet/helpers/akismet_menu.php +++ b/modules/akismet/helpers/akismet_menu.php @@ -26,12 +26,6 @@ class akismet_menu_Core { ->url(url::site("admin/akismet"))); if (module::get_var("akismet", "api_key")) { - if (!$statistics_menu = $menu->get("statistics_menu")) { - $menu->append(Menu::factory("submenu") - ->id("statistics_menu") - ->label(t("Statistics"))); - } - $menu->get("statistics_menu") ->append(Menu::factory("link") ->id("akismet") diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 968d97cd..f2969f49 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -44,20 +44,13 @@ 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, $multi_path)) { + if (g2_import::is_valid_embed_path($embed_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); @@ -74,16 +67,11 @@ 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 (in case of multisite config, use the path to the 'master')")) + $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file")) ->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 0491722d..bcaffab1 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -37,24 +37,22 @@ 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, $multi_path); + g2_import::$init = 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); + static function is_valid_embed_path($embed_path) { + return file_exists($embed_path) && g2_import::init_embed($embed_path); } /** * 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))) { + static function init_embed($embed_path) { + if (!is_file($embed_path)) { return false; } @@ -71,11 +69,17 @@ class g2_import_Core { @dir::unlink($mod_path); mkdir($mod_path); - $base_dir = dirname($embed_path); - if (!empty($multi_path)) - $config_dir = dirname($multi_path); - else - $config_dir = $base_dir; + $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", @@ -107,11 +111,13 @@ class g2_import_Core { array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", - "\$gallery =& new Gallery();"), + "\$gallery =& new Gallery();", + "\$gallery = new Gallery();"), array("require_once(dirname(__FILE__) . '/Gallery.class');", "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '$config_dir');", - "\$gallery =& new G2_Gallery();"), + "\$gallery =& new G2_Gallery();", + "\$gallery = new G2_Gallery();"), array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"), file("$base_dir/bootstrap.inc")))); diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index fb0234b1..a25832fe 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -149,6 +149,9 @@ class gallery_menu_Core { ->id("theme_options") ->label(t("Theme Options")) ->url(url::site("admin/theme_options")))) + ->append(Menu::factory("submenu") + ->id("statistics_menu") + ->label(t("Statistics"))) ->append(Menu::factory("link") ->id("maintenance") ->label(t("Maintenance")) diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 1f976871..7a7396eb 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -69,6 +69,7 @@ class Admin_View_Core extends View { } } + $menu->compact(); print $menu; } diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 83bd1616..6d0881ce 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -23,6 +23,11 @@ class Menu_Element { public $css_id; public $css_class; public $id; + public $type; + + public function __construct($type) { + $this->type = $type; + } /** * Set the id @@ -125,26 +130,38 @@ class Menu_Core extends Menu_Element { public static function factory($type) { switch($type) { case "link": - return new Menu_Element_Link(); + return new Menu_Element_Link($type); case "dialog": - return new Menu_Element_Dialog(); + return new Menu_Element_Dialog($type); case "root": - $menu = new Menu(); - $menu->is_root = true; - return $menu; + return new Menu("root"); case "submenu": - return new Menu(); + return new Menu("submenu"); default: throw Exception("@todo UNKNOWN_MENU_TYPE"); } } - public function __construct() { + public function compact() { + foreach ($this->elements as $target_id => $element) { + if ($element->type == "submenu") { + if (empty($element->elements)) { + $this->remove($target_id); + } else { + $element->compact(); + } + } + } + } + + public function __construct($type) { + parent::__construct($type); $this->elements = array(); + $this->is_root = $type == "root"; } /** diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 31c2faa7..7b2ca840 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -105,6 +105,7 @@ class Theme_View_Core extends View { } } + $menu->compact(); print $menu; } |