From f226cba750d5d3330126b17f9b8dc928a97e76fa Mon Sep 17 00:00:00 2001 From: teepe Date: Fri, 16 Nov 2001 14:49:26 +0000 Subject: [PATCH] integrated printer_friendly into the core git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1765 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/load_prefs.php | 10 ++- src/options.php | 4 +- src/options_display.php | 14 +++ src/printer_friendly_bottom.php | 151 ++++++++++++++++++++++++++++++++ src/printer_friendly_main.php | 24 +++++ src/printer_friendly_top.php | 54 ++++++++++++ src/read_body.php | 58 ++++++++++++ 7 files changed, 311 insertions(+), 4 deletions(-) create mode 100644 src/printer_friendly_bottom.php create mode 100644 src/printer_friendly_main.php create mode 100644 src/printer_friendly_top.php diff --git a/src/load_prefs.php b/src/load_prefs.php index 90745ab1..24e18d4e 100644 --- a/src/load_prefs.php +++ b/src/load_prefs.php @@ -188,13 +188,17 @@ $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT); $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN); - global $collapse_folders, $show_html_default, $show_xmailer_default, $attachment_common_show_images; + global $collapse_folders, $show_html_default, $show_xmailer_default, + $attachment_common_show_images, $pf_subtle_link, $pf_cleandisplay; $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON); /* show_html_default is a int value. */ $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_ON)); - $show_xmailer_default = intval(getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF ) ); - $attachment_common_show_images = intval(getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF ) ); + + $show_xmailer_default = getPref($data_dir, $username, 'show_xmailer_default', SMPREF_OFF ); + $attachment_common_show_images = getPref($data_dir, $username, 'attachment_common_show_images', SMPREF_OFF ); + $pf_subtle_link = getPref($data_dir, $username, 'pf_subtle_link', SMPREF_OFF); + $pf_cleandisplay = getPref($data_dir, $username, 'pf_cleandisplay', SMPREF_OFF); global $include_self_reply_all; $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON); diff --git a/src/options.php b/src/options.php index a7b9a08f..447e8aa0 100644 --- a/src/options.php +++ b/src/options.php @@ -81,6 +81,8 @@ setPref($data_dir, $username, 'page_selector_max', $new_page_selector_max); setPref($data_dir, $username, 'show_xmailer_default', $new_show_xmailer_default); setPref($data_dir, $username, 'attachment_common_show_images', $new_attachment_common_show_images); + setPref($data_dir, $username, 'pf_subtle_link', $new_pf_subtle_link); + setPref($data_dir, $username, 'pf_cleandisplay', $new_pf_cleandisplay); $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF); if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { @@ -91,7 +93,7 @@ } } else { setPref($data_dir, $username, 'javascript_on', $new_javascript_setting); - } + } do_hook('options_display_save'); diff --git a/src/options_display.php b/src/options_display.php index edaaf3c4..22254bbf 100644 --- a/src/options_display.php +++ b/src/options_display.php @@ -195,6 +195,20 @@ 'refresh' => SMOPT_REFRESH_NONE ); + $optvals[SMOPT_GRP_MESSAGE][] = array( + 'name' => 'pf_subtle_link', + 'caption' => _("Printer Friendly: Subtle Link"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[SMOPT_GRP_MESSAGE][] = array( + 'name' => 'pf_cleandisplay', + 'caption' => _("Printer Friendly: Clean Display"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + /* Build and output the option groups. */ $option_groups = createOptionGroups($optgrps, $optvals); printOptionGroups($option_groups); diff --git a/src/printer_friendly_bottom.php b/src/printer_friendly_bottom.php new file mode 100644 index 00000000..1977d4fe --- /dev/null +++ b/src/printer_friendly_bottom.php @@ -0,0 +1,151 @@ +header->from); + $date = getLongDateString($message->header->date); + + // we can clean these up if the list is too long... + $cc = decodeHeader(getLineOfAddrs($message->header->cc)); + $to = decodeHeader(getLineOfAddrs($message->header->to)); + + // and Body and Subject could easily stream off the page... + $body = mime_fetch_body($imap_stream, $passed_id, $passed_ent_id); + $body = str_replace("\n", "\n", trim(decodeBody($body, $message->header->encoding))); + $subject = trim(decodeHeader($message->header->subject)); + + // now, if they choose to, we clean up the display a bit... + if ( empty($pf_cleandisplay) || $pf_cleandisplay != 'no' ) + { + + $num_leading_spaces = 9; // nine leading spaces for indentation + + // sometimes I see ',,' instead of ',' seperating addresses *shrug* + $cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces); + $to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces); + + // the body should have no leading zeros + $body = pf_clean_string($body, 0); + + // clean up everything else... + $subject = pf_clean_string($subject, $num_leading_spaces); + $from = pf_clean_string($from, $num_leading_spaces); + $date = pf_clean_string($date, $num_leading_spaces); + + } // end cleanup + +// --end display setup-- + + +// --start browser output-- + +?> + + + + + <?php echo _("Printable View"); ?> + + +', $theme_css); + echo "\n"; + } + + printf('', + $color[8], $color[4], $color[7], $color[7], $color[7]); + + echo "\n
";
+
+     // headers
+    echo "   " . _("From") . ': ' . htmlentities($from) . "\n";
+    echo "     " . _("To") . ': ' . htmlentities($to) . "\n";
+    if ( strlen($cc) > 0 ) // only show CC: if it's there...
+        echo "     " . _("CC") . ': ' . htmlentities($cc) . "\n";
+    echo "   " . _("Date") . ': ' . htmlentities($date) . "\n";
+    echo _("Subject") . ': ' . htmlentities($subject) . "\n\n";
+
+     // body
+    echo "
\n"; + echo htmlentities($body); + +// --end browser output-- + + +?>
+ + + + $wrap_at ) + { + $this_line = substr($unclean_string, 0, $wrap_at); + if ( strrpos( $this_line, "\n" ) ) // this should NEVER happen with anything but the $body + { + $clean_string .= substr( $this_line, 0, strrpos( $this_line, "\n" )); + $clean_string .= $leading_spaces; + $unclean_string = substr($unclean_string, strrpos( $this_line, "\n" )); + } + else + { + $clean_string .= substr( $this_line, 0, strrpos( $this_line, ' ' )); + $clean_string .= "\n" . $leading_spaces; + $unclean_string = substr($unclean_string, (1+strrpos( $this_line, ' ' ))); + } + } + $clean_string .= $unclean_string; + + return $clean_string; +} // end pf_clean_string() function + +// --end pf-specific functions + +?> diff --git a/src/printer_friendly_main.php b/src/printer_friendly_main.php new file mode 100644 index 00000000..6bade61b --- /dev/null +++ b/src/printer_friendly_main.php @@ -0,0 +1,24 @@ + + + + Print Email + + + + + + diff --git a/src/printer_friendly_top.php b/src/printer_friendly_top.php new file mode 100644 index 00000000..3e7376d2 --- /dev/null +++ b/src/printer_friendly_top.php @@ -0,0 +1,54 @@ + + + + + + +', $theme_css); + echo "\n"; + } + + + printf('', + $color[8], $color[3], $color[7], $color[7], $color[7]); +?> +
+ +
+ + +
+
+
+ + diff --git a/src/read_body.php b/src/read_body.php index a0e89636..503eca2b 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -134,6 +134,62 @@ return -1; } + + // displays a link to a page where the message is displayed + // more "printer friendly" + + function printer_friendly_link($subtle) { + global $passed_id, $mailbox, $ent_num, $color; + global $pf_subtle_link; + + if ($pf_subtle_link != $subtle) return; + + if (strlen(trim($mailbox)) < 1) + $mailbox = 'INBOX'; + + $params = '?passed_ent_id=' . $ent_num . '&mailbox=' . urlencode($mailbox) . + '&passed_id=' . $passed_id; + $text = _("View printable version"); + + if (!$subtle) { + // the link is large, on the bottom of the header panel + echo ' ' . "\n" . + ' ' . "\n" . + '  ' . "\n" . + ' '."\n"; + } else { + // the link is subtle, below "view full header" + echo '
' . "\n"; + } + + // javascript + echo ' ' . "\n" . + // pure html + ' ' . "\n"; + + if (!$subtle) { + // the link is large, on the bottom of the header panel + echo ' ' . "\n" . + ' ' . "\n"; + } + } + + // main of read_boby.php + if (isset($msgs)) { $currentArrayIndex = $passed_id; /* @@ -428,6 +484,7 @@ } else { echo "" . _("View full header") . "\n"; } + printer_friendly_link(1); // 1 = subtle link do_hook("read_body_header_right"); echo '' . "\n" . ' ' ."\n" . @@ -503,6 +560,7 @@ } } + printer_friendly_link(0); // 0 = unsubtle link do_hook("read_body_header"); echo '' . ' ' . -- 2.25.1