Add IMP::prepareMenu()
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 31 Jul 2009 20:46:28 +0000 (14:46 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 31 Jul 2009 21:02:11 +0000 (15:02 -0600)
Needed since menu generation may add javascript files to the output and
these should be caught by the JS caching code.

imp/compose.php
imp/folders.php
imp/lib/IMP.php
imp/mailbox.php
imp/message.php
imp/search.php
imp/thread.php

index e3ca9b8..b866322 100644 (file)
@@ -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);
index 5bfc021..8975dd9 100644 (file)
@@ -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();
index 4705ad9..bf93da3 100644 (file)
@@ -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');
     }
 
     /**
index c18f29f..6f9a189 100644 (file)
@@ -415,6 +415,7 @@ if (!empty($newmsgs)) {
     }
 }
 
+IMP::prepareMenu();
 require IMP_TEMPLATES . '/common-header.inc';
 IMP::menu();
 IMP::status();
index 6b980c2..d647f97 100644 (file)
@@ -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']);
index bca7e2d..0b46a81 100644 (file)
@@ -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();
index 01882f7..5bb9caa 100644 (file)
@@ -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();