Implement printer friendly through CSS also for non-javascript. This
[squirrelmail.git] / src / read_body.php
index 7a7d9f8e39bbbe11ab674f4ae0602ca09bded266..b78a904fcf39ad487bf3b3cce309c1ac9a770c85 100644 (file)
@@ -267,10 +267,10 @@ function SendMDN ( $mailbox, $passed_id, $message, $imapConnection) {
         $success = $deliver->finalizeStream($stream);
     }
     if (!$success) {
-        $msg = _("Message not sent.") . "<br />\n" .
+        $msg = _("Message not sent.") . "\n" .
             $deliver->dlv_msg;
         if (! empty($deliver->dlv_server_msg)) {
-            $msg.= '<br />' .
+            $msg.= "\n" .
                 _("Server replied:") . ' ' . $deliver->dlv_ret_nr . ' ' .
                 nl2br(htmlspecialchars($deliver->dlv_server_msg));
         }
@@ -355,9 +355,10 @@ function formatRecipientString($recipients, $item ) {
         $a = array();
         foreach ($recipients as $r) {
             $a[] = array(
-                            'Name'  => htmlspecialchars($r->getAddress(false)),
+                            // note: decodeHeader is htmlsafe by default
+                            'Name'  => decodeHeader($r->getAddress(false)),
                             'Email' => htmlspecialchars($r->getEmail()),
-                            'Full'  => htmlspecialchars($r->getAddress(true))
+                            'Full'  => decodeHeader($r->getAddress(true))
                         );
         }
 
@@ -671,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);
@@ -687,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,
@@ -717,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,
@@ -988,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);