From ba93e84964486bb58ab83a901b4415268b16e4b6 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 8 Nov 2010 16:35:53 -0700 Subject: [PATCH] Clean up Horde_Menu. No need to define menuitem in constructor. Add Horde_Menu::MASK_BASE - allows insertion of config-based menu items if no other mask items are defined. Break out HTML rendering into separate protected method so that it can be replaced by an extended class. --- framework/Core/lib/Horde/Menu.php | 87 ++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/framework/Core/lib/Horde/Menu.php b/framework/Core/lib/Horde/Menu.php index e2de2ed54..bd9a92cee 100644 --- a/framework/Core/lib/Horde/Menu.php +++ b/framework/Core/lib/Horde/Menu.php @@ -21,35 +21,34 @@ class Horde_Menu const MASK_LOGIN = 2; const MASK_PREFS = 4; const MASK_PROBLEM = 8; - const MASK_ALL = 15; + const MASK_BASE = 16; + const MASK_ALL = 31; /* TODO */ const POS_LAST = 999; /** - * Menu array. + * Mask defining what menu items to show. * - * @var array + * @var integer */ - protected $_menu = array(); + protected $_mask; /** - * Mask defining what general Horde links are shown in this Menu. + * Menu array. * - * @var integer + * @var array */ - protected $_mask; + protected $_menu = array(); /** * Constructor + * + * @param integer $mask Display mask. */ public function __construct($mask = self::MASK_ALL) { - /* Menuitem mask. */ $this->_mask = $mask; - - /* Location of the menufile. */ - $this->_menufile = $GLOBALS['registry']->get('fileroot') . '/config/menu.php'; } /** @@ -146,11 +145,9 @@ class Horde_Menu } /** - * Return the unordered list representing the list of menu items. Styling - * is done through CSS. + * Return the rendered representation of the menu items. * - * @return string An unordered list of menu elements that can be entirely - * styled with CSS. + * @return string The rendered representation. */ public function render() { @@ -223,8 +220,21 @@ class Horde_Menu $this->_menu = array_reverse($this->_menu); } - $menu_view = $prefs->getValue('menu_view'); + return $this->_render(); + } + + /** + * Unordered list representing the list of menu items. Styling is done + * through CSS. + * + * @return string An unordered list of menu elements that can be entirely + * styled with CSS. + */ + protected function _render() + { + $menu_view = $GLOBALS['prefs']->getValue('menu_view'); $output = '