From ae01e1a6e888ae56749fad1ef5d249fa7d7e4d05 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 3 Mar 2010 23:43:49 -0700 Subject: [PATCH] IMP: Remove Horde_Mobile dependency --- imp/compose-mimp.php | 166 +++++++++++++++--------- imp/config/prefs.php.dist | 19 +-- imp/docs/CHANGES | 1 + imp/docs/UPGRADING | 9 +- imp/folders-mimp.php | 27 +++- imp/lib/Notification/Listener/AjaxStatus.php | 8 +- imp/lib/{ => Ui}/Mimp.php | 32 ++--- imp/mailbox-mimp.php | 183 ++++++++++++++------------- imp/message-mimp.php | 183 +++++++++++---------------- imp/templates/common-header.inc | 14 +- imp/templates/compose/compose-mimp.html | 63 +++++++++ imp/templates/compose/compose-mimp.inc | 52 -------- imp/templates/compose/redirect-mimp.inc | 20 --- imp/templates/folders/folders-mimp.html | 10 ++ imp/templates/folders/folders-mimp.inc | 37 ------ imp/templates/mailbox/mailbox-mimp.html | 25 ++++ imp/templates/mailbox/mailbox-mimp.inc | 43 ------- imp/templates/mailbox/search-mimp.html | 17 +++ imp/templates/mailbox/search-mimp.inc | 18 --- imp/templates/message/download-mimp.html | 10 ++ imp/templates/message/message-mimp.html | 23 ++++ 21 files changed, 480 insertions(+), 480 deletions(-) rename imp/lib/{ => Ui}/Mimp.php (64%) create mode 100644 imp/templates/compose/compose-mimp.html delete mode 100644 imp/templates/compose/compose-mimp.inc delete mode 100644 imp/templates/compose/redirect-mimp.inc create mode 100644 imp/templates/folders/folders-mimp.html delete mode 100644 imp/templates/folders/folders-mimp.inc create mode 100644 imp/templates/mailbox/mailbox-mimp.html delete mode 100644 imp/templates/mailbox/mailbox-mimp.inc create mode 100644 imp/templates/mailbox/search-mimp.html delete mode 100644 imp/templates/mailbox/search-mimp.inc create mode 100644 imp/templates/message/download-mimp.html create mode 100644 imp/templates/message/message-mimp.html diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 916c1ba98..2838601c0 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -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'); diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 05178fb88..8dc7df026 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -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, diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index d8d951208..9cd622add 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -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). diff --git a/imp/docs/UPGRADING b/imp/docs/UPGRADING index fbf3b3f6a..dca4654fe 100644 --- a/imp/docs/UPGRADING +++ b/imp/docs/UPGRADING @@ -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 diff --git a/imp/folders-mimp.php b/imp/folders-mimp.php index 262c4e631..92a85b851 100644 --- a/imp/folders-mimp.php +++ b/imp/folders-mimp.php @@ -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(' ', $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/Notification/Listener/AjaxStatus.php b/imp/lib/Notification/Listener/AjaxStatus.php index c57d56f09..97ffeb8b7 100644 --- a/imp/lib/Notification/Listener/AjaxStatus.php +++ b/imp/lib/Notification/Listener/AjaxStatus.php @@ -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: - *
-     * 'mobile' - (Horde_Mobile) The mobile object to send status lines to.
-     * 
+ * @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/Mimp.php b/imp/lib/Ui/Mimp.php similarity index 64% rename from imp/lib/Mimp.php rename to imp/lib/Ui/Mimp.php index 6f732c5e7..b5882ebe3 100644 --- a/imp/lib/Mimp.php +++ b/imp/lib/Ui/Mimp.php @@ -1,6 +1,6 @@ * @package IMP */ -class IMP_Mimp +class IMP_Ui_Mimp { /** - * Take a Horde_Mobile_card and add global menu items. + * Output the menu. * - * @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'). + * @param string $page The current page ('compose', 'folders', 'mailbox', + * 'message', 'search'). + * @param array $items TODO + * + * @return string The menu. */ - public function addMIMPMenu($menu, $page) + public function getMenu($page, $items = array()) { - $items = array(); - if (!in_array($page, array('mailbox', 'message')) || ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) { $items[] = array(_("Inbox"), IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX')); @@ -41,16 +39,18 @@ class IMP_Mimp $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'])); + $items[] = array($menuitem['text'], $menuitem['url']); } } + + $out = '
    '; + foreach ($items as $val) { + $out .= '
  1. ' . htmlspecialchars($val[0]) . '
  2. '; + } + return $out . '
'; } } diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index 9de9bcda1..489996494 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -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] . ' ' . ($sortpref['dir'] ? '^' : 'v') . ''); + } else { + $t->set($key, '' . $val[0] . ''); } - $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'); diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 27fd70753..ed4dffed1 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -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(); diff --git a/imp/templates/common-header.inc b/imp/templates/common-header.inc index 5f26ca5f0..8205e7af5 100644 --- a/imp/templates/common-header.inc +++ b/imp/templates/common-header.inc @@ -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: } ?> <?php echo htmlspecialchars($page_title) ?> + + + + - + diff --git a/imp/templates/compose/compose-mimp.html b/imp/templates/compose/compose-mimp.html new file mode 100644 index 000000000..80f34ab6e --- /dev/null +++ b/imp/templates/compose/compose-mimp.html @@ -0,0 +1,63 @@ +
+
+
+ + + + +

+ +

+
+ +

+ +

+ +
+
+ +
+
+
+
+
+ +

+ + +

+ Subject: +

+

+ Message: +
+ +

+

+ + + + + + + + + +

+ +
+
Menu
+ + + diff --git a/imp/templates/compose/compose-mimp.inc b/imp/templates/compose/compose-mimp.inc deleted file mode 100644 index 1c93bfb5b..000000000 --- a/imp/templates/compose/compose-mimp.inc +++ /dev/null @@ -1,52 +0,0 @@ -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 index d0eb6b2f8..000000000 --- a/imp/templates/compose/redirect-mimp.inc +++ /dev/null @@ -1,20 +0,0 @@ -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 index 000000000..4a99017d1 --- /dev/null +++ b/imp/templates/folders/folders-mimp.html @@ -0,0 +1,10 @@ +
+
+ +
()
+
+
+
Menu
+ + + diff --git a/imp/templates/folders/folders-mimp.inc b/imp/templates/folders/folders-mimp.inc deleted file mode 100644 index c8809e6be..000000000 --- a/imp/templates/folders/folders-mimp.inc +++ /dev/null @@ -1,37 +0,0 @@ -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 index 000000000..776c4a0c1 --- /dev/null +++ b/imp/templates/mailbox/mailbox-mimp.html @@ -0,0 +1,25 @@ +
+
+ + + + + + + + + + + + + + +
[]
+ +
No messages.
+
+
+
Menu
+ + + diff --git a/imp/templates/mailbox/mailbox-mimp.inc b/imp/templates/mailbox/mailbox-mimp.inc deleted file mode 100644 index de40e688e..000000000 --- a/imp/templates/mailbox/mailbox-mimp.inc +++ /dev/null @@ -1,43 +0,0 @@ - 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 index 000000000..ab5e9e9ca --- /dev/null +++ b/imp/templates/mailbox/search-mimp.html @@ -0,0 +1,17 @@ +
+
+
+ + +

+ Search: +

+

+ +

+
+
+
Menu
+ + + diff --git a/imp/templates/mailbox/search-mimp.inc b/imp/templates/mailbox/search-mimp.inc deleted file mode 100644 index 775c7d591..000000000 --- a/imp/templates/mailbox/search-mimp.inc +++ /dev/null @@ -1,18 +0,0 @@ -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 index 000000000..0975f1fd7 --- /dev/null +++ b/imp/templates/message/download-mimp.html @@ -0,0 +1,10 @@ +

+ Click to verify download of attachment: + + [] +

+

+ Return to message view +

+ + diff --git a/imp/templates/message/message-mimp.html b/imp/templates/message/message-mimp.html new file mode 100644 index 000000000..cb8453c57 --- /dev/null +++ b/imp/templates/message/message-mimp.html @@ -0,0 +1,23 @@ +
+
+

+ +

+ + +
Attachment: []
+
+

+

+ +

+ +

+ View Full Message +

+
+
+
Menu
+ + + -- 2.11.0