From e2863cf1c568b2e88d6c08fa67800a13cd4bd067 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 17 Jun 2009 21:14:36 +0800 Subject: Fix for ticket #366 1) Stored the menu element type in the menu element 2) Scanned the menu before display removing any empty sub menus. Went with the removal approach because there will more users than developers Signed-off-by: --- modules/gallery/libraries/Menu.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'modules/gallery/libraries/Menu.php') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 83bd1616..79274057 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,26 @@ 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 __construct($type) { + parent::__construct($type); $this->elements = array(); + $this->is_root = $type == "root"; } /** -- cgit v1.2.3