Implement printer friendly through CSS also for non-javascript. This
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 9 May 2008 16:38:01 +0000 (16:38 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 9 May 2008 16:38:01 +0000 (16:38 +0000)
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

ChangeLog
config/conf.pl
css/print.css
src/read_body.php
templates/default/css/default.css
templates/default/js/default.js
templates/default/read_message_print.tpl [new file with mode: 0644]
templates/default/read_toolbar.tpl
templates/default_advanced/css/advanced.css
templates/default_advanced/read_message_print.tpl [new file with mode: 0644]

index b28d887752702a6335d15542d91c74ef106d0a68..9246d8012615f07a2073efad90937907c1c1a95f 100644 (file)
--- 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)
 --------------------------------------
index cefeca33ac0934dc2a2e4e1544c3e4ae78b3d7eb..423fe16de2601e0f415466c1e4b5ce36d64d7c67 100755 (executable)
@@ -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";
index 3a6acd39a0fe693a8d82c5960ec53a737680d376..06d235f3f39f6268f525d0eb1853d5f30fd87077 100644 (file)
@@ -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; }
 
index 85c0ab60eb879ffeec47aed40e31c9893271618b..b78a904fcf39ad487bf3b3cce309c1ac9a770c85 100644 (file)
@@ -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);
index f1dc0d2cae06d5594bba1ecf45edd3583cbaef03..38161ae0e98443ed657411e2125b6847d925ecab 100644 (file)
@@ -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;
+}
index b3a3c096c2c8a950122e7f6e5083c43bc07a9057..4c7b9e890a18d56524f1529c575d6796f1341c6a 100644 (file)
@@ -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 (file)
index 0000000..3893634
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * read_message_print.tpl
+ *
+ * Let a non-JavaScript user know that they can print this page.
+ *
+ * @copyright &copy; 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 -&gt; Print menu option to print this email. Afterwards, you can close this browser window again to return to SquirrelMail."); ?>
+</div>
index 2bcbb76f421b7fe3e616a044c4a556e84cc49f76..45c57c447bf21caa8114f2c79b223f0e46df55be 100644 (file)
@@ -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 &copy; 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) {
-                ?>
- <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 $link['Text']; ?></a>
+ <a href="<?php echo $link['URL']; ?>"<?php echo (empty($link['Target'])?'':' target="' . $link['Target'] . '"')?>><?php echo $link['Text']; ?></a>
             <?php
-        }
         
         # Spit out a divider between each element
         if ($count < count($links)-1) {
index 141474ca5c97bd384095a3ff069e05fc7b4a4fb5..1655ddeb99cad979d6c54b85eb083d016c32b61a 100644 (file)
     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 --git a/templates/default_advanced/read_message_print.tpl b/templates/default_advanced/read_message_print.tpl
new file mode 100644 (file)
index 0000000..3893634
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * read_message_print.tpl
+ *
+ * Let a non-JavaScript user know that they can print this page.
+ *
+ * @copyright &copy; 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 -&gt; Print menu option to print this email. Afterwards, you can close this browser window again to return to SquirrelMail."); ?>
+</div>