X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmime.php;h=35ce6e7c3e4771351162dc0c61b2b3c7c80386d4;hp=6210c57fc8d1db3cc97f5bef94b31d0c327222f3;hb=9b94c54da2dbd7ff84e721712dfc0c75676377c8;hpb=14c85e395cfeabd2e09e30c90f9031df122081c0 diff --git a/functions/mime.php b/functions/mime.php index 6210c57f..35ce6e7c 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -313,15 +313,9 @@ function translateText(&$body, $wrap_at, $charset) { } if ($quotes % 2) { - if (!isset($color[13])) { - $color[13] = '#800000'; - } - $line = '' . $line . ''; + $line = '' . $line . ''; } elseif ($quotes) { - if (!isset($color[14])) { - $color[14] = '#FF0000'; - } - $line = '' . $line . ''; + $line = '' . $line . ''; } $body_ary[$i] = $line; @@ -420,33 +414,11 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma . '&ent_id=' . $ent_num . '&view_unsafe_images=' . (int) $view_unsafe_images; - // adding warning message - $body = html_tag('div',_("Viewing HTML formatted email"),'center'); - - /** - * height can't be set to 100%, because it does not work as expected when - * iframe is inside the table. Browsers do not create full height objects - * even when iframe is not nested. Maybe there is some way to get full size - * with CSS. Tested in firefox 1.02 and opera 7.53 - * - * width="100%" does not work as expected, when table width is not set (automatic) - * - * tokul: I think \n"; + global $oTemplate; + $oTemplate->assign('iframe_url', $iframeurl); + $oTemplate->assign('html_body', $html_body); + + $body = $oTemplate->fetch('read_html_iframe.tpl'); } else { // old way of html rendering $body = magicHTML($body, $id, $message, $mailbox); @@ -497,40 +469,34 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma } /** - * Displays attachment links and information - * - * Since 1.3.0 function is not included in formatBody() call. - * - * Since 1.0.2 uses attachment $type0/$type1 hook. - * Since 1.2.5 uses attachment $type0/* hook. - * Since 1.5.0 uses attachments_bottom hook. - * + * Generate attachments array for passing to templates. Separated from + * formatAttachments() below so that the same array can be given to the + * print-friendly version. + * + * @since 1.5.2 * @param object $message SquirrelMail message object * @param array $exclude_id message parts that are not attachments. * @param string $mailbox mailbox name * @param integer $id message id - * @return string html formated attachment information. */ -function formatAttachments($message, $exclude_id, $mailbox, $id) { +function buildAttachmentArray($message, $exclude_id, $mailbox, $id) { global $where, $what, $startMessage, $color, $passed_ent_id, $base_uri; $att_ar = $message->getAttachments($exclude_id); - - if (!count($att_ar)) return ''; - - $attachments = ''; - $urlMailbox = urlencode($mailbox); + $attachments = array(); foreach ($att_ar as $att) { $ent = $att->entity_id; $header = $att->header; $type0 = strtolower($header->type0); $type1 = strtolower($header->type1); $name = ''; + $links = array(); $links['download link']['text'] = _("Download"); $links['download link']['href'] = $base_uri . "src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent"; + if ($type0 =='message' && $type1 == 'rfc822') { $default_page = $base_uri . 'src/read_body.php'; $rfc822_header = $att->rfc822_header; @@ -551,7 +517,7 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { } else { $from_name = _("Unknown sender"); } - $description = $from_name; + $description = _("From").': '.$from_name; } else { $default_page = $base_uri . 'src/download.php'; $filename = $att->getFilename(); @@ -577,50 +543,84 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { /* This executes the attachment hook with a specific MIME-type. * If that doesn't have results, it tries if there's a rule - * for a more generic type. + * for a more generic type. Finally, a hook for ALL attachment + * types is run as well. */ $hookresults = do_hook("attachment $type0/$type1", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); +// FIXME: How does this code ever get executed? $hookresults[1] is $links +// from above, and should always be returned by do_hook(). I will +// test this and fix if needed (but it has been working, right???) +// and get rid of these comments (Paul) +// UPDATE: Preliminary testing shows that in fact I am correct that the +// following never gets executed (unless a strange plugin actually +// unsets the contents of the links)... how did this ever work??? +// Can someonen please show a plugin that worked here? if(count($hookresults[1]) <= 1) { $hookresults = do_hook("attachment $type0/*", $links, $startMessage, $id, $urlMailbox, $ent, $defaultlink, $display_filename, $where, $what); } + $hookresults = do_hook("attachment */*", $hookresults[1], + $startMessage, $id, $urlMailbox, $ent, $hookresults[6], + $display_filename, $where, $what); $links = $hookresults[1]; $defaultlink = $hookresults[6]; - $attachments .= '' . - ''.decodeHeader($display_filename).' ' . - '' . show_readable_size($header->size) . - '  ' . - '[ '.htmlspecialchars($type0).'/'.htmlspecialchars($type1).' ] ' . - ''; - $attachments .= '' . $description . ''; - $attachments .= ' '; - - $skipspaces = 1; + $this_attachment = array(); + $this_attachment['Name'] = decodeHeader($display_filename); + $this_attachment['Description'] = $description; + $this_attachment['DefaultHREF'] = $defaultlink; + $this_attachment['DownloadHREF'] = $links['download link']['href']; + $this_attachment['ViewHREF'] = isset($links['attachment_common']) ? $links['attachment_common']['href'] : ''; + $this_attachment['Size'] = $header->size; + $this_attachment['ContentType'] = htmlspecialchars($type0 .'/'. $type1); + $this_attachment['OtherLinks'] = array(); foreach ($links as $val) { - if ($skipspaces) { - $skipspaces = 0; - } else { - $attachments .= '  |  '; - } - $attachments .= '' - . (isset($val['text']) && !empty($val['text']) ? $val['text'] : '') - . (isset($val['extra']) && !empty($val['extra']) ? $val['extra'] : '') - . ''; + if ($val['text']==_("Download") || $val['text'] == _("View")) + continue; + if (empty($val['text']) && empty($val['extra'])) + continue; + + $temp = array(); + $temp['HREF'] = $val['href']; + $temp['Text'] = (empty($val['text']) ? '' : $val['text']) . (empty($val['extra']) ? '' : $val['extra']); + $this_attachment['OtherLinks'][] = $temp; } + $attachments[] = $this_attachment; + unset($links); - $attachments .= "\n"; } - $attachmentadd = do_hook_function('attachments_bottom',$attachments); - if ($attachmentadd != '') - $attachments = $attachmentadd; + return $attachments; } +/** + * Displays attachment links and information + * + * Since 1.3.0 function is not included in formatBody() call. + * + * Since 1.0.2 uses attachment $type0/$type1 hook. + * Since 1.2.5 uses attachment $type0/* hook. + * Since 1.5.0 uses attachments_bottom hook. + * Since 1.5.2 uses templates and does *not* return a value. + * + * @param object $message SquirrelMail message object + * @param array $exclude_id message parts that are not attachments. + * @param string $mailbox mailbox name + * @param integer $id message id + */ +function formatAttachments($message, $exclude_id, $mailbox, $id) { + global $oTemplate; + + $attach = buildAttachmentArray($message, $exclude_id, $mailbox, $id); + + $oTemplate->assign('attachments', $attach); + $oTemplate->display('read_attachments.tpl'); +} + function sqimap_base64_decode(&$string) { // Base64 encoded data goes in pairs of 4 bytes. To achieve on the @@ -2102,6 +2102,8 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links $has_unsafe_images; /** * Don't display attached images in HTML mode. + * + * SB: why? */ $attachment_common_show_images = false; $tag_list = Array(