public function getThreadsUi($threads, $col_headers, $bodies = false, $template_file = false)
{
if (!count($threads)) {
return '';
}
/* Render threaded lists with Horde_Tree. */
if (!$template_file && isset($threads[0]['indent'])) {
$tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('threads', 'Html', array('multiline' => $bodies, 'lines' => !$bodies));
$tree->setHeader(array(array('class' => $col_headers['message_thread_class_plain'], 'html' => '<strong>' . $col_headers['message_thread'] . '</strong>'), array('class' => $col_headers['message_author_class_plain'], 'html' => '<strong>' . $col_headers['message_author'] . '</strong>'), array('class' => $col_headers['message_timestamp_class_plain'], 'html' => '<strong>' . $col_headers['message_timestamp'] . '</strong>')));
foreach ($threads as &$thread) {
if ($bodies) {
$text = '<strong>' . $thread['message_subject'] . '</strong><small>[';
if (isset($thread['reply'])) {
$text .= ' ' . $thread['reply'];
}
if (!empty($thread['actions'])) {
$text .= ', ' . implode(', ', $thread['actions']);
}
$text .= ']</small><br />' . str_replace(array("\r", "\n"), '', $thread['body'] . (isset($thread['message_attachment']) ? $thread['message_attachment'] : ''));
} else {
$text = '<strong>' . $thread['link'] . $thread['message_subject'] . '</a></strong> ';
if (isset($thread['actions'])) {
$text .= '<small>[' . implode(', ', $thread['actions']) . ']</small>';
}
}
$tree->addNode(array('id' => $thread['message_id'], 'parent' => $thread['parent'], 'label' => $text, 'params' => array('class' => 'linedRow', 'icon' => false), 'right' => array($thread['message_author'], $thread['message_date'])));
}
return $tree->getTree(true);
}
/* Set up the thread template tags. */
$view = new Agora_View();
$view->threads_list = $threads;
$view->col_headers = $col_headers;
$view->thread_view_bodies = $bodies;
/* Render template. */
if (!$template_file) {
$template_file = 'messages/threads';
}
return $view->render($template_file);
}