Parcourir la source

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 il y a 20 ans
Parent
commit
127e38685a
2 fichiers modifiés avec 18 ajouts et 10 suppressions
  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>';
 }
 
-/* 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
  * everything needed, including HTML Tags, Attachments at the
  * 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
      * primary message. To add more of them, just put them in the
      * 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,
                           $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.
                 '&amp;mailbox=' . $urlmailbox .'&amp;sort=' . $sort .
                 '&amp;startMessage=' . $startMessage . '&amp;show_more=0';
@@ -2066,4 +2074,4 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX') {
 
 }  // end fn SendDownloadHeaders
 
-?>
+?>

+ 7 - 7
src/printer_friendly_bottom.php

@@ -70,7 +70,7 @@ if ($show_html_default == 1) {
 $body = '';
 if ($ent_ar[0] != '') {
   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;" />';
   }
   $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) */
      html_tag( 'table', '', 'center', '', 'cellspacing="0" cellpadding="0" border="0" width="100%"' ) .
      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' )
      ) . "\n" .
      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' )
      ) . "\n" .
      html_tag( 'tr',
-         html_tag( 'td', _("Date").'&nbsp;', 'left' ) .
+         html_tag( 'td', '<b>'._("Date").':</b>&nbsp;', 'left' ) .
          html_tag( 'td', htmlspecialchars($date), 'left' )
      ) . "\n" .
      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' )
     ) . "\n";
     if ( strlen($cc) > 0 ) { /* only show Cc: if it's there... */
          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' )
          );
      }
@@ -194,4 +194,4 @@ function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
 } /* end pf_clean_string() function */
 
 /* --end pf-specific functions */
-?>
+?>