From 0c276b598f6380020374d7b885761995609c05be Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 31 Jul 2009 14:46:28 -0600 Subject: [PATCH] Add IMP::prepareMenu() Needed since menu generation may add javascript files to the output and these should be caught by the JS caching code. --- imp/compose.php | 3 +++ imp/folders.php | 4 ++++ imp/lib/IMP.php | 22 +++++++++++++++++++--- imp/mailbox.php | 1 + imp/message.php | 1 + imp/search.php | 1 + imp/thread.php | 1 + 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/imp/compose.php b/imp/compose.php index e3ca9b8d5..b8663221b 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -1218,6 +1218,9 @@ if ($redirect) { $template_output = $t->fetch(IMP_TEMPLATES . '/compose/compose.html'); } +if ($showmenu) { + IMP::prepareMenu(); +} Horde::addScriptFile('compose.js', 'imp', true); require IMP_TEMPLATES . '/common-header.inc'; Horde::addInlineScript($js_code); diff --git a/imp/folders.php b/imp/folders.php index 5bfc0214b..8975dd9c6 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -269,6 +269,7 @@ case 'folders_empty_mailbox_confirm': } $title = _("Folder Actions - Confirmation"); + IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); @@ -291,6 +292,7 @@ case 'mbox_size': Horde::addScriptFile('tables.js', 'horde', true); $title = _("Folder Sizes"); + IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); @@ -333,6 +335,7 @@ $folders_url = Horde_Util::addParameter($folders_url, 'folders_token', $folders_ if ($_SESSION['imp']['file_upload'] && ($actionID == 'import_mbox')) { $title = _("Folder Navigator"); + IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); @@ -502,6 +505,7 @@ $template->setOption('gettext', true); $template->set('rows', $rows); $title = _("Folder Navigator"); +IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 4705ad9fb..bf93da325 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -47,6 +47,9 @@ class IMP /* hideDeletedMsgs() cache. */ static private $_delhide = null; + /* prepareMenu() cache. */ + static private $_menuTemplate = null; + /* Has init previously been called? */ static private $_init = false; @@ -603,10 +606,14 @@ class IMP } /** - * Outputs IMP's menu to the current output stream. + * Build IMP's list of menu items. */ - static public function menu() + static public function prepareMenu() { + if (isset(self::$_menuTemplate)) { + return; + } + $t = new Horde_Template(); $t->set('forminput', Horde_Util::formInput()); $t->set('use_folders', ($_SESSION['imp']['protocol'] != 'pop') && $GLOBALS['conf']['user']['allow_folders'], true); @@ -623,7 +630,16 @@ class IMP } $t->set('menu_string', self::getMenu('string')); - echo $t->fetch(IMP_TEMPLATES . '/menu.html'); + self::$_menuTemplate = $t; + } + + /** + * Outputs IMP's menu to the current output stream. + */ + static public function menu() + { + self::prepareMenu(); + echo self::$_menuTemplate->fetch(IMP_TEMPLATES . '/menu.html'); } /** diff --git a/imp/mailbox.php b/imp/mailbox.php index c18f29f74..6f9a18951 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -415,6 +415,7 @@ if (!empty($newmsgs)) { } } +IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); diff --git a/imp/message.php b/imp/message.php index 6b980c261..d647f9760 100644 --- a/imp/message.php +++ b/imp/message.php @@ -717,6 +717,7 @@ $m_template->set('msgtext', $msgtext); Horde::addScriptFile('effects.js', 'horde', true); Horde::addScriptFile('imp.js', 'imp', true); Horde::addScriptFile('message.js', 'imp', true); +IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; if (!empty($conf['maillog']['use_maillog'])) { IMP_Maillog::displayLog($envelope['message-id']); diff --git a/imp/search.php b/imp/search.php index bca7e2d62..0b46a81c9 100644 --- a/imp/search.php +++ b/imp/search.php @@ -342,6 +342,7 @@ if (empty($search['mbox'])) { $title = _("Message Search"); Horde::addScriptFile('stripe.js', 'horde', true); Horde::addScriptFile('search.js', 'imp', true); +IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); diff --git a/imp/thread.php b/imp/thread.php index 01882f7a4..5bb9caa25 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -165,6 +165,7 @@ $template->set('tree', $tree); /* Output page. */ $title = ($mode == 'thread') ? _("Thread View") : _("Multiple Message View"); +IMP::prepareMenu(); require IMP_TEMPLATES . '/common-header.inc'; IMP::menu(); IMP::status(); -- 2.11.0