diff --git a/sources/Positioning.class.php b/sources/Positioning.class.php index d6aed22689..9b3ca815e7 100644 --- a/sources/Positioning.class.php +++ b/sources/Positioning.class.php @@ -32,6 +32,13 @@ abstract class Positioning_Items */ protected $_position = null; + /** + * An (unique) id to identify the "item" + * + * @var string + */ + protected $_name = null; + /** * Known positions the item can be added * @@ -231,6 +238,27 @@ public function childOf($parent) return $this; } + public function get($name) + { + // First the easy ones + if ($this->_name === $name) + return $this; + + // If not, then let's have some fun + if (!empty($this->_children)) + { + foreach ($this->_children as $key => $item) + { + $found = $item->get($name); + + if ($found) + return $found; + } + } + + return false; + } + /** * Remove a item by name * diff --git a/sources/subs/Menu.subs.php b/sources/subs/Menu.subs.php index 50eef4052a..82e4f74f39 100644 --- a/sources/subs/Menu.subs.php +++ b/sources/subs/Menu.subs.php @@ -25,6 +25,11 @@ */ class Menu_Entries extends Positioning_Items { + public function __construct($id) + { + parent::__construct($id); + } + /** * Add a new item to the pile * @@ -60,7 +65,7 @@ public function add($key, $item = null, $priority = null) elseif ($this->_position === 'child') { if (!isset($this->_children[$this->_relative])) - $this->_children[$this->_relative] = new Menu_Entries(); + $this->_children[$this->_relative] = new Menu_Entries($key); // Always return the valid children of the "current" position return $this->_children[$this->_relative]; @@ -111,7 +116,7 @@ class Standard_Menu extends Menu_Entries public function get($id) { if (!isset($this->_instances[$id])) - $this->_instances[$id] = new Menu_Entries(); + $this->_instances[$id] = new Menu_Entries($id); return $this->_instances[$id]; } @@ -159,9 +164,7 @@ public function createMenu($id, $menuOptions = array()) if (isset($subbutton['children'])) { foreach ($subbutton['children']->prepareContext() as $key2 => $subbutton2) - { $button['areas'][$key]['subsections'][$key2] = $subbutton2; - } } } } @@ -196,7 +199,7 @@ public static function context() // this is a singleton if ($instance === null) - $instance = new Standard_Menu(); + $instance = new Standard_Menu('AllMenus'); return $instance; }