protected function _getInlineOutput(array $options)
{
global $prefs, $registry;
$atc_parts = $display_ids = $i = $metadata = $msgtext = $wrap_ids = array();
$text_out = '';
$view = $registry->getView();
$contents_mask = isset($options['mask']) ? $options['mask'] : 0;
$mimeid_filter = isset($options['mimeid']) ? new Horde_Mime_Id($options['mimeid']) : null;
$show_parts = $prefs->getValue('parts_display');
foreach ($this->contents->getMIMEMessage()->partIterator() as $part) {
$mime_id = $part->getMimeId();
$i[] = $mime_id;
if (isset($display_ids[$mime_id]) || isset($atc_parts[$mime_id])) {
continue;
}
if ($mimeid_filter && (strval($mimeid_filter) != $mime_id && !$mimeid_filter->isChild($mime_id))) {
continue;
}
if (!($render_mode = $this->contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE_AUTO))) {
if ($part->isAttachment()) {
if ($show_parts == 'atc') {
$atc_parts[$mime_id] = 1;
}
if ($contents_mask) {
$msgtext[$mime_id] = array('text' => $this->_formatSummary($this->contents->getSummary($mime_id, $contents_mask), true));
}
}
continue;
}
$render_part = $this->contents->renderMIMEPart($mime_id, $render_mode);
if ($show_parts == 'atc' && $part->isAttachment() && (empty($render_part) || !($render_mode & IMP_Contents::RENDER_INLINE))) {
$atc_parts[$mime_id] = 1;
}
if (empty($render_part)) {
if ($contents_mask && $part->isAttachment()) {
$msgtext[$mime_id] = array('text' => $this->_formatSummary($this->contents->getSummary($mime_id, $contents_mask), true));
}
continue;
}
reset($render_part);
while (list($id, $info) = each($render_part)) {
$display_ids[$id] = 1;
if (empty($info)) {
continue;
}
$part_text = $contents_mask && empty($info['nosummary']) ? $this->_formatSummary($this->contents->getSummary($id, $contents_mask), !empty($info['attach'])) : '';
if (empty($info['attach'])) {
if (isset($info['status'])) {
if (!is_array($info['status'])) {
$info['status'] = array($info['status']);
}
$render_issues = array();
foreach ($info['status'] as $val) {
if (in_array($view, $val->views)) {
if ($val instanceof IMP_Mime_Status_RenderIssue) {
$render_issues[] = $val;
} else {
$part_text .= strval($val);
}
}
}
if (!empty($render_issues)) {
$render_issues_ob = new IMP_Mime_Status_RenderIssue_Display();
$render_issues_ob->addIssues($render_issues);
$part_text .= strval($render_issues_ob);
}
}
$part_text .= '<div class="mimePartData">' . $info['data'] . '</div>';
} elseif ($show_parts == 'atc') {
$atc_parts[$id] = 1;
}
$msgtext[$id] = array('text' => $part_text, 'wrap' => empty($info['wrap']) ? null : $info['wrap']);
if (isset($info['metadata'])) {
/* Format: array(identifier, ...[data]...) */
$metadata = array_merge($metadata, $info['metadata']);
}
}
}
if (!empty($msgtext)) {
uksort($msgtext, 'strnatcmp');
}
reset($msgtext);
while (list($id, $part) = each($msgtext)) {
while (!empty($wrap_ids)) {
$id_ob = new Horde_Mime_Id(end($wrap_ids));
if ($id_ob->isChild($id)) {
break;
}
array_pop($wrap_ids);
$text_out .= '</div>';
}
if (!empty($part['wrap'])) {
$text_out .= '<div class="' . $part['wrap'] . '" impcontentsmimeid="' . $id . '">';
$wrap_ids[] = $id;
}
$text_out .= '<div class="mimePartBase"' . (empty($part['wrap']) ? ' impcontentsmimeid="' . $id . '"' : '') . '>' . $part['text'] . '</div>';
}
$text_out .= str_repeat('</div>', count($wrap_ids));
if (!strlen($text_out)) {
$text_out = strval(new IMP_Mime_Status(null, _("There are no parts that can be shown inline.")));
}
$atc_parts = $show_parts == 'all' ? $i : array_keys($atc_parts);
return array('atc_parts' => $atc_parts, 'display_ids' => array_keys($display_ids), 'metadata' => $metadata, 'msgtext' => $text_out, 'one_part' => count($i) === 1);
}