IMP: Remove Horde_Mobile dependency
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 06:43:49 +0000 (23:43 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 07:42:09 +0000 (00:42 -0700)
22 files changed:
imp/compose-mimp.php
imp/config/prefs.php.dist
imp/docs/CHANGES
imp/docs/UPGRADING
imp/folders-mimp.php
imp/lib/Mimp.php [deleted file]
imp/lib/Notification/Listener/AjaxStatus.php
imp/lib/Ui/Mimp.php [new file with mode: 0644]
imp/mailbox-mimp.php
imp/message-mimp.php
imp/templates/common-header.inc
imp/templates/compose/compose-mimp.html [new file with mode: 0644]
imp/templates/compose/compose-mimp.inc [deleted file]
imp/templates/compose/redirect-mimp.inc [deleted file]
imp/templates/folders/folders-mimp.html [new file with mode: 0644]
imp/templates/folders/folders-mimp.inc [deleted file]
imp/templates/mailbox/mailbox-mimp.html [new file with mode: 0644]
imp/templates/mailbox/mailbox-mimp.inc [deleted file]
imp/templates/mailbox/search-mimp.html [new file with mode: 0644]
imp/templates/mailbox/search-mimp.inc [deleted file]
imp/templates/message/download-mimp.html [new file with mode: 0644]
imp/templates/message/message-mimp.html [new file with mode: 0644]

index 916c1ba..2838601 100644 (file)
@@ -2,6 +2,22 @@
 /**
  * Minimalist (mimp) compose display page.
  *
+ * URL Parameters:
+ *   'a' = (string) The action ID.
+ *   'action' = (string) TODO
+ *   'bcc' => (string) TODO
+ *   'bcc_expand_[1-5]' => (string) TODO
+ *   'cc' => (string) TODO
+ *   'cc_expand_[1-5]' => (string) TODO
+ *   'composeCache' = (string) TODO
+ *   'from' => (string) TODO
+ *   'identity' = (integer) The identity to use for composing.
+ *   'message' = (string) TODO
+ *   'subject' => (string) TODO
+ *   'to' => (string) TODO
+ *   'to_expand_[1-5]' => (string) TODO
+ *   'u' => (string) Unique ID (cache buster).
+ *
  * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (GPL). If you
@@ -16,6 +32,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp', array('impmode' => 'mimp'));
 
 Horde_Nls::setTimeZone();
+$vars = Horde_Variables::getDefaultVariables();
 
 /* The message text and headers. */
 $expand = array();
@@ -33,41 +50,36 @@ if ($prefs->getValue('compose_bcc')) {
 
 /* Set the current identity. */
 $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
-if (!$prefs->isLocked('default_identity')) {
-    $identity_id = Horde_Util::getFormData('identity');
-    if (!is_null($identity_id)) {
-        $identity->setDefault($identity_id);
-    }
+if (!$prefs->isLocked('default_identity') && isset($vars->identity)) {
+    $identity->setDefault($vars->identity);
 }
 
-$save_sent_mail = $prefs->getValue('save_sent_mail');
+$draft = IMP::folderPref($prefs->getValue('drafts_folder'), true);
 $sent_mail_folder = $identity->getValue('sent_mail_folder');
-$thismailbox = Horde_Util::getFormData('thismailbox');
-$uid = Horde_Util::getFormData('uid');
 
 /* Determine if mailboxes are readonly. */
-$draft = IMP::folderPref($prefs->getValue('drafts_folder'), true);
-$readonly_drafts = empty($draft) ? false : $imp_imap->isReadOnly($draft);
-if ($imp_imap->isReadOnly($sent_mail_folder)) {
-    $save_sent_mail = false;
-}
+$readonly_drafts = empty($draft)
+    ? false
+    : $imp_imap->isReadOnly($draft);
+$save_sent_mail = $imp_imap->isReadOnly($sent_mail_folder)
+    ? false
+    : $prefs->getValue('save_sent_mail');
 
 /* Determine if compose mode is disabled. */
 $compose_disable = !IMP::canCompose();
 
 /* Initialize objects. */
-$composeCache = Horde_Util::getFormData('composeCache');
-$imp_compose = IMP_Compose::singleton($composeCache);
+$imp_compose = IMP_Compose::singleton($vars->composeCache);
 $imp_ui = new IMP_Ui_Compose();
 
 foreach (array_keys($display_hdrs) as $val) {
-    $header[$val] = Horde_Util::getFormData($val);
+    $header[$val] = $vars->$val;
 
     /* If we are reloading the screen, check for expand matches. */
-    if ($composeCache) {
+    if ($vars->composeCache) {
         $expanded = array();
         for ($i = 0; $i < 5; ++$i) {
-            if ($tmp = Horde_Util::getFormData($val . '_expand_' . $i)) {
+            if ($tmp = $vars->get($val . '_expand_' . $i)) {
                 $expanded[] = $tmp;
             }
         }
@@ -80,12 +92,11 @@ foreach (array_keys($display_hdrs) as $val) {
 }
 
 /* Run through the action handlers. */
-$actionID = Horde_Util::getFormData('a');
-switch ($actionID) {
+switch ($vars->a) {
 // 'd' = draft
 case 'd':
     try {
-        $result = $imp_compose->resumeDraft($uid . IMP::IDX_SEP . $thismailbox);
+        $result = $imp_compose->resumeDraft($imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']);
 
         $msg = $result['msg'];
         $header = array_merge($header, $result['header']);
@@ -101,10 +112,8 @@ case 'd':
     break;
 
 case _("Expand Names"):
-    $action = Horde_Util::getFormData('action');
-
     foreach (array_keys($display_hdrs) as $val) {
-        if (($val == 'to') || ($action != 'rc')) {
+        if (($val == 'to') || ($vars->action != 'rc')) {
             $res = $imp_ui->expandAddresses($header[$val], $imp_compose);
             if (is_string($res)) {
                 $header[$val] = $res;
@@ -115,8 +124,8 @@ case _("Expand Names"):
         }
     }
 
-    if (!is_null($action)) {
-        $actionID = $action;
+    if (isset($vars->action)) {
+        $vars->a = $vars->action;
     }
     break;
 
@@ -126,11 +135,11 @@ case _("Expand Names"):
 case 'r':
 case 'ra':
 case 'rl':
-    if (!($imp_contents = $imp_ui->getIMPContents($uid, $thismailbox))) {
+    if (!($imp_contents = $imp_ui->getIMPContents($imp_mbox['uid'], $imp_mbox['thismailbox']))) {
         break;
     }
     $actions = array('r' => 'reply', 'ra' => 'reply_all', 'rl' => 'reply_list');
-    $reply_msg = $imp_compose->replyMessage($actions[$actionID], $imp_contents, $header['to']);
+    $reply_msg = $imp_compose->replyMessage($actions[$vars->a], $imp_contents, $header['to']);
     $header = $reply_msg['headers'];
 
     $notification->push(_("Reply text will be automatically appended to your outgoing message."), 'horde.message');
@@ -138,7 +147,7 @@ case 'rl':
 
 // 'f' = forward
 case 'f':
-    if (!($imp_contents = $imp_ui->getIMPContents($uid, $thismailbox))) {
+    if (!($imp_contents = $imp_ui->getIMPContents($imp_mbox['uid'], $imp_mbox['thismailbox']))) {
         break;
     }
     $fwd_msg = $imp_compose->forwardMessage('forward_attach', $imp_contents, false);
@@ -148,7 +157,7 @@ case 'f':
     break;
 
 case _("Redirect"):
-    if (!($imp_contents = $imp_ui->getIMPContents($uid, $thismailbox))) {
+    if (!($imp_contents = $imp_ui->getIMPContents($imp_compose->getMetadata('uid'), $imp_compose->getMetadata('mailbox')))) {
         break;
     }
 
@@ -162,14 +171,14 @@ case _("Redirect"):
         require IMP_BASE . '/mailbox-mimp.php';
         exit;
     } catch (Horde_Exception $e) {
-        $actionID = 'rc';
+        $vars->a = 'rc';
         $notification->push($e);
     }
     break;
 
 case _("Save Draft"):
 case _("Send"):
-    switch ($actionID) {
+    switch ($vars->a) {
     case _("Save Draft"):
         if ($readonly_drafts) {
             break 2;
@@ -183,17 +192,14 @@ case _("Send"):
         break;
     }
 
-    $message = Horde_Util::getFormData('message', '');
+    $message = strval($vars->message);
     $f_to = $header['to'];
     $f_cc = $f_bcc = null;
     $old_header = $header;
     $header = array();
 
-    $thismailbox = $imp_compose->getMetadata('mailbox');
-    $uid = $imp_compose->getMetadata('uid');
-
     if ($ctype = $imp_compose->getMetadata('reply_type')) {
-        if (!($imp_contents = $imp_ui->getIMPContents($uid, $thismailbox))) {
+        if (!($imp_contents = $imp_ui->getIMPContents($imp_compose->getMetadata('uid'), $imp_compose->getMetadata('mailbox')))) {
             break;
         }
 
@@ -213,18 +219,18 @@ case _("Send"):
     }
 
     try {
-        $header['from'] = $identity->getFromLine(null, Horde_Util::getFormData('from'));
+        $header['from'] = $identity->getFromLine(null, $vars->from);
     } catch (Horde_Exception $e) {
         $header['from'] = '';
     }
     $header['replyto'] = $identity->getValue('replyto_addr');
-    $header['subject'] = Horde_Util::getFormData('subject');
+    $header['subject'] = strval($vars->subject);
 
     foreach ($display_hdrs as $val) {
         $header[$val] = $imp_ui->getAddressList($old_header[$val]);
     }
 
-    switch ($actionID) {
+    switch ($vars->a) {
     case _("Save Draft"):
         try {
             $notification->push($imp_compose->saveDraft($header, $message, Horde_Nls::getCharset(), false), 'horde.success');
@@ -247,7 +253,7 @@ case _("Send"):
         $options = array(
             'save_sent' => $save_sent_mail,
             'sent_folder' => $sent_mail_folder,
-            'readreceipt' => Horde_Util::getFormData('request_read_receipt')
+            'readreceipt' => ($conf['compose']['allow_receipts'] && ($prefs->getValue('disposition_request_read') == 'always'))
         );
 
         try {
@@ -271,29 +277,75 @@ case _("Cancel"):
     exit;
 }
 
-/* Get the message cache ID. */
-$cacheID = $imp_compose->getCacheId();
-
-$title = _("Message Composition");
-$mimp_render = new Horde_Mobile();
-$mimp_render->set('title', $title);
-
-$select_list = $identity->getSelectList();
+/* Initialize Horde_Template. */
+$t = $injector->createInstance('Horde_Template');
+$t->setOption('gettext', true);
 
 /* Grab any data that we were supplied with. */
 if (empty($msg)) {
-    $msg = Horde_Util::getFormData('message', '');
+    $msg = strval($vars->message);
 }
 if (empty($header['subject'])) {
-    $header['subject'] = Horde_Util::getFormData('subject');
+    $header['subject'] = strval($vars->subject);
 }
 
-$menu = new Horde_Mobile_card('o', _("Menu"));
-$mset = $menu->add(new Horde_Mobile_linkset());
-IMP_Mimp::addMIMPMenu($mset, 'compose');
+$t->set('cacheid', htmlspecialchars($imp_compose->getCacheId()));
+$t->set('menu', $injector->getInstance('IMP_Ui_Mimp')->getMenu('compose'));
+$t->set('to', htmlspecialchars($header['to']));
+$t->set('url', Horde::applicationUrl('compose-mimp.php'));
 
-if ($actionID == 'rc') {
-    require IMP_TEMPLATES . '/compose/redirect-mimp.inc';
+if ($vars->a == 'rc') {
+    unset($display_hdrs['cc'], $display_hdrs['bcc']);
+    $title = _("Redirect");
 } else {
-    require IMP_TEMPLATES . '/compose/compose-mimp.inc';
+    $t->set('compose_enable', !$compose_disable);
+    $t->set('msg', htmlspecialchars($msg));
+    $t->set('save_draft', $conf['user']['allow_folders'] && !$readonly_drafts);
+    $t->set('subject', htmlspecialchars($header['subject']));
+
+    if (!$prefs->isLocked('default_identity')) {
+        $tmp = array();
+        foreach ($identity->getSelectList() as $key => $val) {
+            $tmp[] = array(
+                'key' => $key,
+                'sel' => ($key == $identity->getDefault()),
+                'val' => $val
+            );
+        }
+        $t->set('identities', $tmp);
+    }
+
+    $title = _("Message Composition");
 }
+
+$hdrs = array();
+foreach ($display_hdrs as $key => $val) {
+    $tmp = array(
+        'key' => $key,
+        'label' => htmlspecialchars($val),
+        'val' => $header[$key]
+    );
+
+    if (isset($expand[$key])) {
+        $tmp['matchlabel'] = (count($expand[$key][1]) > 5)
+            ? sprintf(_("Ambiguous matches for \"%s\" (first 5 matches displayed):"), $expand[$key][0])
+            : sprintf(_("Ambiguous matches for \"%s\":"), $expand[$key][0]);
+
+        $tmp['match'] = array();
+        foreach (array_slice($expand[$key][1], 0, 5) as $key2 => $val2) {
+            $tmp['match'][] = array(
+                'id' => $key . '_expand_' . $key2,
+                'val' => htmlspecialchars($val2)
+            );
+        }
+    }
+
+    $hdrs[] = $tmp;
+}
+
+$t->set('hdrs', $hdrs);
+$t->set('title', $title);
+
+require IMP_TEMPLATES . '/common-header.inc';
+IMP::status();
+echo $t->fetch(IMP_TEMPLATES . '/compose/compose-mimp.html');
index 05178fb..8dc7df0 100644 (file)
@@ -204,8 +204,7 @@ $prefGroups['mimp'] = array(
     'column' => _("Other Options"),
     'label' => _("Minimalist View Options"),
     'desc' => _("Configure options for the minimalist view."),
-    'members' => array('mimp_preview_msg', 'mimp_max_from_chars',
-                       'mimp_max_subj_chars', 'mimp_download_confirm')
+    'members' => array('mimp_preview_msg', 'mimp_download_confirm')
 );
 
 $prefGroups['standard'] = array(
@@ -1634,22 +1633,6 @@ $_prefs['mimp_preview_msg'] = array(
     'desc' => _("Display only the first 250 characters of a message initially?")
 );
 
-$_prefs['mimp_max_from_chars'] = array(
-    'value' => 10,
-    'locked' => true,
-    'shared' => false,
-    'type' => 'number',
-    'desc' => _("In the mailbox view, how many characters of From: addresses should we show before truncating?")
-);
-
-$_prefs['mimp_max_subj_chars'] = array(
-    'value' => 20,
-    'locked' => true,
-    'shared' => false,
-    'type' => 'number',
-    'desc' => _("In the mailbox view, how many characters of Subject: lines should we show before truncating?")
-);
-
 $_prefs['mimp_download_confirm'] = array(
     'value' => 0,
     'locked' => true,
index d8d9512..9cd622a 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Mobile view no longer uses Horde_Mobile to generate output.
 [jan] Implement iTip viewer actions in DIMP (Request #8061).
 [mms] Display alarm notifications in DIMP (Request #6232).
 [mms] Auto-determine charset for text attachments (Bug #8858).
index fbf3b3f..dca4654 100644 (file)
@@ -43,8 +43,7 @@ The 'show_preview' option has been removed; enabling previews is now handled
 by the 'show_preview' preference.
 
 The 'max_from_chars' and 'max_subj_chars' configuration options for the
-minimal (mimp) display have been moved to preferences ('mimp_max_from_chars'
-and 'mimp_max_subj_chars').
+minimal (mimp) display have been removed.
 
 The 'limit_factor' configuration option has been removed.
 
@@ -55,9 +54,9 @@ Preferences
 The following preferences are no longer used and may be safely removed from
 your ``config/prefs.php`` file and your preferences backend::
 
-   'alternative_display'
-   'attachment_display'
-   'forward_bodytext'
+   alternative_display
+   attachment_display
+   forward_bodytext
 
 
 Hooks
index 262c4e6..92a85b8 100644 (file)
@@ -42,23 +42,36 @@ if ($subscribe && Horde_Util::getFormData('ts')) {
     $mask |= IMP_Imap_Tree::NEXT_SHOWSUB;
 }
 
+/* Initialize Horde_Template. */
+$t = $injector->createInstance('Horde_Template');
+
 /* Start iterating through the list of mailboxes, displaying them. */
 $rows = array();
 $tree_ob = $imptree->build($mask);
 foreach ($tree_ob[0] as $val) {
     $rows[] = array(
-        'level' => str_repeat('..', $val['level']),
-        'label' => $val['base_elt']['l'],
-        'link' => ((empty($val['container'])) ? IMP::generateIMPUrl('mailbox-mimp.php', $val['value']) : null),
-        'msgs' => ((isset($val['msgs'])) ? ($val['unseen'] . '/' . $val['msgs']) : null)
+        'level' => str_repeat('&nbsp;', $val['level'] * 2),
+        'label' => htmlspecialchars(Horde_String::abbreviate($val['base_elt']['l'], 30 - ($val['level'] * 2))),
+        'link' => (empty($val['container']) ? IMP::generateIMPUrl('mailbox-mimp.php', $val['value']) : null),
+        'msgs' => (isset($val['msgs']) ? ($val['unseen'] . '/' . $val['msgs']) : null)
     );
 }
+$t->set('rows', $rows);
 
 $selfurl = Horde::applicationUrl('folders-mimp.php');
+$menu = array(array(_("Refresh"), $selfurl));
 if ($subscribe) {
-    $sub_text = $showAll ? _("Show Subscribed Folders") : _("Show All Folders");
-    $sub_link = $selfurl->copy()->add('ts', 1);
+    $menu[] = array(
+        ($showAll ? _("Show Subscribed Folders") : _("Show All Folders")),
+        $selfurl->copy()->add('ts', 1)
+    );
 }
 
+$t->set('menu', $injector->getInstance('IMP_Ui_Mimp')->getMenu('folders', $menu));
+
 $title = _("Folders");
-require IMP_TEMPLATES . '/folders/folders-mimp.inc';
+$t->set('title', $title);
+
+require_once IMP_TEMPLATES . '/common-header.inc';
+IMP::status();
+echo $t->fetch(IMP_TEMPLATES . '/folders/folders-mimp.html');
diff --git a/imp/lib/Mimp.php b/imp/lib/Mimp.php
deleted file mode 100644 (file)
index 6f732c5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * MIMP Base Class - provides minimalist view functions.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package IMP
- */
-class IMP_Mimp
-{
-    /**
-     * Take a Horde_Mobile_card and add global menu items.
-     *
-     * @param Horde_Mobile_linkset $menu  The menu linkset, with page-specific
-     *                                    options already filled in.
-     * @param string $page                The current page ('compose',
-     *                                    'folders', 'mailbox', 'message',
-     *                                    'search').
-     */
-    public function addMIMPMenu($menu, $page)
-    {
-        $items = array();
-
-        if (!in_array($page, array('mailbox', 'message')) ||
-            ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) {
-            $items[] = array(_("Inbox"), IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX'));
-        }
-
-        if (!in_array($page, array('compose', 'search')) && IMP::canCompose()) {
-            $items[] = array(_("New Message"), Horde::applicationUrl('compose-mimp.php')->add('u', uniqid(mt_rand())));
-        }
-
-        if (!in_array($page, array('folders', 'search'))) {
-            $items[] = array(_("Folders"), Horde::applicationUrl('folders-mimp.php'));
-        }
-
-        $items[] = array(_("Log out"), Horde::getServiceLink('logout', 'imp'));
-
-        foreach ($items as $val) {
-            $menu->add(new Horde_Mobile_link($val[0], $val[1]));
-        }
-
-        $menu = new Horde_Menu();
-        foreach ($menu->getSiteLinks() as $menuitem) {
-            if ($menuitem != 'separator') {
-                $menu->add(new Horde_Mobile_link($menuitem['text'], $menuitem['url']));
-            }
-        }
-    }
-
-}
index c57d56f..97ffeb8 100644 (file)
@@ -18,16 +18,12 @@ class IMP_Notification_Listener_AjaxStatus extends Horde_Notification_Listener_S
      * message stack.
      *
      * @param array $events   The list of events to handle.
-     * @param array $options  An array of options:
-     * <pre>
-     * 'mobile' - (Horde_Mobile) The mobile object to send status lines to.
-     * </pre>
+     * @param array $options  An array of options. Not used.
      */
     public function notify($events, $options = array())
     {
         Horde::addInlineScript(array(
-            'var ajax_dc = window.DimpCore || parent.DimpCore',
-            'if (ajax_dc) { ajax_dc.showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ') }'
+            'if (window.DimpCore || parent.DimpCore) { (window.DimpCore || parent.DimpCore).showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ') }'
         ), 'dom');
     }
 
diff --git a/imp/lib/Ui/Mimp.php b/imp/lib/Ui/Mimp.php
new file mode 100644 (file)
index 0000000..b5882eb
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Provides minimalist view (MIMP) helper functions.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Ui_Mimp
+{
+    /**
+     * Output the menu.
+     *
+     * @param string $page  The current page ('compose', 'folders', 'mailbox',
+     *                                        'message', 'search').
+     * @param array $items  TODO
+     *
+     * @return string  The menu.
+     */
+    public function getMenu($page, $items = array())
+    {
+        if (!in_array($page, array('mailbox', 'message')) ||
+            ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) {
+            $items[] = array(_("Inbox"), IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX'));
+        }
+
+        if (!in_array($page, array('compose', 'search')) && IMP::canCompose()) {
+            $items[] = array(_("New Message"), Horde::applicationUrl('compose-mimp.php')->add('u', uniqid(mt_rand())));
+        }
+
+        if (!in_array($page, array('folders', 'search'))) {
+            $items[] = array(_("Folders"), Horde::applicationUrl('folders-mimp.php'));
+        }
+
+        $items[] = array(_("Log out"), Horde::getServiceLink('logout', 'imp'));
+
+        $menu = new Horde_Menu();
+        foreach ($menu->getSiteLinks() as $menuitem) {
+            if ($menuitem != 'separator') {
+                $items[] = array($menuitem['text'], $menuitem['url']);
+            }
+        }
+
+        $out = '<ol>';
+        foreach ($items as $val) {
+            $out .= '<li><a href="' . $val[1] . '">' . htmlspecialchars($val[0]) . '</a></li>';
+        }
+        return $out . '</ol>';
+    }
+
+}
index 9de9bcd..4899964 100644 (file)
@@ -24,20 +24,21 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp', array('impmode' => 'mimp'));
 
 Horde_Nls::setTimeZone();
+$imp_ui_mimp = $injector->getInstance('IMP_Ui_Mimp');
+$vars = Horde_Variables::getDefaultVariables();
+
+/* Initialize Horde_Template. */
+$t = $injector->createInstance('Horde_Template');
+$t->setOption('gettext', true);
 
 /* Determine if mailbox is readonly. */
 $readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
 
-/* Need Horde_Mobile init here for autoloading purposes. */
-$mimp_render = new Horde_Mobile();
-
-/* Create mailbox menu. */
-$menu = new Horde_Mobile_card('o', _("Menu"));
-$mset = $menu->add(new Horde_Mobile_linkset());
+/* Get the base URL for this page. */
+$mailbox_url = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']);
 
 /* Run through the action handlers */
-$actionID = Horde_Util::getFormData('a');
-switch ($actionID) {
+switch ($vars->a) {
 // 'm' = message missing
 case 'm':
     $notification->push(_("There was an error viewing the requested message."), 'horde.error');
@@ -52,58 +53,60 @@ case 'e':
 
 // 'c' = change sort
 case 'c':
-    IMP::setSort(Horde_Util::getFormData('sb'), Horde_Util::getFormData('sd'));
+    IMP::setSort($vars->sb, $vars->sd);
     break;
 
 // 's' = search
 case 's':
-    IMP_Mimp::addMIMPMenu($mset, 'search');
-    require IMP_TEMPLATES . '/mailbox/search-mimp.inc';
+    $title = sprintf(_("Search %s"), IMP::getLabel($imp_mbox['mailbox']));
+
+    $t->set('mailbox', $imp_mbox['mailbox']);
+    $t->set('menu', $imp_ui_mimp->getMenu('search'));
+    $t->set('title', $title);
+    $t->set('url', $mailbox_url);
+
+    require_once IMP_TEMPLATES . '/common-header.inc';
+    IMP::status();
+    echo $t->fetch(IMP_TEMPLATES . '/mailbox/search-mimp.html');
     exit;
 
 // 'rs' = run search
 case 'rs':
-    $search_query = Horde_Util::getFormData('search');
-    if (!empty($search_query) &&
+    if (!empty($vars->search) &&
         ($_SESSION['imp']['protocol'] == 'imap')) {
         $query = new Horde_Imap_Client_Search_Query();
-        $query->text($search_query, false);
+        $query->text($vars->search, false);
 
         /* Create the search query and reset the global $imp_mbox variable. */
-        $sq = $imp_search->createSearchQuery($query, array(Horde_Util::getFormData('mailbox')), array(), _("Search Results"));
+        $sq = $imp_search->createSearchQuery($query, array($imp_mbox['mailbox']), array(), _("Search Results"));
         IMP::setCurrentMailboxInfo($imp_search->createSearchID($sq));
 
-        /* Need to re-calculate the read-only value. */
+        /* Need to re-calculate these values. */
         $readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
+        $mailbox_url = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']);
     }
     break;
 }
 
-/* Get the base URL for this page. */
-$mailbox_url = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']);
-
 /* Build the list of messages in the mailbox. */
 $imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox']);
-$pageOb = $imp_mailbox->buildMailboxPage(Horde_Util::getFormData('p'), Horde_Util::getFormData('s'));
+$pageOb = $imp_mailbox->buildMailboxPage($vars->p, $vars->s);
 
-/* Generate page links. */
-$pages_first = $pages_prev = $pages_last = $pages_next = null;
-if ($pageOb['page'] != 1) {
-    $pages_first = new Horde_Mobile_link(_("First Page"), $mailbox_url->copy()->add('p', 1));
-    $pages_prev = new Horde_Mobile_link(_("Previous Page"), $mailbox_url->copy()->add('p', $pageOb['page'] - 1));
-}
-if ($pageOb['page'] != $pageOb['pagecount']) {
-    $pages_next = new Horde_Mobile_link(_("Next Page"), $mailbox_url->copy()->add('p', $pageOb['page'] + 1));
-    $pages_last = new Horde_Mobile_link(_("Last Page"), $mailbox_url->copy()->add('p', $pageOb['pagecount']));
-}
-
-/* Generate mailbox summary string. */
+/* Generate page title. */
 $title = IMP::getLabel($imp_mbox['mailbox']);
-$mimp_render->set('title', $title);
+
+/* Modify title for display on page. */
 if ($pageOb['msgcount']) {
-    $msgcount = $pageOb['msgcount'];
     $unseen = $imp_mailbox->unseenMessages(Horde_Imap_Client::SORT_RESULTS_COUNT);
+    $title .= ' (' . $unseen . '/' .  $pageOb['msgcount'] . ')';
+}
+if ($pageOb['pagecount'] > 1) {
+    $title .= ' - ' . $pageOb['page'] . ' ' . _("of") . ' ' . $pageOb['pagecount'];
 }
+if ($readonly) {
+    $title .= ' [' . _("Read-Only") . ']';
+}
+$t->set('title', $title);
 
 $curr_time = time();
 $curr_time -= $curr_time % 60;
@@ -128,15 +131,12 @@ while (list(,$ob) = each($mbox_info['overview'])) {
     /* Initialize the header fields. */
     $msg = array(
         'status' => '',
-        'subject' => $imp_ui->getSubject($ob['envelope']['subject'])
+        'subject' => trim($imp_ui->getSubject($ob['envelope']['subject']))
     );
 
     /* Format the from header. */
     $getfrom = $imp_ui->getFrom($ob['envelope']);
-    $msg['from'] = $getfrom['from'];
-    if (Horde_String::length($msg['from']) > $prefs->getValue('mimp_max_from_chars')) {
-        $msg['from'] = Horde_String::substr($msg['from'], 0, $prefs->getValue('mimp_max_from_chars')) . '...';
-    }
+    $msg['from'] = Horde_String::truncate($getfrom['from'], 20);
 
     /* Get flag information. */
     $flag_parse = $injector->getInstance('IMP_Imap_Flags')->parse(array(
@@ -149,22 +149,16 @@ while (list(,$ob) = each($mbox_info['overview'])) {
         if (isset($val['abbrev'])) {
             $msg['status'] .= $val['abbrev'];
         } elseif ($val['type'] == 'imapp') {
-            $msg['subject'] = '*' .
-                ((Horde_String::length($val['label']) > 8)
-                     ? Horde_String::substr($val['label'], 0, 5) . '...'
-                     : $val['label']
-                ) .
-                '* ' . $msg['subject'];
+            $msg['subject'] = '*' . Horde_String::truncate($val['label'], 8) . '* ' . $msg['subject'];
         }
     }
 
-    if (!empty($threadtree[$ob['uid']])) {
-        $msg['subject'] = $threadtree[$ob['uid']] . trim($msg['subject']);
-    }
+    $msg['subject'] = Horde_String::truncate($msg['subject'], 30);
 
-    if (Horde_String::length($msg['subject']) > $prefs->getValue('mimp_max_subj_chars')) {
-        $msg['subject'] = Horde_String::substr($msg['subject'], 0, $prefs->getValue('mimp_max_subj_chars')) . '...';
-    }
+    /* Thread display. */
+    $msg['thread'] = empty($threadtree[$ob['uid']])
+        ? ''
+        : $threadtree[$ob['uid']];
 
     /* Generate the target link. */
     $msg['target'] = in_array('\\draft', $ob['flags'])
@@ -173,65 +167,74 @@ while (list(,$ob) = each($mbox_info['overview'])) {
 
     $msgs[] = $msg;
 }
+$t->set('msgs', $msgs);
 
 $mailbox = $mailbox_url->copy()->add('p', $pageOb['page']);
-$items = array(array(_("Refresh"), $mailbox));
+$menu = array(array(_("Refresh"), $mailbox));
 $search_mbox = $imp_search->isSearchMbox($imp_mbox['mailbox']);
 
 /* Determine if we are going to show the Purge Deleted link. */
 if (!$readonly &&
     !$prefs->getValue('use_trash') &&
     !$imp_search->isVINBOXFolder()) {
-    $items[] = array(_("Purge Deleted"), $mailbox->copy()->add('a', 'e'));
+    $menu[] = array(_("Purge Deleted"), $mailbox->copy()->add('a', 'e'));
 }
 
-/* Create sorting links. */
-$sort = array();
-$sort_list = array(
-    Horde_Imap_Client::SORT_ARRIVAL => '#',
-    Horde_Imap_Client::SORT_FROM => _("From"),
-    Horde_Imap_Client::SORT_SUBJECT => _("Subject")
+/* Create header links. */
+$hdr_list = array(
+    'hdr_arrival' => array('#', Horde_Imap_Client::SORT_ARRIVAL),
+    'hdr_from' => array(_("From"), Horde_Imap_Client::SORT_FROM),
+    'hdr_subject' => array(_("Subject"), Horde_Imap_Client::SORT_SUBJECT),
+    'hdr_thread' => array(_("Thread"), Horde_Imap_Client::SORT_THREAD)
 );
-foreach ($sort_list as $key => $val) {
-    if ($sortpref['limit']) {
-        $sort[$key] = (($key == Horde_Imap_Client::SORT_ARRIVAL) ? '*' : '') . $val;
+foreach ($hdr_list as $key => $val) {
+    if ($search_mbox ||
+        $sortpref['limit'] && ($key != 'hdr_arrival')) {
+        $t->set($key, $val[0]);
     } else {
-        $sortdir = $sortpref['dir'];
-        $sortkey = $key;
-        if (($key == Horde_Imap_Client::SORT_SUBJECT) &&
-            IMP::threadSortAvailable($mailbox) &&
-            !$search_mbox) {
-            if (is_null($imp_thread)) {
-                $items[] = array(_("Sort by Thread"), $mailbox->copy()->add(array('a' => 'c', 'sb' => Horde_Imap_Client::SORT_THREAD, 'sd' => $sortdir)));
-            } else {
-                $sortkey = Horde_Imap_Client::SORT_THREAD;
-                $items[] = array(_("Do Not Sort by Thread"), $mailbox->copy()->add(array('a' => 'c', 'sb' => Horde_Imap_Client::SORT_SUBJECT, 'sd' => $sortdir)));
-            }
-        }
-        if ($sortpref['by'] == $key) {
-            $val = '*' . $val;
-            $sortdir = !$sortdir;
+        $sort_link = $mailbox->copy()->add(array('a' => 'c', 'sb' => $val[1]));
+        if ($sortpref['by'] == $val[1]) {
+            $t->set($key, $val[0] . ' <a href="' . strval($sort_link->add('sd', intval(!$sortpref['dir']))) . '">' . ($sortpref['dir'] ? '^' : 'v') . '</a>');
+        } else {
+            $t->set($key, '<a href="' . $sort_link . '">' . $val[0] . '</a>');
         }
-        $sort[$key] = new Horde_Mobile_link($val, $mailbox->copy()->add(array('a' => 'c', 'sb' => $sortkey, 'sd' => $sortdir)));
     }
 }
 
-/* Add search link. */
+/* Add thread header entry. */
 if (!$search_mbox &&
-    ($_SESSION['imp']['protocol'] == 'imap')) {
-    $items[] = array(_("Search"), $mailbox_url->copy()->add('a', 's'));
+    !$sortpref['limit'] &&
+    IMP::threadSortAvailable($mailbox)) {
+    if (is_null($imp_thread)) {
+        $t->set('hdr_subject_minor', $t->get('hdr_thread'));
+    } else {
+        $t->set('hdr_subject_minor', $t->get('hdr_subject'));
+        $t->set('hdr_subject', $t->get('hdr_thread'));
+    }
 }
 
-foreach ($items as $val) {
-    $mset->add(new Horde_Mobile_link($val[0], $val[1]));
+/* Add search link. */
+if ($_SESSION['imp']['protocol'] == 'imap') {
+    if ($search_mbox) {
+        $orig_mbox = reset($imp_search->getSearchFolders());
+        $menu[] = array(sprintf(_("New Search in %s"), IMP::getLabel($orig_mbox)), IMP::generateIMPUrl('mailbox-mimp.php', $orig_mbox)->add('a', 's'));
+    } else {
+        $menu[] = array(_("Search"), $mailbox_url->copy()->add('a', 's'));
+    }
 }
 
-$nav = array('pages_first', 'pages_prev', 'pages_next', 'pages_last');
-foreach ($nav as $n) {
-    if (Horde_Util::nonInputVar($n)) {
-        $mset->add($$n);
-    }
+/* Generate page links. */
+if ($pageOb['page'] != 1) {
+    $menu[] = array(_("First Page"), $mailbox_url->copy()->add('p', 1));
+    $menu[] = array(_("Previous Page"), $mailbox_url->copy()->add('p', $pageOb['page'] - 1));
+}
+if ($pageOb['page'] != $pageOb['pagecount']) {
+    $menu[] = array(_("Next Page"), $mailbox_url->copy()->add('p', $pageOb['page'] + 1));
+    $menu[] = array(_("Last Page"), $mailbox_url->copy()->add('p', $pageOb['pagecount']));
 }
 
-IMP_Mimp::addMIMPMenu($mset, 'mailbox');
-require IMP_TEMPLATES . '/mailbox/mailbox-mimp.inc';
+$t->set('menu', $imp_ui_mimp->getMenu('mailbox', $menu));
+
+require_once IMP_TEMPLATES . '/common-header.inc';
+IMP::status();
+echo $t->fetch(IMP_TEMPLATES . '/mailbox/mailbox-mimp.html');
index 27fd707..ed4dffe 100644 (file)
@@ -22,6 +22,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('imp', array('impmode' => 'mimp'));
 
 Horde_Nls::setTimeZone();
+$vars = Horde_Variables::getDefaultVariables();
 
 /* Make sure we have a valid index. */
 $imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']);
@@ -38,9 +39,8 @@ $imp_ui = new IMP_Ui_Message();
 $readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
 
 /* Run through action handlers */
-$actionID = Horde_Util::getFormData('a');
 $msg_delete = false;
-switch ($actionID) {
+switch ($vars->a) {
 // 'd' = delete message
 // 'u' = undelete message
 case 'd':
@@ -51,13 +51,14 @@ case 'u':
 
     /* Get mailbox/UID of message. */
     $index_array = $imp_mailbox->getIMAPIndex();
+    $index_array = $imp_mailbox->getIMAPIndex();
     $indices_array = array($index_array['mailbox'] => array($index_array['uid']));
 
-    if ($actionID == 'u') {
+    if ($vars->a == 'u') {
         $imp_message->undelete($indices_array);
     } else {
         try {
-            Horde::checkRequestToken('imp.message-mimp', Horde_Util::getFormData('mt'));
+            Horde::checkRequestToken('imp.message-mimp', $vars->mt);
             $imp_message->delete($indices_array);
             $msg_delete = false;
         } catch (Horde_Exception $e) {
@@ -70,10 +71,8 @@ case 'u':
 // 'ri' = report innocent
 case 'rs':
 case 'ri':
-    if (IMP_Spam::reportSpam(array($index_array['mailbox'] => array($index_array['uid'])), $actionID == 'rs' ? 'spam' : 'innocent') === 1) {
-        $msg_delete = true;
-        break;
-    }
+    $index_array = $imp_mailbox->getIMAPIndex();
+    $msg_delete = (IMP_Spam::reportSpam(array($index_array['mailbox'] => array($index_array['uid'])), $vars->a == 'rs' ? 'spam' : 'innocent') === 1);
     break;
 
 // 'c' = confirm download
@@ -133,31 +132,28 @@ $msgindex = $imp_mailbox->getMessageIndex();
 $msgcount = $imp_mailbox->getMessageCount();
 
 /* Generate the mailbox link. */
-$mailbox_link = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox'])->add('s', $msgindex));
+$mailbox_link = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox'])->add('s', $msgindex);
 $self_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $uid, $mailbox_name);
 
-/* Init render object. */
-$mimp_render = new Horde_Mobile();
+/* Initialize Horde_Template. */
+$t = $injector->createInstance('Horde_Template');
+$t->setOption('gettext', true);
 
 /* Output download confirmation screen. */
-$atc_id = Horde_Util::getFormData('atc');
-if (($actionID == 'c') && !is_null($atc_id)) {
-    $summary = $imp_contents->getSummary($atc_id, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
-
-    $mimp_render->set('title', _("Verify Download"));
+if (($vars->a == 'c') && isset($vars->atc)) {
+    $summary = $imp_contents->getSummary($vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
 
-    $null = null;
-    $hb = $mimp_render->add(new Horde_Mobile_block($null));
+    $title = _("Verify Download");
 
-    $hb->add(new Horde_Mobile_text(_("Click to verify download of attachment") . ': '));
-    $hb->add(new Horde_Mobile_link($summary['description'], $summary['download']));
-    $t = $hb->add(new Horde_Mobile_text(sprintf(' [%s] %s', $summary['type'], $summary['size']) . "\n"));
-    $t->set('linebreaks', true);
+    $t->set('descrip', $summary['description']);
+    $t->set('download', $summary['download']);
+    $t->set('self_link', $self_link);
+    $t->set('size', $summary['size']);
+    $t->set('type', $summary['type']);
 
-    $hb = $mimp_render->add(new Horde_Mobile_block($null));
-    $hb->add(new Horde_Mobile_link(_("Return to message view"), $self_link));
+    require IMP_TEMPLATES . '/common-header.inc';
+    echo $t->fetch(IMP_TEMPLATES . '/message/download-mimp.html');
 
-    $mimp_render->display();
     exit;
 }
 
@@ -188,12 +184,7 @@ foreach (array('to', 'cc', 'bcc') as $val) {
 /* Process the subject now. */
 if (($subject = $mime_headers->getValue('subject'))) {
     /* Filter the subject text, if requested. */
-    $subject = IMP::filterText($subject);
-
-    /* Generate the shortened subject text. */
-    if (Horde_String::length($subject) > $conf['mimp']['mailbox']['max_subj_chars']) {
-        $subject = Horde_String::substr($subject, 0, $conf['mimp']['mailbox']['max_subj_chars']) . '...';
-    }
+    $subject = Horde_String::truncate(IMP::filterText($subject), 30);
 } else {
     $subject = _("[No Subject]");
 }
@@ -239,16 +230,6 @@ foreach ($flag_parse as $val) {
     }
 }
 
-/* Generate previous/next links. */
-$prev_msg = $imp_mailbox->getIMAPIndex(-1);
-if ($prev_msg) {
-    $prev_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $prev_msg['uid'], $prev_msg['mailbox']);
-}
-$next_msg = $imp_mailbox->getIMAPIndex(1);
-if ($next_msg) {
-    $next_link = IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $next_msg['uid'], $next_msg['mailbox']);
-}
-
 /* Create the body of the message. */
 $parts_list = $imp_contents->getContentTypeMap();
 $atc_parts = $display_ids = array();
@@ -293,25 +274,13 @@ foreach ($parts_list as $mime_id => $mime_type) {
 
 /* Display the first 250 characters, or display the entire message? */
 if ($prefs->getValue('mimp_preview_msg') &&
-    !Horde_Util::getFormData('fullmsg') &&
+    !isset($vars->fullmsg) &&
     (strlen($msg_text) > 250)) {
     $msg_text = Horde_String::substr(trim($msg_text), 0, 250) . " [...]\n";
-    $fullmsg_link = new Horde_Mobile_link(_("View Full Message"), $self_link->copy()->add('fullmsg', 1));
-} else {
-    $fullmsg_link = null;
+    $t->set('fullmsg_link', $self_link->copy()->add('fullmsg', 1));
 }
 
-/* Create message menu. */
-$menu = new Horde_Mobile_card('o', _("Menu"));
-$mset = $menu->add(new Horde_Mobile_linkset());
-
-if (!$readonly) {
-    if (in_array('\\deleted', $flags)) {
-        $mset->add(new Horde_Mobile_link(_("Undelete"), $self_link->copy()->add('a', 'u')));
-    } else {
-        $mset->add(new Horde_Mobile_link(_("Delete"), $self_link->copy()->add(array('a' => 'd', 'mt' => Horde::getRequestToken('imp.message-mimp')))));
-    }
-}
+$t->set('msg', nl2br(Horde_Text_Filter::filter($msg_text, 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true))));
 
 $compose_params = array(
     'identity' => $identity,
@@ -319,101 +288,95 @@ $compose_params = array(
     'uid' => $uid,
 );
 
+$menu = array();
+if (!$readonly) {
+    $menu[] = in_array('\\deleted', $flags)
+        ? array(_("Undelete"), $self_link->copy()->add('a', 'u'))
+        : array(_("Delete"), $self_link->copy()->add(array('a' => 'd', 'mt' => Horde::getRequestToken('imp.message-mimp'))));
+}
+
 /* Add compose actions (Reply, Reply List, Reply All, Forward, Redirect). */
 if (IMP::canCompose()) {
-    $items = array(IMP::composeLink(array(), array('a' => 'r') + $compose_params) => _("Reply"));
+    $menu[] = array(_("Reply"), IMP::composeLink(array(), array('a' => 'r') + $compose_params));
 
     if ($list_info['reply_list']) {
-        $items[IMP::composeLink(array(), array('a' => 'rl') + $compose_params)] = _("Reply to List");
+        $menu[] = array(_("Reply to List"), IMP::composeLink(array(), array('a' => 'rl') + $compose_params));
     }
 
     if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array('filter' => array_keys($user_identity->getAllFromAddresses(true))))) {
-        $items[IMP::composeLink(array(), array('a' => 'ra') + $compose_params)] = _("Reply All");
+        $menu[] = array(_("Reply All"), IMP::composeLink(array(), array('a' => 'ra') + $compose_params));
     }
 
-    $items[IMP::composeLink(array(), array('a' => 'f') + $compose_params)] = _("Forward");
-    $items[IMP::composeLink(array(), array('a' => 'rc') + $compose_params)] = _("Redirect");
-}
-
-foreach ($items as $link => $label) {
-    $mset->add(new Horde_Mobile_link($label, $link));
+    $menu[] = array(_("Forward"), IMP::composeLink(array(), array('a' => 'f') + $compose_params));
+    $menu[] = array(_("Redirect"), IMP::composeLink(array(), array('a' => 'rc') + $compose_params));
 }
 
-if (isset($next_link)) {
-    $mset->add(new Horde_Mobile_link(_("Next Message"), $next_link));
+/* Generate previous/next links. */
+if ($prev_msg = $imp_mailbox->getIMAPIndex(-1)) {
+    $menu[] = array(_("Previous Message"), IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $prev_msg['uid'], $prev_msg['mailbox']));
 }
-if (isset($prev_link)) {
-    $mset->add(new Horde_Mobile_link(_("Previous Message"), $prev_link));
+if ($next_msg = $imp_mailbox->getIMAPIndex(1)) {
+    $menu[] = array(_("Next Message"), IMP::generateIMPUrl('message-mimp.php', $imp_mbox['mailbox'], $next_msg['uid'], $next_msg['mailbox']));
 }
 
-$mset->add(new Horde_Mobile_link(sprintf(_("To %s"), IMP::getLabel($imp_mbox['mailbox'])), $mailbox_link));
+$menu[] = array(sprintf(_("To %s"), IMP::getLabel($imp_mbox['mailbox'])), $mailbox_link);
 
 if ($conf['spam']['reporting'] &&
     ($conf['spam']['spamfolder'] ||
      ($mailbox_name != IMP::folderPref($prefs->getValue('spam_folder'), true)))) {
-    $mset->add(new Horde_Mobile_link(_("Report as Spam"), $self_link->copy()->add(array('a' => 'rs', 'mt' => Horde::getRequestToken('imp.message-mimp')))));
+    $menu[] = array(_("Report as Spam"), $self_link->copy()->add(array('a' => 'rs', 'mt' => Horde::getRequestToken('imp.message-mimp'))));
 }
 
 if ($conf['notspam']['reporting'] &&
     (!$conf['notspam']['spamfolder'] ||
      ($mailbox_name == IMP::folderPref($prefs->getValue('spam_folder'), true)))) {
-    $mset->add(new Horde_Mobile_link(_("Report as Innocent"), $self_link->copy()->add(array('a' => 'ri', 'mt' => Horde::getRequestToken('imp.message-mimp')))));
+    $menu[] = array(_("Report as Innocent"), $self_link->copy()->add(array('a' => 'ri', 'mt' => Horde::getRequestToken('imp.message-mimp'))));
 }
 
-IMP_Mimp::addMIMPMenu($mset, 'message');
-
-$mimp_render->set('title', $display_headers['subject']);
-
-$c = $mimp_render->add(new Horde_Mobile_card('m', ($status ? $status . ' | ' : '') . $display_headers['subject'] . ' ' . sprintf(_("(%d of %d)"), $msgindex, $msgcount)));
-$c->softkey('#o', _("Menu"));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-$null = null;
-$hb = $c->add(new Horde_Mobile_block($null));
-
-$allto_param = Horde_Util::getFormData('allto');
+$t->set('menu', $injector->getInstance('IMP_Ui_Mimp')->getMenu('message', $menu));
 
+$hdrs = array();
 foreach ($display_headers as $head => $val) {
-    $all_to = false;
-    $hb->add(new Horde_Mobile_text($basic_headers[$head] . ': ', array('b')));
+    $tmp = array(
+        'label' => htmlspecialchars($basic_headers[$head])
+    );
     if ((Horde_String::lower($head) == 'to') &&
-        !$allto_param &&
+        !isset($vars->allto) &&
         (($pos = strpos($val, ',')) !== false)) {
         $val = Horde_String::substr($val, 0, strpos($val, ','));
-        $all_to = true;
+        $tmp['all_to'] = $self_link->copy()->add('allto', 1);
     }
-    $t = $hb->add(new Horde_Mobile_text($val . (($all_to) ? ' ' : "\n")));
-    if ($all_to) {
-        $hb->add(new Horde_Mobile_link('[' . _("Show All") . ']', $self_link->copy()->add('allto', 1)));
-        $t = $hb->add(new Horde_Mobile_text("\n"));
-    }
-    $t->set('linebreaks', true);
+    $tmp['val'] = $val;
+    $hdrs[] = $tmp;
 }
+$t->set('hdrs', $hdrs);
 
+$atc = array();
 foreach ($atc_parts as $key) {
     $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
-    $hb->add(new Horde_Mobile_text(_("Attachment") . ': ', array('b')));
-    if (empty($summary['download'])) {
-        $hb->add(new Horde_Mobile_text($summary['description']));
-    } else {
+
+    $tmp = array(
+        'descrip' => $summary['description'],
+        'size' => $summary['size'],
+        'type' => $summary['type']
+    );
+
+    if (!empty($summary['download'])) {
         /* Preference: if set, only show download confirmation screen if
          * attachment over a certain size. */
-        $download_link = ($summary['bytes'] > $prefs->getValue('mimp_download_confirm'))
+        $tmp['download'] = ($summary['bytes'] > $prefs->getValue('mimp_download_confirm'))
             ? $self_link->copy()->add(array('a' => 'c', 'atc' => $key))
             : $summary['download'];
-        $hb->add(new Horde_Mobile_link($summary['description'], $download_link));
     }
-    $t = $hb->add(new Horde_Mobile_text(sprintf(' [%s] %s', $summary['type'], $summary['size']) . "\n"));
-    $t->set('linebreaks', true);
+
+    $atc[] = $tmp;
 }
+$t->set('atc', $atc);
 
-$t = $c->add(new Horde_Mobile_text($msg_text));
-$t->set('linebreaks', true);
+$title = $display_headers['subject'];
+$t->set('title', ($status ? $status . ' | ' : '') . $display_headers['subject'] . ' ' . sprintf(_("(%d of %d)"), $msgindex, $msgcount));
 
-if (!is_null($fullmsg_link)) {
-    $c->add($fullmsg_link);
-}
+require IMP_TEMPLATES . '/common-header.inc';
+IMP::status();
+echo $t->fetch(IMP_TEMPLATES . '/message/message-mimp.html');
 
-$mimp_render->add($menu);
-$mimp_render->display();
index 5f26ca5..8205e7a 100644 (file)
@@ -9,6 +9,10 @@ case 'dimp':
     include IMP_TEMPLATES . '/javascript_defs_dimp.php';
     break;
 
+case 'mimp':
+    // Nothing
+    break;
+
 default:
     include IMP_TEMPLATES . '/javascript_defs.php';
     break;
@@ -38,6 +42,10 @@ case 'dimp':
     Horde::includeStylesheetFiles(array('sub' => 'dimp'));
     break;
 
+case 'mimp':
+    // Nothing
+    break;
+
 default:
     Horde::includeStylesheetFiles();
     Horde::includeScriptFiles();
@@ -45,10 +53,14 @@ default:
 }
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
+<?php if ($imp_view == 'mimp'): ?>
+</head>
+<body>
+<?php elseif ($imp_view == 'dimp'): ?>
 <link href="<?php echo $GLOBALS['registry']->getImageDir() ?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php if ($imp_view == 'dimp'): ?>
 </head>
 <?php else: ?>
+<link href="<?php echo $GLOBALS['registry']->getImageDir() ?>/favicon.ico" rel="SHORTCUT ICON" />
 <?php if ($mailbox_url = Horde_Util::nonInputVar('mailbox_url')): ?>
 <link href="<?php echo $mailbox_url ?>" rel="Up" />
 <?php elseif (!Horde_Util::nonInputVar('login_page')): ?>
diff --git a/imp/templates/compose/compose-mimp.html b/imp/templates/compose/compose-mimp.html
new file mode 100644 (file)
index 0000000..80f34ab
--- /dev/null
@@ -0,0 +1,63 @@
+  <div><tag:title /></div>
+  <hr />
+  <form action="<tag:url />" method="post">
+   <input type="hidden" name="composeCache" value="<tag:cacheid />" />
+<if:redirect>
+   <input type="hidden" name="action" value="rc" />
+<else:redirect>
+   <p>
+    <label for="identity">
+     <gettext>From:</gettext>
+     <select id="identity" name="identity">
+<loop:identities>
+      <option value="<tag:identities.key />"<if:identities.sel> selected="selected"</if:identities.sel>><tag:identities.val /></option>
+</loop:identities>
+     </select>
+    </label>
+   </p>
+</if:redirect>
+<loop:hdrs>
+   <p>
+    <label for="<tag:hdrs.key />">
+     <tag:hdrs.label />
+     <input id="<tag:hdrs.key />" name="<tag:hdrs.key />" value="<tag:hdrs.val />" />
+    </label>
+   </p>
+<if:hdrs.matchlabel>
+   <blockquote>
+    <div><tag:hdrs.matchlabel /></div>
+<loop:hdrs.match>
+    <div><label for="<tag:hdrs.match.id />"><input type="checkbox" name="<tag:hdrs.match.id />" id="<tag:hdrs.match.id />" value="<tag:hdrs.match.val />" /><tag:hdrs.match.val /></label></div>
+</loop:hdrs.match>
+   </blockquote>
+</if:hdrs.matchlabel>
+</loop:hdrs>
+<if:redirect>
+   <p>
+    <input type="submit" name="a" value="<gettext>Redirect</gettext>" />
+<else:redirect>
+   <p>
+    <gettext>Subject:</gettext> <input name="subject" value="<tag:subject />" />
+   </p>
+   <p>
+    <gettext>Message:</gettext>
+    <br />
+    <textarea name="message" rows="10" cols="80"><tag:msg /></textarea>
+   </p>
+   <p>
+<if:compose_enable>
+    <input type="submit" name="a" value="<gettext>Send</gettext>" />
+</if:compose_enable>
+<if:save_draft>
+    <input type="submit" name="a" value="<gettext>Save Draft</gettext>" />
+</if:save_draft>
+</else:redirect></if:redirect>
+    <input type="submit" name="a" value="<gettext>Expand Names</gettext>" />
+    <input type="submit" name="a" value="<gettext>Cancel</gettext>" />
+   </p>
+  </form>
+  <hr />
+  <div><gettext>Menu</gettext></div>
+  <tag:menu />
+ </body>
+</html>
diff --git a/imp/templates/compose/compose-mimp.inc b/imp/templates/compose/compose-mimp.inc
deleted file mode 100644 (file)
index 1c93bfb..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-$c = $mimp_render->add(new Horde_Mobile_card('m', $title));
-$c->softkey('#o', _("Menu"));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-$f = $c->add(new Horde_Mobile_form('compose-mimp.php'));
-
-// Hidden Variables.
-$f->add(new Horde_Mobile_hidden('composeCache', $cacheID));
-
-if (!$prefs->isLocked('default_identity')) {
-    $ib = $f->add(new Horde_Mobile_block(new Horde_Mobile_text(_("Identity: "))));
-    $ident_sel = $ib->add(new Horde_Mobile_select('identity'));
-    $default = Horde_Util::getFormData('identity', $identity->getDefault());
-    foreach ($select_list as $key => $select) {
-        $ident_sel->add($select, $key, ($key == $default));
-    }
-}
-
-foreach ($display_hdrs as $key => $val) {
-    $f->add(new Horde_Mobile_input($key, $header[$key], $val));
-    if (isset($expand[$key])) {
-        if (count($expand[$key][1]) > 5) {
-            $f->add(new Horde_Mobile_text(sprintf(_("Ambiguous matches for \"%s\" (first 5 matches displayed):"), $expand[$key][0])));
-        } else {
-            $f->add(new Horde_Mobile_text(sprintf(_("Ambiguous matches for \"%s\":"), $expand[$key][0])));
-        }
-
-        foreach (array_slice($expand[$key][1], 0, 5) as $key2 => $val2) {
-            $f->add(new Horde_Mobile_checkbox($key . '_expand_' . $key2, htmlspecialchars($val2), $val2, false));
-        }
-    }
-}
-
-$f->add(new Horde_Mobile_input('subject', $header['subject'], _("Subject: ")));
-
-$f->add(new Horde_Mobile_textarea('message', $msg, _("Message: "), 10, 80));
-
-if (!$compose_disable) {
-    $f->add(new Horde_Mobile_submit(_("Send"), 'a'));
-}
-if ($conf['user']['allow_folders'] && !$readonly_drafts) {
-    $f->add(new Horde_Mobile_submit(_("Save Draft"), 'a'));
-}
-
-$f->add(new Horde_Mobile_submit(_("Expand Names"), 'a'));
-$f->add(new Horde_Mobile_submit(_("Cancel"), 'a'));
-
-$mimp_render->add($menu);
-$mimp_render->display();
diff --git a/imp/templates/compose/redirect-mimp.inc b/imp/templates/compose/redirect-mimp.inc
deleted file mode 100644 (file)
index d0eb6b2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-$c = &$mimp_render->add(new Horde_Mobile_card('m', $title));
-$c->softkey('#o', _("Menu"));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-$f = &$c->add(new Horde_Mobile_form('compose.php'));
-
-$f->add(new Horde_Mobile_hidden('action', 'rc'));
-$f->add(new Horde_Mobile_hidden('thismailbox', $thismailbox));
-$f->add(new Horde_Mobile_hidden('uid', $uid));
-
-$f->add(new Horde_Mobile_input('to', $header['to'], _("To: ")));
-
-$f->add(new Horde_Mobile_submit(_("Redirect"), 'a'));
-$f->add(new Horde_Mobile_submit(_("Expand Names"), 'a'));
-
-$mimp_render->add($menu);
-$mimp_render->display();
diff --git a/imp/templates/folders/folders-mimp.html b/imp/templates/folders/folders-mimp.html
new file mode 100644 (file)
index 0000000..4a99017
--- /dev/null
@@ -0,0 +1,10 @@
+  <div><tag:title /></div>
+  <hr />
+<loop:rows>
+  <div><tag:rows.level /><if:rows.link><a href="<tag:rows.link />"><tag:rows.label /></a><else:rows.link><tag:rows.label /></else:rows.link></if:rows.link><if:rows.msgs> (<tag:rows.msgs />)</if:rows.msgs></div>
+</loop:rows>
+  <hr />
+  <div><gettext>Menu</gettext></div>
+  <tag:menu />
+ </body>
+</html>
diff --git a/imp/templates/folders/folders-mimp.inc b/imp/templates/folders/folders-mimp.inc
deleted file mode 100644 (file)
index c8809e6..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-$mimp_render = new Horde_Mobile();
-$mimp_render->set('title', $title);
-$c = &$mimp_render->add(new Horde_Mobile_card('m', $title));
-$c->softkey('#o', _("Menu"));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-$null = null;
-$fb = &$c->add(new Horde_Mobile_block($null));
-
-foreach ($rows as $val) {
-    $fb->add(new Horde_Mobile_text($val['level']));
-    if (empty($val['link'])) {
-        $fb->add(new Horde_Mobile_text($val['label']));
-    } else {
-        $fb->add(new Horde_Mobile_link($val['label'], $val['link']));
-    }
-    if (!is_null($val['msgs'])) {
-        $fb->add(new Horde_Mobile_text(' (' . $val['msgs'] . ')'));
-    }
-
-    $t = &$fb->add(new Horde_Mobile_text("\n"));
-    $t->set('linebreaks', true);
-}
-
-$menu = new Horde_Mobile_card('o', _("Menu"));
-$mset = &$menu->add(new Horde_Mobile_linkset());
-$mset->add(new Horde_Mobile_link(_("Refresh"), $selfurl));
-if ($subscribe) {
-    $mset->add(new Horde_Mobile_link($sub_text, $sub_link));
-}
-IMP_Mimp::addMIMPMenu($mset, 'folders');
-
-$mimp_render->add($menu);
-$mimp_render->display();
diff --git a/imp/templates/mailbox/mailbox-mimp.html b/imp/templates/mailbox/mailbox-mimp.html
new file mode 100644 (file)
index 0000000..776c4a0
--- /dev/null
@@ -0,0 +1,25 @@
+  <div><tag:title /></div>
+  <hr />
+<if:msgs>
+  <table>
+   <tr>
+    <th><tag:hdr_arrival /></th>
+    <th><tag:hdr_from /></th>
+    <th><tag:hdr_subject /><if:hdr_subject_minor> <small>[<tag:hdr_subject_minor />]</small></if:hdr_subject_minor></th>
+   </tr>
+<loop:msgs>
+   <tr>
+    <td><tag:msgs.status /></td>
+    <td><tag:msgs.from /></td>
+    <td><tag:msgs.thread /> <a href="<tag:msgs.target />"><tag:msgs.subject /></a></td>
+   </tr>
+</loop:msgs>
+  </table>
+<else:msgs>
+<div><gettext>No messages.</gettext></div>
+</else:msgs></if:msgs>
+  <hr />
+  <div><gettext>Menu</gettext></div>
+  <tag:menu />
+ </body>
+</html>
diff --git a/imp/templates/mailbox/mailbox-mimp.inc b/imp/templates/mailbox/mailbox-mimp.inc
deleted file mode 100644 (file)
index de40e68..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-if (!empty($msgcount)) {
-    $title .= ' (' . $unseen . '/' .  $msgcount . ')';
-}
-if ($pageOb['pagecount'] > 1) {
-    $title .= ' - ' . $pageOb['page'] . ' ' . _("of") . ' ' . $pageOb['pagecount'];
-}
-
-if ($readonly) {
-    $title .= ' [' . _("Read-Only") . ']';
-}
-
-$mimp_render = new Horde_Mobile();
-$c = &$mimp_render->add(new Horde_Mobile_card('m', $title));
-$c->softkey('#o', _("Menu"));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-if (!empty($pageOb['end'])) {
-    $elts = null;
-    $t = &$c->add(new Horde_Mobile_table($elts));
-    $t->set('border', 0);
-    $t->set('padding', 1);
-    $t->set('spacing', 1);
-
-    $r = &$t->add(new Horde_Mobile_row());
-    $r->add($sort[Horde_Imap_Client::SORT_ARRIVAL]);
-    $r->add($sort[Horde_Imap_Client::SORT_FROM]);
-    $r->add($sort[Horde_Imap_Client::SORT_SUBJECT]);
-
-    $i = 1;
-    foreach ($msgs as $msg) {
-        $r = &$t->add(new Horde_Mobile_row());
-        $r->add($msg['status']);
-        $r->add($msg['from']);
-        $l = &$r->add(new Horde_Mobile_link($msg['subject'], $msg['target']));
-        $l->set('accesskey', $i++);
-    }
-}
-
-$mimp_render->add($menu);
-$mimp_render->display();
diff --git a/imp/templates/mailbox/search-mimp.html b/imp/templates/mailbox/search-mimp.html
new file mode 100644 (file)
index 0000000..ab5e9e9
--- /dev/null
@@ -0,0 +1,17 @@
+  <div><tag:title /></div>
+  <hr />
+  <form action="<tag:url />" method="post">
+   <input type="hidden" name="a" value="rs" />
+   <input type="hidden" name="mailbox" value="<tag:mailbox />" />
+   <p>
+    <gettext>Search:</gettext> <input name="search" />
+   </p>
+   <p>
+    <input type="submit" name="a" value="<gettext>Run Search</gettext>" />
+   </p>
+  </form>
+  <hr />
+  <div><gettext>Menu</gettext></div>
+  <tag:menu />
+ </body>
+</html>
diff --git a/imp/templates/mailbox/search-mimp.inc b/imp/templates/mailbox/search-mimp.inc
deleted file mode 100644 (file)
index 775c7d5..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-$mimp_render = new Horde_Mobile();
-$c = $mimp_render->add(new Horde_Mobile_card('m', sprintf(_("Search %s"), $imp_mbox['mailbox'])));
-
-$notification->notify(array('listeners' => 'status', 'mobile' => $c));
-
-$f = $c->add(new Horde_Mobile_form('mailbox-mimp.php'));
-
-$f->add(new Horde_Mobile_hidden('a', 'rs'));
-$f->add(new Horde_Mobile_hidden('mailbox', $imp_mbox['mailbox']));
-
-$f->add(new Horde_Mobile_input('search', '', _("Search:")));
-
-$f->add(new Horde_Mobile_submit(_("Run Search"), 'submit'));
-
-$mimp_render->add($menu);
-$mimp_render->display();
diff --git a/imp/templates/message/download-mimp.html b/imp/templates/message/download-mimp.html
new file mode 100644 (file)
index 0000000..0975f1f
--- /dev/null
@@ -0,0 +1,10 @@
+  <p>
+   <gettext>Click to verify download of attachment</gettext>:
+   <a href="<tag:download />"><tag:descrip /></a>
+   [<tag:type />] <tag:size />
+  </p>
+  <p>
+   <a href="<tag:self_link />"><gettext>Return to message view</gettext></a>
+  </p>
+ </body>
+</html>
diff --git a/imp/templates/message/message-mimp.html b/imp/templates/message/message-mimp.html
new file mode 100644 (file)
index 0000000..cb8453c
--- /dev/null
@@ -0,0 +1,23 @@
+  <div><tag:title /></div>
+  <hr />
+  <p>
+<loop:hdrs>
+   <div><em><tag:hdrs.label />:</em> <tag:hdrs.val /><if:hdrs.all_to> [<a href="<tag:hdrs.all_to />"><gettext>Show All</gettext></a>]</if:hdrs.all_to></div>
+</loop:hdrs>
+<loop:atc>
+   <div><em><gettext>Attachment</gettext>:</em> <if:atc.download><a href="<tag:atc.download />"><tag:atc.descrip /></a><else:atc.download><tag:atc.descrip /></else:atc.download></if:atc.download> [<tag:atc.type />] <tag:atc.size /></div>
+</loop:atc>
+  </p>
+  <p>
+   <tag:msg />
+  </p>
+<if:fullmsg_link>
+  <p>
+   <a href="<tag:fullmsg_link />"><gettext>View Full Message</gettext></a>
+  </p>
+</if:fullmsg_link>
+  <hr />
+  <div><gettext>Menu</gettext></div>
+  <tag:menu />
+ </body>
+</html>