* @param string $ent_num (since 1.3.0) message part id
* @param integer $id (since 1.3.0) message id
* @param string $mailbox (since 1.3.0) imap folder name
- * @param boolean $clean (since 1.5.1) Do not output stuff that's irrelevant for the printable version.
* @return string html formated message text
*/
-function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX', $clean=FALSE) {
+function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX') {
/* 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.
$body = trim($body);
translateText($body, $wrap_at,
$body_message->header->getParameter('charset'));
- } elseif ($use_iframe && ! $clean) {
- // $clean is used to remove iframe in printable view.
-
+ } elseif ($use_iframe) {
/**
* If we don't add html message between iframe tags,
* we must detect unsafe images and modify $has_unsafe_images.
$body_message->header->getParameter('charset'));
}
- // if this is the clean display (i.e. printer friendly), stop here.
- if ( $clean ) {
- return $body;
- }
-
/*
* Previously the links for downloading and unsafe images were printed
* under the mail. By putting the links in a global variable we can
}
/**
- * Generate attachments array for passing to templates. Separated from
- * formatAttachments() below so that the same array can be given to the
- * print-friendly version.
+ * Generate attachments array for passing to templates.
*
* @since 1.5.2
* @param object $message SquirrelMail message object
the message.
<br /><br />
- <b>Enable Subtle Printer Friendly Link</b><br />
- This determines the way the Printable Version-link will be displayed.
- <br /><br />
-
- <b>Enable Printer Friendly Clean Display</b><br />
- This will clean out the message so the print looks nicer.
- <br /><br />
-
<b>Other Options</b><br />
Depending on the configuration of your SquirrelMail installation, some more
options might be displayed here. They hopefully should be self-explanatory.
+++ /dev/null
-<?php
-
-/**
- * printer_friendly_bottom.php
- *
- * with javascript on, it is the bottom frame of printer_friendly_main.php
- * else, it is alone in a new window
- *
- * - this is the page that does all the work, really.
- *
- * @copyright © 1999-2007 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- */
-
-/** This is the printer_friendly_bottom page */
-define('PAGE_NAME', 'printer_friendly_bottom');
-
-/**
- * Include the SquirrelMail initialization file.
- */
-require('../include/init.php');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'functions/imap_general.php');
-require_once(SM_PATH . 'functions/imap_messages.php');
-require_once(SM_PATH . 'functions/date.php');
-require_once(SM_PATH . 'functions/mime.php');
-require_once(SM_PATH . 'functions/url_parser.php');
-
-/* get some of these globals */
-sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
-sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
-sqgetGlobalVar('messages', $messages, SQ_SESSION);
-
-if (! sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
- $passed_ent_id = '';
-}
-sqgetGlobalVar('show_html_default', $show_html_default, SQ_FORM);
-/* end globals */
-
-$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
-$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
-if (isset($messages[$mbx_response['UIDVALIDITY']][$passed_id])) {
- $message = $messages[$mbx_response['UIDVALIDITY']][$passed_id];
-} else {
- $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
-}
-if ($passed_ent_id) {
- $message = $message->getEntity($passed_ent_id);
-}
-
-/* --start display setup-- */
-
-$rfc822_header = $message->rfc822_header;
-/* From and Date are usually fine as they are... */
-$from = $rfc822_header->getAddr_s('from');
-$date = getLongDateString($rfc822_header->date, $rfc822_header->date_unparsed);
-$subject = trim($rfc822_header->subject);
-
-/* we can clean these up if the list is too long... */
-$cc = $rfc822_header->getAddr_s('cc');
-$to = $rfc822_header->getAddr_s('to');
-
-if ($show_html_default == 1) {
- $ent_ar = $message->findDisplayEntity(array());
-} else {
- $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
-}
-$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, TRUE);
- if ($i < count($ent_ar)-1) {
- $body .= '<hr />';
- }
- }
- /* Note that $body is passed to this hook (and modified) by reference as of 1.5.2 */
- do_hook('message_body', $body);
-} else {
- $body = _("Message not printable");
-}
-
-/* now we clean up the display a bit... */
-
-$num_leading_spaces = 9; // nine leading spaces for indentation
-
-// sometimes I see ',,' instead of ',' separating addresses *shrug*
-$cc = pf_clean_string(str_replace(',,', ',', $cc), $num_leading_spaces);
-$to = pf_clean_string(str_replace(',,', ',', $to), $num_leading_spaces);
-
-// 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
-
-$to = decodeHeader($to);
-$cc = decodeHeader($cc);
-$from = decodeHeader($from);
-$subject = decodeHeader($subject);
-
-// --end display setup--
-
-
-/* --start browser output-- */
-displayHtmlHeader($subject);
-
-$aHeaders = array();
-$aHeaders[ _("From") ] = $from;
-$aHeaders[ _("Subject") ] = $subject;
-$aHeaders[ _("Date") ] = htmlspecialchars($date);
-$aHeaders[ _("To") ] = $to;
-$aHeaders[ _("Cc") ] = $cc;
-
-$attachments_ar = buildAttachmentArray($message, $ent_ar, $mailbox, $passed_id);
-
-$oTemplate->assign('headers', $aHeaders);
-$oTemplate->assign('message_body', $body);
-$oTemplate->assign('attachments', $attachments_ar);
-
-$oTemplate->display('printer_friendly_bottom.tpl');
-$oTemplate->display('footer.tpl');
-
-/* --end browser output-- */
-
-
-/* --start pf-specific functions-- */
-
-/**
- * Function should clean layout of printed messages when user
- * enables "Printer Friendly Clean Display" option.
- * For example: $string = pf_clean_string($string, 9);
- *
- * @param string unclean_string
- * @param integer num_leading_spaces
- * @return string
- * @access private
- */
-function pf_clean_string ( $unclean_string, $num_leading_spaces ) {
- global $data_dir, $username;
- $unclean_string = str_replace(' ',' ',$unclean_string);
- $wrap_at = getPref($data_dir, $username, 'wrap_at', 86);
- $wrap_at = $wrap_at - $num_leading_spaces; /* header stuff */
-
- $leading_spaces = '';
- while ( strlen($leading_spaces) < $num_leading_spaces )
- $leading_spaces .= ' ';
-
- $clean_string = '';
- while ( strlen($unclean_string) > $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
- {
- $i = strrpos( $this_line, ' ');
- $clean_string .= substr( $this_line, 0, $i);
- $clean_string .= "\n" . $leading_spaces;
- $unclean_string = substr($unclean_string, 1+$i);
- }
- }
- $clean_string .= $unclean_string;
-
- return $clean_string;
-} /* end pf_clean_string() function */
+++ /dev/null
-<?php
-
-/**
- * printer_friendly frameset
- *
- * @copyright © 1999-2007 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- */
-
-/** This is the printer_friendly_main page */
-define('PAGE_NAME', 'printer_friendly_main');
-
-/**
- * Include the SquirrelMail initialization file.
- */
-include('../include/init.php');
-
-/* get those globals into gear */
-if ( ! sqgetGlobalVar('passed_ent_id',$passed_ent_id,SQ_GET))
- $passed_ent_id = 0;
-if ( ! sqgetGlobalVar('mailbox',$mailbox,SQ_GET) ||
- ! sqgetGlobalVar('passed_id',$passed_id,SQ_GET)) {
- error_box(_("Invalid URL"));
-} else {
- $passed_id= (int) $passed_id;
- $view_unsafe_images = (bool) $_GET['view_unsafe_images'];
- sqgetGlobalVar('show_html_default', $show_html_default, SQ_FORM);
-/* end globals */
- displayHtmlHeader( _("Printer Friendly"), '', false, true );
-
- $oErrorHandler->setDelayedErrors(true);
-
- $url = 'printer_friendly_bottom.php?passed_ent_id=' .
- urlencode($passed_ent_id) . '&mailbox=' . urlencode($mailbox) .
- '&passed_id=' . $passed_id .
- '&view_unsafe_images='.$view_unsafe_images .
- '&show_html_default='.$show_html_default;
-
- $oTemplate->assign('printer_friendly_url', $url);
-
- $oTemplate->display('printer_friendly_main.tpl');
-
-}
+++ /dev/null
-<?php
-
-/**
- * printer_friendly top frame
- *
- * top frame of printer_friendly_main.php
- * displays some javascript buttons for printing & closing
- *
- * @copyright © 1999-2007 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- */
-
-/** This is the printer_friendly_top page */
-define('PAGE_NAME', 'printer_friendly_top');
-
-/**
- * Include the SquirrelMail initialization file.
- */
-include('../include/init.php');
-
-displayHtmlHeader( _("Printer Friendly"));
-$oErrorHandler->setDelayedErrors(true);
-
-$oTemplate->display('printer_friendly_top.tpl');
-
-$oTemplate->display('footer.tpl');
padding:10px;
}
-div.printerFriendlyTop table {
- width:100%;
-}
-
-div.printerFriendlyTop td {
- text-align: right;
-}
-
-div.printerFriendly table.attach {
- width: 100%;
- margin-top:5px;
- margin-bottom:5px;
-}
-
-div.printerFriendly td.attachField {
- width: 30%;
- font-weight: bold;
- text-align: right;
-}
-
-div.printerFriendly td.attachFieldValue {
- text-align: left;
- empty-cells: show;
-}
-
-div.printerFriendly td.attachName {
- font-weight: bold;
-}
-
div.viewHeader table.table1 {
width: 100%;
}
+++ /dev/null
-<?php
-/**
- * printer_friendly_bottom.tpl
- *
- * Display the printer friendly version of an email. This is called "_bottom"
- * because when javaascript is enabled, the printer friendly view is a window
- * with two frames.
- *
- * The following variables are available in this template:
- * $headers - array containing the headers to be displayed for this email.
- * Each element in the array represents a separate header.
- * The index of each element is the field name; the value is
- * the value of that field.
- * $message_body - formatted, scrubbed body of the email.
- * $attachments - array containing info for all message attachments. Each
- * element in the array represents a separate attachment and
- * contains the following elements:
- * $el['Name'] - The name of the attachment
- * $el['Description'] - Description of the attachment
- * $el['DefaultHREF'] - URL to the action that should occur when the name is clicked
- * $el['DownloadHREF'] - URL to download the attachment
- * $el['ViewHREF'] - URL to view the attachment. Empty if not available.
- * $el['Size'] - Size of attachment in bytes.
- * $el['ContentType'] - Content-Type of the attachment
- * $el['OtherLinks'] - array containing links to any other actions
- * available for this attachment that might be
- * provided by plugins, for example. Each element represents
- * a different action and contains the following elements:
- * $link['HREF'] - URL to access the functionality
- * $link['Text'] - Text representing the functionality.
- *
- *
- * @copyright © 1999-2006 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- * @subpackage templates
- */
-
-
-/** extract template variables **/
-extract($t);
-
-/** Begin template **/
-?>
-<div class="printerFriendly">
-<table cellspacing="0" class="table_blank">
- <?php
- foreach ($headers as $field=>$value) {
- # If the value is empty, skip the entry.
- if (empty($value))
- continue;
- ?>
- <tr>
- <td class="fieldName">
- <?php echo $field; ?>:
- </td>
- <td class="fieldValue">
- <?php echo $value; ?>
- </td>
- </tr>
- <?php
- }
- ?>
-</table>
-<hr />
-<?php echo $message_body; ?>
-<?php
-if (count($attachments) > 0) {
- ?>
-<hr />
-<b><?php echo _("Attachments:"); ?></b>
- <?php
- foreach ($attachments as $attachment) {
- ?>
-<table cellspacing="0" border="1" class="attach">
- <tr>
- <td colspan="2" class="attachName">
- <?php echo $attachment['Name']; ?>
- </td>
- </tr>
- <tr>
- <td class="attachField">
- <?php echo _("Size"); ?>:
- </td>
- <td class="attachFieldValue">
- <?php echo humanReadableSize($attachment['Size']); ?>
- </td>
- </tr>
- <tr>
- <td class="attachField">
- <?php echo _("Type:"); ?>
- </td>
- <td class="attachFieldValue">
- <?php echo $attachment['ContentType']; ?>
- </td>
- </tr>
- <tr>
- <td class="attachField">
- <?php echo _("Info:"); ?>
- </td>
- <td class="attachFieldValue">
- <?php echo $attachment['Description']; ?>
- </td>
- </tr>
-</table>
- <?php
- }
-}
-?>
-</div>
+++ /dev/null
-<?php
-/**
- * printer_friendly_main.tpl
- *
- * Display the entire printer friendly window. By default, this uses frames when
- * javascript is available.
- *
- * The following variables are available in this template:
- * $printer_friendly_url - URL to display the printer-frinedly version of a message
- *
- * @copyright © 1999-2006 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- * @subpackage templates
- */
-
-/** add required includes **/
-
-/** extract template variables **/
-extract($t);
-
-/** Begin template **/
-?>
-<frameset rows="60, *">
- <frame src="printer_friendly_top.php" name="top_frame" scrolling="no" noresize="noresize" frameborder="0" />
- <frame src="<?php echo $printer_friendly_url; ?>" name="bottom_frame" frameborder="0" />
-</frameset>
-</html>
+++ /dev/null
-<?php
-/**
- * printer_friendly_top.tpl
- *
- * Top frame of the printer-friendly window. Bt default, this is only displayed
- * when javascript is enabled.
- *
- * There are no additional variables given to this template.
- *
- * @copyright © 1999-2006 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id$
- * @package squirrelmail
- * @subpackage templates
- */
-
-/** add required includes **/
-
-/** extract template variables **/
-extract($t);
-
-/** Begin template **/
-?>
-<script type="text/javascript">
-<!--
-function printPopup() {
- parent.frames[1].focus();
- parent.frames[1].print();
-}
--->
-</script>
-<div class="printerFriendlyTop">
-<table class="table_blank" cellspacing="0">
- <tr>
- <td>
- <input type="button" value="<?php echo _("Print"); ?>" onclick="printPopup()" />
- <input type="button" value="<?php echo _("Close"); ?>" onclick="window.parent.close()" />
- </td>
- </tr>
-</table>
-</div>
\ No newline at end of file