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;
+ }
+
}
$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) {
/* 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'];
$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(
}
}
- 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']) {
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;