Re: Printer friendly pages (was: SF.net SVN: squirrelmail: [13121] trunk/squirrelmail)

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Parent Message unknown Re: Printer friendly pages (was: SF.net SVN: squirrelmail: [13121] trunk/squirrelmail)

by Fredrik Jervfors-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> Add preliminary printerfriendly-through-css feature. This adds a new
>> print.css stylesheet that is used when using the browser's print (or
>> print preview) function. A problem is that due to the frames, it won't
>> work if selecting File -> Print because this will print webmail.php
>> instead of read_body. To see it in action, open read_body on its own and
>> use File -> Print Preview.
>
> I didn't try it, but nice work.

I too didn't try it, but I like the idea.

>> It would be nice if this could replace the printer_friendly function
>> over time, because it's purely css based and thus doesn't require extra
>> code. For that we need to finetune the sheet and most importantly,
>> conquer the frames-problem in some smart way.
>
> Many many websites use a popup window for print-ready pages.

With the possibilities in CSS they shouldn't have to any more, but as
Thijs points out that only works if the original idea behind the WWW is
respected: that information is displayed as pages and not in frames. When
(hopefully not "if") we have a framless version we could dump the pop-ups
altogether (and have a plugin with pop-ups for those who really wants
them).

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!

Sincerely,
Fredrik

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Parent Message unknown Re: Printer friendly pages (was: SF.net SVN: squirrelmail: [13121] trunk/squirrelmail)

by Fredrik Jervfors-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>>> Add preliminary printerfriendly-through-css feature. This adds a
>>>> new print.css stylesheet that is used when using the browser's print
>>>> (or
>>>> print preview) function. A problem is that due to the frames, it
>>>> won't work if selecting File -> Print because this will print
>>>> webmail.php instead of read_body. To see it in action, open
>>>> read_body on its own and use File -> Print Preview.
>>>
>>> I didn't try it, but nice work.
>>
>> I too didn't try it, but I like the idea.
>>
>>>> It would be nice if this could replace the printer_friendly
>>>> function over time, because it's purely css based and thus doesn't
>>>> require extra code. For that we need to finetune the sheet and most
>>>> importantly, conquer the frames-problem in some smart way.
>>>
>>> Many many websites use a popup window for print-ready pages.
>>
>> With the possibilities in CSS they shouldn't have to any more, but as
>> Thijs points out that only works if the original idea behind the WWW is
>> respected: that information is displayed as pages and not in frames.
>> When
>
> I don't know why such the hatred of frames.  :-)  They are more
> efficient and they work fine.  Plenty of desktop apps also use frames.

I don't hate frames - I'm just saying that they're an add-on to the
original idea about the page (and beauty in simplicity?).

>> (hopefully not "if") we have a framless version we could dump the
>> pop-ups
>
> 1.5.2 allows this.  I have fiddled with some code that unframes it
> whilst working on mobile phone stuff.  No folder list unless you access it
> via a link, but some other advanced template set should be able to include
> that, too, although some core changes may or may not be necessary.

Sweet! For some reason I wasn't aware of this.

>> altogether (and have a plugin with pop-ups for those who really wants
>> them).
>>
>> 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!

Sincerely,
Fredrik


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Thijs Kinkhorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, May 8, 2008 23:53, Fredrik Jervfors 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'm enthusiastic about it because it replaces a significant amount of code
and files with just a handful lines of new stuff. So only open question to
me is what to do when there's no JavaScript.

Currently I'm thinking along this line. When no Javascript, then:

- The Print link is a link to same read_body with a print=1 parameter
attached and a target="_blank".
- Read_body opens in a new window and near the top is a box that says: Use
File->Print in your browser to print this message. of course that box is
also hidden with css from the actual print.

That seems to me the best way to support both JS and non_JS browsers
without having to keep a large infrastructure just for the (increasingly
more rare) non-JS browsers.

Comments welcome. I'll probably continue with implementing this sometime
soon.

I've looked into a way to use the print CSS to just hide or get rid of the
left frame when print is invoked on webmail.php, but couldn't get it done.
If someone gets that working, then that would of course also be great.


cheers,
Thijs


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Paul Lesniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 9, 2008 at 2:13 AM, Thijs Kinkhorst <kink@...> wrote:

> On Thu, May 8, 2008 23:53, Fredrik Jervfors 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'm enthusiastic about it because it replaces a significant amount of code
> and files with just a handful lines of new stuff. So only open question to
> me is what to do when there's no JavaScript.
>
> Currently I'm thinking along this line. When no Javascript, then:
>
> - The Print link is a link to same read_body with a print=1 parameter
> attached and a target="_blank".
> - Read_body opens in a new window and near the top is a box that says: Use
> File->Print in your browser to print this message. of course that box is
> also hidden with css from the actual print.
>
> That seems to me the best way to support both JS and non_JS browsers
> without having to keep a large infrastructure just for the (increasingly
> more rare) non-JS browsers.
>
> Comments welcome. I'll probably continue with implementing this sometime
> soon.

I like it

> I've looked into a way to use the print CSS to just hide or get rid of the
> left frame when print is invoked on webmail.php, but couldn't get it done.
> If someone gets that working, then that would of course also be great.

Can't the default style sheet have a display:none for media:<anything
but print>??

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Thijs Kinkhorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 9, 2008 16:23, Paul Lesniewski wrote:
>> I've looked into a way to use the print CSS to just hide or get rid of
>> the left frame when print is invoked on webmail.php, but couldn't get it
>> done. If someone gets that working, then that would of course also be
>> great.
>
> Can't the default style sheet have a display:none for media:<anything
> but print>??


Sorry, don't follow what you mean...


Thijs





-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Paul Lesniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 9, 2008 at 7:28 AM, Thijs Kinkhorst <kink@...> wrote:

> On Fri, May 9, 2008 16:23, Paul Lesniewski wrote:
>>> I've looked into a way to use the print CSS to just hide or get rid of
>>> the left frame when print is invoked on webmail.php, but couldn't get it
>>> done. If someone gets that working, then that would of course also be
>>> great.
>>
>> Can't the default style sheet have a display:none for media:<anything
>> but print>??
>
> Sorry, don't follow what you mean...

My css is rusty ATM, but I was pretty sure you could specify any css
attributes you want to differently for each media type.  So in the
left frame's style sheet (might need to split one off for it), set
display:none for the print media type (sorry, reverse logic in my
previous post above).  Something like:

<style type="text/css" media="print">
body { visibility: hidden; display: none }
... you can add any extra print-only style here...
</style>

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Thijs Kinkhorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 9, 2008 16:41, Paul Lesniewski wrote:
> My css is rusty ATM, but I was pretty sure you could specify any css
> attributes you want to differently for each media type.  So in the left
> frame's style sheet (might need to split one off for it), set display:none
> for the print media type (sorry, reverse logic in my previous post above).

Yes, but with such a technique I can make the frame empty, but not
disappear. So if you print webmail.php, your printout will have a chunk of
white space on the left hand side.

If there were some way to set the entire frame to display none or to width
0 I'm interested but I couldn't find a working one.


Thijs


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Paul Lesniewski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, May 9, 2008 at 7:57 AM, Thijs Kinkhorst <kink@...> wrote:

> On Fri, May 9, 2008 16:41, Paul Lesniewski wrote:
>> My css is rusty ATM, but I was pretty sure you could specify any css
>> attributes you want to differently for each media type.  So in the left
>> frame's style sheet (might need to split one off for it), set display:none
>> for the print media type (sorry, reverse logic in my previous post above).
>
> Yes, but with such a technique I can make the frame empty, but not
> disappear. So if you print webmail.php, your printout will have a chunk of
> white space on the left hand side.
>
> If there were some way to set the entire frame to display none or to width
> 0 I'm interested but I couldn't find a working one.

Do you use the advanced skin?  Notice the up and down buttons in the
upper right-hand corner.  They push the preview pane away (by setting
frame widths).  You can steal that code.  Catch is that again it
requires JavaScript, but the concept is easy (note that the width
setting part should be abstracted):

<script type="text/javascript">
<!--

   orig_left_size = ..... can't be bothered to figure this out, but
it's easy enough....

   if (document.all)
   {
      parent.document.all["fs1"].cols = "0, *";
   }
   else if (this.document.getElementById)
   {
      parent.document.getElementById("fs1").cols = "0, *";
   }

   PRINT!!!

   if (document.all)
   {
      parent.document.all["fs1"].cols = orig_left_size + ", *";
   }
   else if (this.document.getElementById)
   {
      parent.document.getElementById("fs1").cols = orig_left_size + ", *";
   }

//-->
</script>

Thing is, would the javascript block at the PRINT part until the
content is sent to the printer before it sets the left frame back up
to size?

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Michael Peddemors :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday 09 May 2008 02:13, Thijs Kinkhorst wrote:
> Currently I'm thinking along this line. When no Javascript, then:

Or simply adopt a strategy now that you have to have JavaScript enabled to use
Webmail.. don't you think it is time?

--
--
"Catch the Magic of Linux..."
------------------------------------------------------------------------
Michael Peddemors - President/CEO - LinuxMagic
Products, Services, Support and Development
Visit us at http://www.linuxmagic.com
------------------------------------------------------------------------
A Wizard IT Company - For More Info http://www.wizard.ca
"LinuxMagic" is a Registered TradeMark of Wizard Tower TechnoServices Ltd.
------------------------------------------------------------------------
604-589-0037 Beautiful British Columbia, Canada

This email and any electronic data contained are confidential and intended
solely for the use of the individual or entity to which they are addressed.
Please note that any views or opinions presented in this email are solely
those of the author and are not intended to  represent those of the company.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Thijs Kinkhorst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday 9 May 2008 20:15, Michael Peddemors wrote:
> On Friday 09 May 2008 02:13, Thijs Kinkhorst wrote:
> > Currently I'm thinking along this line. When no Javascript, then:
>
> Or simply adopt a strategy now that you have to have JavaScript enabled to
> use Webmail.. don't you think it is time?

I have no problem at all with JavaScript but do believe we should make the
core features work without it. Reading a mail, sending a mail, and printing
is also one of them. If less basic stuff doesn't work without JS, then so be
it. On the other hand, if there's relatively simple code with which we can
make it work, why wouldn't we?

It's not quite about browsers that don't support JS at all. It's more about
companies, internet cafes and the like that disable or block JS.


Thijs

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Fredrik Jervfors-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> 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'm enthusiastic about it because it replaces a significant amount of
> code and files with just a handful lines of new stuff. So only open
> question to me is what to do when there's no JavaScript.
>
> Currently I'm thinking along this line. When no Javascript, then:
>
>
> - The Print link is a link to same read_body with a print=1 parameter
> attached and a target="_blank". - Read_body opens in a new window and near
> the top is a box that says: Use File->Print in your browser to print this
> message. of course that box is also hidden with css from the actual print.
>
>
> That seems to me the best way to support both JS and non_JS browsers
> without having to keep a large infrastructure just for the (increasingly
> more rare) non-JS browsers.
>
> Comments welcome. I'll probably continue with implementing this sometime
> soon.
>
> I've looked into a way to use the print CSS to just hide or get rid of
> the left frame when print is invoked on webmail.php, but couldn't get it
> done. If someone gets that working, then that would of course also be
> great.

Sounds like a good approach. I've seen your commits, but I haven't tested
it yet. Nice work, Thijs!

Sincerely,
Fredrik

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: squirrelmail-devel@...
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel

Re: Printer friendly pages

by Thierry Godefroy-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <jervfors@...> 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
[squirrelmail-20080513-SVN_devel-ReinstatePrinterFriendly.patch]

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.
+ *     &nb