. */ /** * Class Menu - System for generating menus. */ class Menu { /** @var string The text to be displayed in the mneu */ private $label; /** @var string The target URL or href*/ private $link; /** @var string The CSS ID to be used for this menu item */ private $id; /** @var string An onclick action, typically used with a link of "#" */ private $onclick; /** @var Menu[] */ private $submenus; /** @var string Used internally to create javascript menus */ private $parentmenu; /** @var string Used to format javascript menus */ private $submenuclass; /** @var string Used to format javascript menus */ private $iconclass; /** @var string Used to format javascript menus */ private $class; /** * Constructor for the menu class * * @param string $label The label for the menu item * @param string $link The target URL * @param string $id An CSS identifier * @param string $onclick A javascript onclick handler * @param Menu[] $submenus Any submenus */ public function __construct($label, $link = '#', $id = '', $onclick = '', $submenus = array()) { $this ->setLabel($label) ->setLink($link) ->setId($id) ->setOnclick($onclick) ->setSubmenus($submenus); } /** * Convert this menu to an HTML list, for easy rendering of * lists of menus/nulls. * * @return string */ public function __toString() { return $this->getMenuAsList(); } /** * Render this menu using Bootstrap markup * * @return string */ public function bootstrap() { if ($this->iconclass) { $class = ' class="' . $this->iconclass . '"'; } else { $class = ''; } if ($this->id) { $id = ' id="' . $this->id . '"'; } else { $id = ''; } if ($this->submenus) { $submenus = ''; foreach ($this->submenus as $submenu) { $submenus .= $submenu->bootstrap(); } return '