From: kink Date: Fri, 9 May 2008 16:38:01 +0000 (+0000) Subject: Implement printer friendly through CSS also for non-javascript. This X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a6519f058c12bc4eade242bef1c5f4e27a9611ba;p=squirrelmail.git Implement printer friendly through CSS also for non-javascript. This will bring up a new window with read_body loaded with a message box telling the user to print it. Also tweak the print stylesheet a bit. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13123 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index b28d8877..9246d801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -247,6 +247,7 @@ Version 1.5.2 - SVN - Allow database based preferences to read in default settings from the default_pref file next to hardcoding them into the DB class, thanks Thierry Godefroy. + - Reimplement printer friendly to make use of CSS. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/config/conf.pl b/config/conf.pl index cefeca33..423fe16d 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -1703,7 +1703,7 @@ sub display_use_tls($) { } # $encode_header_key -sub command114{ +sub command114 { print "Encryption key allows to hide SquirrelMail Received: headers\n"; print "in outbound messages. Interface uses encryption key to encode\n"; print "username, remote address and proxied address, then stores encoded\n"; diff --git a/css/print.css b/css/print.css index 3a6acd39..06d235f3 100644 --- a/css/print.css +++ b/css/print.css @@ -1,7 +1,10 @@ /* printer friendly style, currently only targeted at read_body */ -#page_header, .readMenuBar, .spacer, form, #listcommands, .field_Options { display: none; } - - +/* 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 --git a/src/read_body.php b/src/read_body.php index 85c0ab60..b78a904f 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -672,7 +672,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { global $base_uri, $where, $what, $show_html_default, - $oTemplate, $download_href, + $oTemplate, $download_href, $PHP_SELF, $unsafe_image_toggle_href, $unsafe_image_toggle_text; $urlMailbox = urlencode($mailbox); @@ -688,29 +688,12 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { } $url = $base_uri.'src/view_header.php?'.$query_string; - - // 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; + if ( checkForJavaScript() ) { + $pf_params = 'javascript:printThis();'; } else { - // 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 = set_url_var($PHP_SELF, 'print', '1'); } - $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, @@ -718,7 +701,8 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { ); $links[] = array ( 'URL' => $pf_params, - 'Text' => _("View Printable Version") + 'Text' => _("Print"), + 'Target' => '_blank' ); $links[] = array ( 'URL' => $download_href, @@ -989,7 +973,13 @@ $_SESSION['mailbox_cache'] = $mailbox_cache; $oTemplate->assign('message_list_href', get_message_list_uri($aMailbox['NAME'], $startMessage, $what)); displayPageHeader($color, $mailbox,'',''); -formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message,false); + +/* 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); +} formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee); $oTemplate->assign('message_body', $messagebody); diff --git a/templates/default/css/default.css b/templates/default/css/default.css index f1dc0d2c..38161ae0 100644 --- a/templates/default/css/default.css +++ b/templates/default/css/default.css @@ -1100,4 +1100,10 @@ div.viewText td.spacer { background-color: #DCDCDC /* __COLOR0__ */; } - +#printMessageBox { + background-color: #fffff0; + border: 1px solid #f2e93a; + margin: 1em; + padding: 1em; + font-size: x-large; +} diff --git a/templates/default/js/default.js b/templates/default/js/default.js index b3a3c096..4c7b9e89 100644 --- a/templates/default/js/default.js +++ b/templates/default/js/default.js @@ -283,3 +283,9 @@ function checkForm(smaction) { } } } + +function printThis() +{ + parent.frames['right'].focus(); + parent.frames['right'].print(); +} diff --git a/templates/default/read_message_print.tpl b/templates/default/read_message_print.tpl new file mode 100644 index 00000000..38936345 --- /dev/null +++ b/templates/default/read_message_print.tpl @@ -0,0 +1,17 @@ + + +
+ +
diff --git a/templates/default/read_toolbar.tpl b/templates/default/read_toolbar.tpl index 2bcbb76f..45c57c44 100644 --- a/templates/default/read_toolbar.tpl +++ b/templates/default/read_toolbar.tpl @@ -11,6 +11,7 @@ * 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 @@ -33,31 +34,9 @@ extract($t); if (empty($link['Text'])) continue; - # Printer firendly link must be handled a little differently - if ($link['Text'] == _("View Printable Version")) { - if ($javascript_on) { - ?> - - - - - - + > + +
+ +