瀏覽代碼

Add param 'clean' to formatBody to prevent irrelevant stuff like 'download
this as a file' being output in printer friendly. I guess formatBody is
a bit too much of an all-in-one function and it might be cleaner to split
it up at some time in the future. Also add colons to the printer friendly
mailheaders and make them bold.

Thijs Kinkhorst 20 年之前
父節點
當前提交
127e38685a
共有 2 個文件被更改,包括 18 次插入10 次删除
  1. 11 3
      functions/mime.php
  2. 7 7
      src/printer_friendly_bottom.php

+ 11 - 3
functions/mime.php

@@ -331,12 +331,14 @@ function translateText(&$body, $wrap_at, $charset) {
     $body = '<pre>' . implode("\n", $body_ary) . '</pre>';
     $body = '<pre>' . implode("\n", $body_ary) . '</pre>';
 }
 }
 
 
-/* This returns a parsed string called $body. That string can then
+/**
+ * This returns a parsed string called $body. That string can then
  * be displayed as the actual message in the HTML. It contains
  * be displayed as the actual message in the HTML. It contains
  * everything needed, including HTML Tags, Attachments at the
  * everything needed, including HTML Tags, Attachments at the
  * bottom, etc.
  * bottom, etc.
+ * @param clean Do not output stuff that's irrelevant for the printable version.
  */
  */
-function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX') {
+function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX', $clean=FALSE) {
     /* This if statement checks for the entity to show as the
     /* This if statement checks for the entity to show as the
      * primary message. To add more of them, just put them in the
      * primary message. To add more of them, just put them in the
      * order that is their priority.
      * order that is their priority.
@@ -392,6 +394,12 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
             translateText($body, $wrap_at,
             translateText($body, $wrap_at,
                           $body_message->header->getParameter('charset'));
                           $body_message->header->getParameter('charset'));
         }
         }
+
+        // if this is the clean display (i.e. printer friendly), stop here.
+        if ( $clean ) {
+            return $body;
+        }
+
         $link = 'passed_id=' . $id . '&amp;ent_id='.$ent_num.
         $link = 'passed_id=' . $id . '&amp;ent_id='.$ent_num.
                 '&amp;mailbox=' . $urlmailbox .'&amp;sort=' . $sort .
                 '&amp;mailbox=' . $urlmailbox .'&amp;sort=' . $sort .
                 '&amp;startMessage=' . $startMessage . '&amp;show_more=0';
                 '&amp;startMessage=' . $startMessage . '&amp;show_more=0';
@@ -2066,4 +2074,4 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX') {
 
 
 }  // end fn SendDownloadHeaders
 }  // end fn SendDownloadHeaders
 
 
-?>
+?>

+ 7 - 7
src/printer_friendly_bottom.php

@@ -70,7 +70,7 @@ if ($show_html_default == 1) {
 $body = '';
 $body = '';
 if ($ent_ar[0] != '') {
 if ($ent_ar[0] != '') {
   for ($i = 0; $i < count($ent_ar); $i++) {
   for ($i = 0; $i < count($ent_ar); $i++) {
-     $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
+     $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox, TRUE);
      $body .= '<hr style="height: 1px;" />';
      $body .= '<hr style="height: 1px;" />';
   }
   }
   $hookResults = do_hook('message_body', $body);
   $hookResults = do_hook('message_body', $body);
@@ -116,24 +116,24 @@ echo '<body text="#000000" bgcolor="#FFFFFF" link="#000000" vlink="#000000" alin
      /* headers (we use table because translations are not all the same width) */
      /* headers (we use table because translations are not all the same width) */
      html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
      html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
      html_tag( 'tr',
      html_tag( 'tr',
-         html_tag( 'td', _("From").'&nbsp;', 'left' ,'','valign="top"') .
+         html_tag( 'td', '<b>'._("From").':</b>&nbsp;', 'left' ,'','valign="top"') .
          html_tag( 'td', $from, 'left' )
          html_tag( 'td', $from, 'left' )
      ) . "\n" .
      ) . "\n" .
      html_tag( 'tr',
      html_tag( 'tr',
-         html_tag( 'td', _("Subject").'&nbsp;', 'left','','valign="top"' ) .
+         html_tag( 'td', '<b>'._("Subject").':</b>&nbsp;', 'left','','valign="top"' ) .
          html_tag( 'td', $subject, 'left' )
          html_tag( 'td', $subject, 'left' )
      ) . "\n" .
      ) . "\n" .
      html_tag( 'tr',
      html_tag( 'tr',
-         html_tag( 'td', _("Date").'&nbsp;', 'left' ) .
+         html_tag( 'td', '<b>'._("Date").':</b>&nbsp;', 'left' ) .
          html_tag( 'td', htmlspecialchars($date), 'left' )
          html_tag( 'td', htmlspecialchars($date), 'left' )
      ) . "\n" .
      ) . "\n" .
      html_tag( 'tr',
      html_tag( 'tr',
-         html_tag( 'td', _("To").'&nbsp;', 'left','','valign="top"' ) .
+         html_tag( 'td', '<b>'._("To").':</b>&nbsp;', 'left','','valign="top"' ) .
          html_tag( 'td', $to, 'left' )
          html_tag( 'td', $to, 'left' )
     ) . "\n";
     ) . "\n";
     if ( strlen($cc) > 0 ) { /* only show Cc: if it's there... */
     if ( strlen($cc) > 0 ) { /* only show Cc: if it's there... */
          echo html_tag( 'tr',
          echo html_tag( 'tr',
-             html_tag( 'td', _("Cc").'&nbsp;', 'left','','valign="top"' ) .
+             html_tag( 'td', '<b>'._("Cc").':</b>&nbsp;', 'left','','valign="top"' ) .
              html_tag( 'td', $cc, 'left' )
              html_tag( 'td', $cc, 'left' )
          );
          );
      }
      }
@@ -194,4 +194,4 @@ function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
 } /* end pf_clean_string() function */
 } /* end pf_clean_string() function */
 
 
 /* --end pf-specific functions */
 /* --end pf-specific functions */
-?>
+?>