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
This commit is contained in:
Tim Almdal
2009-06-17 06:14:36 -07:00
parent 2531f67990
commit fbefdd5556
2 changed files with 26 additions and 7 deletions
+12 -7
View File
@@ -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";
}
/**