From: Michael M Slusarz Date: Wed, 5 May 2010 06:48:26 +0000 (-0600) Subject: Improved Ingo menu rendering X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=17f5a57919fff298f5436008a2e33b930894b13a;p=horde.git Improved Ingo menu rendering --- diff --git a/ingo/blacklist.php b/ingo/blacklist.php index 367ba43cf..944331d28 100644 --- a/ingo/blacklist.php +++ b/ingo/blacklist.php @@ -102,6 +102,7 @@ Ingo::prepareMenu(); Ingo::addNewFolderJs(); $title = _("Blacklist Edit"); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); require INGO_TEMPLATES . '/blacklist/blacklist.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ingo/filters.php b/ingo/filters.php index e104974f8..183a4e8fa 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -143,7 +143,8 @@ Horde::addScriptFile('filters.js', 'ingo'); Ingo::prepareMenu(); $title = _("Filter Rules"); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); require INGO_TEMPLATES . '/filters/header.inc'; /* Common URLs. */ diff --git a/ingo/forward.php b/ingo/forward.php index a1470b983..608064852 100644 --- a/ingo/forward.php +++ b/ingo/forward.php @@ -95,6 +95,7 @@ $form->setTitle($form_title); $title = _("Forwards Edit"); Ingo::prepareMenu(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); $form->renderActive(new Horde_Form_Renderer(array('encode_title' => false)), $vars, 'forward.php', 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 7afb8691b..bfe3d5e10 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -23,11 +23,11 @@ class Ingo const USER_HEADER = '++USER_HEADER++'; /** - * getMenu() cache. + * prepareMenu() cache. * - * @var string + * @var Horde_Template */ - static private $_menuCache = null; + static private $_menuTemplate = null; /** * hasSharePermission() cache. @@ -417,6 +417,8 @@ class Ingo /** * Build Ingo's list of menu items. + * + * @return Horde_Menu A Horde_Menu object. */ static public function getMenu() { @@ -456,11 +458,46 @@ class Ingo */ static public function prepareMenu() { - if (!self::$_menuCache) { - self::$_menuCache = self::getMenu()->render(); + if (isset(self::$_menuTemplate)) { + return; + } + + $t = $GLOBALS['injector']->createInstance('Horde_Template'); + $t->set('forminput', Horde_Util::formInput()); + + if (!empty($GLOBALS['ingo_shares']) && + (count($GLOBALS['all_rulesets']) > 1)) { + $options = array(); + foreach (array_keys($GLOBALS['all_rulesets']) as $id) { + $options[] = array( + 'name' => htmlspecialchars($GLOBALS['all_rulesets'][$id]->get('name')), + 'selected' => ($_SESSION['ingo']['current_share'] == $id), + 'val' => htmlspecialchars($id) + ); + } + $t->set('options', $options); } - return self::$_menuCache; + $t->set('menu_string', self::getMenu()->render()); + + self::$_menuTemplate = $t; + } + + /** + * Outputs IMP's menu to the current output stream. + */ + static public function menu() + { + self::prepareMenu(); + echo self::$_menuTemplate->fetch(INGO_TEMPLATES . '/menu/menu.html'); + } + + /** + * Outputs IMP's status/notification bar. + */ + static public function status() + { + $GLOBALS['notification']->notify(array('listeners' => array('status', 'audio'))); } /** diff --git a/ingo/rule.php b/ingo/rule.php index 166a5bf8b..96f409aa8 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -197,7 +197,8 @@ Horde::addScriptFile('rule.js', 'ingo'); Ingo::prepareMenu(); Ingo::addNewFolderJs(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); require INGO_TEMPLATES . '/rule/header.inc'; /* Add new, blank condition. */ diff --git a/ingo/script.php b/ingo/script.php index e865eeb3f..77a3b5d38 100644 --- a/ingo/script.php +++ b/ingo/script.php @@ -52,7 +52,8 @@ case 'show_active': $title = _("Filter Script Display"); Ingo::prepareMenu(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); require INGO_TEMPLATES . '/script/header.inc'; if (!empty($script)) { require INGO_TEMPLATES . '/script/activate.inc'; diff --git a/ingo/spam.php b/ingo/spam.php index f31dbe7c1..4b4355949 100644 --- a/ingo/spam.php +++ b/ingo/spam.php @@ -152,6 +152,7 @@ $title = _("Spam Filtering"); Ingo::prepareMenu(); Ingo::addNewFolderJs(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); $form->renderActive($renderer, $vars, 'spam.php', 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ingo/templates/menu.inc b/ingo/templates/menu.inc deleted file mode 100644 index 71b6f2bd5..000000000 --- a/ingo/templates/menu.inc +++ /dev/null @@ -1,20 +0,0 @@ -
- - -
- -notify(array('listeners' => 'status')) ?> diff --git a/ingo/templates/menu/menu.html b/ingo/templates/menu/menu.html new file mode 100644 index 000000000..23d80eea9 --- /dev/null +++ b/ingo/templates/menu/menu.html @@ -0,0 +1,17 @@ +
+ + + diff --git a/ingo/vacation.php b/ingo/vacation.php index 613c373b7..f6abdc044 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -144,6 +144,7 @@ $form->setTitle($form_title); $title = _("Vacation Edit"); Ingo::prepareMenu(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); $form->renderActive(new Horde_Form_Renderer(array('encode_title' => false)), $vars, 'vacation.php', 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ingo/whitelist.php b/ingo/whitelist.php index 8169f3e4b..dfec2721a 100644 --- a/ingo/whitelist.php +++ b/ingo/whitelist.php @@ -55,6 +55,7 @@ $wl_rule = $filters->findRule(Ingo_Storage::ACTION_WHITELIST); $title = _("Whitelist Edit"); Ingo::prepareMenu(); require INGO_TEMPLATES . '/common-header.inc'; -require INGO_TEMPLATES . '/menu.inc'; +Ingo::menu(); +Ingo::status(); require INGO_TEMPLATES . '/whitelist/whitelist.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc';