From: Michael M Slusarz Date: Fri, 9 Oct 2009 22:12:18 +0000 (-0600) Subject: Improved threading display in MIMP X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8c8e9f4a6c40dd1f3b3060feabf55c3cca0780d6;p=horde.git Improved threading display in MIMP --- diff --git a/imp/lib/Imap/Thread.php b/imp/lib/Imap/Thread.php index b783814ea..84d48df02 100644 --- a/imp/lib/Imap/Thread.php +++ b/imp/lib/Imap/Thread.php @@ -132,4 +132,56 @@ class IMP_Imap_Thread return $tree; } + /** + * Generate the thread representation text for the given index list. + * + * @param array $indices The list of indices to create a tree for. + * @param boolean $sortdir True for newest first, false for oldest first. + * + * @return array An array with the index as the key and the thread image + * representation as the value. + */ + public function getThreadTextTree($indices, $sortdir) + { + $tree = array(); + + foreach ($this->getThreadTreeOb($indices, $sortdir) as $k => $v) { + $tmp = ''; + + if (!empty($v)) { + foreach (str_split($v) as $c) { + switch (intval($c)) { + case 0: + $tmp .= ' '; + break; + + case '1': + $tmp .= '| '; + break; + + case '2': + $tmp .= '|-'; + break; + + case '3': + $tmp .= '/-'; + break; + + case '4': + $tmp .= '\-'; + break; + + case '5': + // TODO + break; + } + } + } + + $tree[$k] = $tmp; + } + + return $tree; + } + } diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index c125c2ae4..068323ce5 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -80,6 +80,9 @@ $mailbox_url = IMP::generateIMPUrl('mailbox-mimp.php', $imp_mbox['mailbox']); $imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox']); $pageOb = $imp_mailbox->buildMailboxPage(Horde_Util::getFormData('p'), Horde_Util::getFormData('s')); +/* Need Horde_Mobile init here for autoloading purposes. */ +$mimp_render = new Horde_Mobile(); + /* Generate page links. */ $pages_first = $pages_prev = $pages_last = $pages_next = null; if ($pageOb['page'] != 1) { @@ -93,7 +96,6 @@ if ($pageOb['page'] != $pageOb['pagecount']) { /* Generate mailbox summary string. */ $title = IMP::getLabel($imp_mbox['mailbox']); -$mimp_render = new Horde_Mobile(); $mimp_render->set('title', $title); if ($pageOb['msgcount']) { $msgcount = $pageOb['msgcount']; @@ -111,11 +113,14 @@ $imp_ui = new IMP_UI_Mailbox($imp_mbox['mailbox']); $mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('headers' => array('x-priority'))); /* Get thread information. */ -$threadob = ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) - ? $imp_mailbox->getThreadOb() - : null; +if ($sortpref['by'] == Horde_Imap_Client::SORT_THREAD) { + $imp_thread = new IMP_Imap_Thread($imp_mailbox->getThreadOb()); + $threadtree = $imp_thread->getThreadTextTree(reset($mbox_info['uids']), $sortpref['dir']); +} else { + $imp_thread = null; + $threadtree = array(); +} -reset($mbox_info); while (list(,$ob) = each($mbox_info['overview'])) { /* Initialize the header fields. */ $msg = array( @@ -151,8 +156,8 @@ while (list(,$ob) = each($mbox_info['overview'])) { } } - if ($threadob && $threadob->getThreadIndent($ob['uid'])) { - $msg['subject'] = '>> ' . ltrim($msg['subject']); + if (!empty($threadtree[$ob['uid']])) { + $msg['subject'] = $threadtree[$ob['uid']] . trim($msg['subject']); } if (Horde_String::length($msg['subject']) > $conf['mimp']['mailbox']['max_subj_chars']) { @@ -194,7 +199,7 @@ foreach ($sort_list as $key => $val) { if (($key == Horde_Imap_Client::SORT_SUBJECT) && IMP::threadSortAvailable($mailbox) && !$search_mbox) { - if (is_null($threadob)) { + if (is_null($imp_thread)) { $items[Horde_Util::addParameter($mailbox, array('a' => 'c', 'sb' => Horde_Imap_Client::SORT_THREAD, 'sd' => $sortdir))] = _("Sort by Thread"); } else { $sortkey = Horde_Imap_Client::SORT_THREAD; diff --git a/imp/templates/mailbox/mailbox-mimp.inc b/imp/templates/mailbox/mailbox-mimp.inc index b668cba56..af7af16a8 100644 --- a/imp/templates/mailbox/mailbox-mimp.inc +++ b/imp/templates/mailbox/mailbox-mimp.inc @@ -19,7 +19,8 @@ $imp_notify->setMobileObject($c); $notification->notify(array('listeners' => 'status')); if (!empty($pageOb['end'])) { - $t = &$c->add(new Horde_Mobile_table()); + $elts = null; + $t = &$c->add(new Horde_Mobile_table($elts)); $t->set('border', 0); $t->set('padding', 1); $t->set('spacing', 1);