Re: Printer friendly pages
Thierry Godefroy <[email protected]>
| Newsgroups | gmane.mail.squirrelmail.devel |
|---|---|
| Message-ID | <[email protected]> |
ARRRGHHHH ! Please, pretty please, noooooo !... <-- * begs on his knees * I just downloaded the latest (2008/05/13) SVN and tested it, and it's horrible as far as I am concerned. --- On Sat, 5/10/08, Fredrik Jervfors <[email protected]> wrote: > >> What we could do already is to remove the printer friendly files from > >> "/src/" and use "/src/read_body.php" with another CSS to provide > >> the clean look needed for printing. Unfortunately I don't have time > >> to do this myself. Volunteers, please step up! > > > > The pure-css print function is finished here and it was quite easy. > > Of course it has a *but*, that's why I didn't commit it. It works, > > but: only for JavaScript-enabled browsers. > > > > Basically what I've done is replaced the "View Printable Version" > > with a "Print" link that pops up your browser print window. > > This is nothing more than the two lines of JS that currently power > > the Print button in the printer friendly popup. It works because that > > JS puts the focus on the right frame and then calls the print command > > on it. I tested it under both Linux and Windoze, with Firefox 2, Opera 9 and IE7: it plain does not work with Javascript enabled: it opens an empty tab, and when opening the error console, it says that it did not find PrintThis(): I did not investigate, but I think the problem is that default.css is not loaded into the new tab/window when the javascript:printThis() link is clicked. In any case, it doesn't work as it is in the SVN right now. I also tried with Javascript off, and then the page displayed properly, with the text asking to use the Print option of the browser. But now my question is: how a plugin is supposed to change the layout of the message before it is printed. I.e. what if you don't want the printed message to look exactly in the same way it is displayed (what if you want less header fields, for example ?...) ? I _NEED_ this ability to change the message format before printing it for my Melinda plugin (because I don't want all the header fields printed, or not in the same way: there are loads of such header fields in a Melinda (pseudo-formal) mail, and you don't want them to take a full page once printed !). I vote strongly against this change, and kindly request to have it reverted. The attached patch allows to do just that... Many thanks in advance and best regards, Thierry. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ----- squirrelmail-devel mailing list Posting guidelines: http://squirrelmail.org/postingguidelines List address: [email protected] List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
squirrelmail-20080513-SVN_devel-ReinstatePrinterFriendly.patch
(text/x-patch, 28.4 KB)
diff -urN squirrelmail/css/print.css squirrelmail-patched/css/print.css
--- squirrelmail/css/print.css 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/css/print.css 1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-/* printer friendly style, currently only targeted at read_body */
-
-/* Drop any irrelevant stuff that's normally on the read_body page */
-#page_header, .readMenuBar, .spacer, form, #printMessageBox,
- #listcommands, .field_Options, .attachActions { display: none; }
-
-/* Display attachment list a bit better */
-.header5 { font-size: larger; }
-.readAttachments td, .fieldName { padding-right: 1em; }
-
diff -urN squirrelmail/functions/mime.php squirrelmail-patched/functions/mime.php
--- squirrelmail/functions/mime.php 2008-05-10 14:27:45.000000000 +0200
+++ squirrelmail-patched/functions/mime.php 2008-05-13 10:59:22.000000000 +0200
@@ -342,9 +342,10 @@
* @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') {
+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.
@@ -400,7 +401,9 @@
$body = trim($body);
translateText($body, $wrap_at,
$body_message->header->getParameter('charset'));
- } elseif ($use_iframe) {
+ } elseif ($use_iframe && ! $clean) {
+ // $clean is used to remove iframe in printable view.
+
/**
* If we don't add html message between iframe tags,
* we must detect unsafe images and modify $has_unsafe_images.
@@ -440,6 +443,11 @@
$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
@@ -495,7 +503,9 @@
}
/**
- * Generate attachments array for passing to templates.
+ * 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
diff -urN squirrelmail/functions/page_header.php squirrelmail-patched/functions/page_header.php
--- squirrelmail/functions/page_header.php 2008-05-08 12:19:18.000000000 +0200
+++ squirrelmail-patched/functions/page_header.php 2008-05-13 10:59:22.000000000 +0200
@@ -96,9 +96,6 @@
$header_tags .= $oTemplate->fetch_right_to_left_stylesheet_link();
}
- // 5. Printer friendly stylesheet
- $header_tags .= create_css_link($base_uri . 'css/print.css', 'printerfriendly', false, 'print');
-
if ($squirrelmail_language == 'ja_JP') {
/*
* force correct detection of charset, when browser does not follow
diff -urN squirrelmail/help/en_US/options.hlp squirrelmail-patched/help/en_US/options.hlp
--- squirrelmail/help/en_US/options.hlp 2008-05-10 14:27:45.000000000 +0200
+++ squirrelmail-patched/help/en_US/options.hlp 2008-05-13 10:59:22.000000000 +0200
@@ -163,6 +163,14 @@
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.
diff -urN squirrelmail/src/printer_friendly_bottom.php squirrelmail-patched/src/printer_friendly_bottom.php
--- squirrelmail/src/printer_friendly_bottom.php 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/src/printer_friendly_bottom.php 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,173 @@
+<?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: printer_friendly_bottom.php 12582 2007-08-12 19:10:39Z kink $
+ * @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 */
diff -urN squirrelmail/src/printer_friendly_main.php squirrelmail-patched/src/printer_friendly_main.php
--- squirrelmail/src/printer_friendly_main.php 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/src/printer_friendly_main.php 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * printer_friendly frameset
+ *
+ * @copyright © 1999-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id: printer_friendly_main.php 12530 2007-07-14 17:30:44Z kink $
+ * @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');
+
+}
diff -urN squirrelmail/src/printer_friendly_top.php squirrelmail-patched/src/printer_friendly_top.php
--- squirrelmail/src/printer_friendly_top.php 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/src/printer_friendly_top.php 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,28 @@
+<?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: printer_friendly_top.php 12530 2007-07-14 17:30:44Z kink $
+ * @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');
diff -urN squirrelmail/src/read_body.php squirrelmail-patched/src/read_body.php
--- squirrelmail/src/read_body.php 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/src/read_body.php 2008-05-13 10:59:22.000000000 +0200
@@ -672,7 +672,7 @@
function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
global $base_uri, $where, $what, $show_html_default,
- $oTemplate, $download_href, $PHP_SELF,
+ $oTemplate, $download_href,
$unsafe_image_toggle_href, $unsafe_image_toggle_text;
$urlMailbox = urlencode($mailbox);
@@ -688,12 +688,29 @@
}
$url = $base_uri.'src/view_header.php?'.$query_string;
- if ( checkForJavaScript() ) {
- $pf_params = 'javascript:printThis();';
+
+ // Build the printer friend link
+ /* hackydiehack */
+
+ // Pull "view_unsafe_images" from the URL to find out if the unsafe images
+ // should be displayed. The default is not to display unsafe images.
+ if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
+ // If "view_unsafe_images" isn't part of the URL, default to not
+ // displaying unsafe images.
+ $view_unsafe_images = false;
} else {
- $pf_params = set_url_var($PHP_SELF, 'print', '1');
+ // If "view_unsafe_images" is part of the URL, display unsafe images
+ // regardless of the value of the URL variable.
+ // FIXME: Do we really want to display the unsafe images regardless of the value in URL variable?
+ $view_unsafe_images = true;
}
+ $pf_params = '?passed_ent_id=' . $urlPassed_ent_id .
+ '&mailbox=' . $urlMailbox .
+ '&passed_id=' . $urlPassed_id .
+ '&view_unsafe_images='. (bool) $view_unsafe_images .
+ '&show_html_default=' . $show_html_default;
+
$links = array();
$links[] = array (
'URL' => $url,
@@ -701,8 +718,7 @@
);
$links[] = array (
'URL' => $pf_params,
- 'Text' => _("Print"),
- 'Target' => '_blank'
+ 'Text' => _("View Printable Version")
);
$links[] = array (
'URL' => $download_href,
@@ -973,13 +989,7 @@
$oTemplate->assign('message_list_href', get_message_list_uri($aMailbox['NAME'], $startMessage, $what));
displayPageHeader($color, $mailbox,'','');
-
-/* this is the non-javascript version of printer friendly */
-if ( sqgetGlobalVar('print', $print, SQ_GET) ) {
- $oTemplate->display('read_message_print.tpl');
-} else {
- formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,false);
-}
+formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,false);
formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
$oTemplate->assign('message_body', $messagebody);
diff -urN squirrelmail/templates/default/css/default.css squirrelmail-patched/templates/default/css/default.css
--- squirrelmail/templates/default/css/default.css 2008-05-10 14:27:45.000000000 +0200
+++ squirrelmail-patched/templates/default/css/default.css 2008-05-13 10:59:22.000000000 +0200
@@ -1022,6 +1022,30 @@
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.attachName {
+ font-weight: bold;
+}
+
div.viewHeader table.table1 {
width: 100%;
}
@@ -1071,10 +1095,4 @@
background-color: #DCDCDC /* __COLOR0__ */;
}
-#printMessageBox {
- background-color: #fffff0;
- border: 1px solid #f2e93a;
- margin: 1em;
- padding: 1em;
- font-size: x-large;
-}
+
diff -urN squirrelmail/templates/default/js/default.js squirrelmail-patched/templates/default/js/default.js
--- squirrelmail/templates/default/js/default.js 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/templates/default/js/default.js 2008-05-13 10:59:22.000000000 +0200
@@ -283,9 +283,3 @@
}
}
}
-
-function printThis()
-{
- parent.frames['right'].focus();
- parent.frames['right'].print();
-}
diff -urN squirrelmail/templates/default/printer_friendly_bottom.tpl squirrelmail-patched/templates/default/printer_friendly_bottom.tpl
--- squirrelmail/templates/default/printer_friendly_bottom.tpl 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/templates/default/printer_friendly_bottom.tpl 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,111 @@
+<?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: printer_friendly_bottom.tpl 12021 2006-12-30 21:24:00Z pdontthink $
+ * @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>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>
diff -urN squirrelmail/templates/default/printer_friendly_main.tpl squirrelmail-patched/templates/default/printer_friendly_main.tpl
--- squirrelmail/templates/default/printer_friendly_main.tpl 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/templates/default/printer_friendly_main.tpl 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,29 @@
+<?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: printer_friendly_main.tpl 12092 2007-01-07 15:44:12Z kink $
+ * @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>
diff -urN squirrelmail/templates/default/printer_friendly_top.tpl squirrelmail-patched/templates/default/printer_friendly_top.tpl
--- squirrelmail/templates/default/printer_friendly_top.tpl 1970-01-01 01:00:00.000000000 +0100
+++ squirrelmail-patched/templates/default/printer_friendly_top.tpl 2008-05-13 10:59:22.000000000 +0200
@@ -0,0 +1,41 @@
+<?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: printer_friendly_top.tpl 11923 2006-10-18 18:39:45Z stevetruckstuff $
+ * @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>
\ Pas de fin de ligne à la fin du fichier.
diff -urN squirrelmail/templates/default/read_message_print.tpl squirrelmail-patched/templates/default/read_message_print.tpl
--- squirrelmail/templates/default/read_message_print.tpl 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/templates/default/read_message_print.tpl 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-<?php
-/**
- * read_message_print.tpl
- *
- * Let a non-JavaScript user know that they can print this page.
- *
- * @copyright © 2008 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id: read_menubar_nav.tpl 12415 2007-05-18 11:05:23Z pdontthink $
- * @package squirrelmail
- * @subpackage templates
- */
-?>
-
-<div id="printMessageBox">
-<?php echo _("Use your web browser's Print button or File -> Print menu option to print this email. Afterwards, you can close this browser window again to return to SquirrelMail."); ?>
-</div>
diff -urN squirrelmail/templates/default/read_toolbar.tpl squirrelmail-patched/templates/default/read_toolbar.tpl
--- squirrelmail/templates/default/read_toolbar.tpl 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/templates/default/read_toolbar.tpl 2008-05-13 10:59:22.000000000 +0200
@@ -11,11 +11,10 @@
* following elements:
* $link['URL'] - URL needed to access the action
* $link['Text'] - Text to be displayed for the action.
- * $link['Target'] - Optional link target
*
* @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id: read_toolbar.tpl 13123 2008-05-09 16:38:01Z kink $
+ * @version $Id: read_toolbar.tpl 12671 2007-09-04 09:33:10Z kink $
* @package squirrelmail
* @subpackage templates
*/
@@ -34,9 +33,31 @@
if (empty($link['Text']))
continue;
+ # Printer firendly link must be handled a little differently
+ if ($link['Text'] == _("View Printable Version")) {
+ if ($javascript_on) {
+ ?>
+ <script type="text/javascript">
+ <!--
+ function printFormat () {
+ var print_win = window.open("../src/printer_friendly_main.php<?php echo $link['URL']; ?>", "Print", "width=800; height=600");
+ print_win.focus();
+ }
+ // -->
+ </script>
+ <a href="javascript:printFormat()"><?php echo $link['Text']; ?></a>
+ <?php
+ } else {
+ # everything else follows this format...
+ ?>
+ <a href="../src/printer_friendly_bottom.php<?php echo $link['URL']; ?>" target="_blank"><?php echo $link['Text']; ?></a>
+ <?php
+ }
+ } else {
?>
- <a href="<?php echo $link['URL']; ?>"<?php echo (empty($link['Target'])?'':' target="' . $link['Target'] . '"')?>><?php echo $link['Text']; ?></a>
+ <a href="<?php echo $link['URL']; ?>"><?php echo $link['Text']; ?></a>
<?php
+ }
# Spit out a divider between each element
if ($count < count($links)-1) {
diff -urN squirrelmail/templates/default_advanced/css/advanced.css squirrelmail-patched/templates/default_advanced/css/advanced.css
--- squirrelmail/templates/default_advanced/css/advanced.css 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/templates/default_advanced/css/advanced.css 2008-05-13 10:59:22.000000000 +0200
@@ -149,11 +149,4 @@
background: #EEEEEE url(../images/grippie.png) no-repeat center 2px;
}
-#printMessageBox {
- background-color: #fffff0;
- border: 1px solid #f2e93a;
- margin: 1em;
- padding: 1em;
- font-size: x-large;
-}
diff -urN squirrelmail/templates/default_advanced/read_message_print.tpl squirrelmail-patched/templates/default_advanced/read_message_print.tpl
--- squirrelmail/templates/default_advanced/read_message_print.tpl 2008-05-09 18:38:01.000000000 +0200
+++ squirrelmail-patched/templates/default_advanced/read_message_print.tpl 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-<?php
-/**
- * read_message_print.tpl
- *
- * Let a non-JavaScript user know that they can print this page.
- *
- * @copyright © 2008 The SquirrelMail Project Team
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @version $Id: read_menubar_nav.tpl 12415 2007-05-18 11:05:23Z pdontthink $
- * @package squirrelmail
- * @subpackage templates
- */
-?>
-
-<div id="printMessageBox">
-<?php echo _("Use your web browser's Print button or File -> Print menu option to print this email. Afterwards, you can close this browser window again to return to SquirrelMail."); ?>
-</div>