XHTML fixes
[squirrelmail.git] / src / read_body.php
index cf0d3b2f9bb6bfd5fd983385d7f621eaf0a528ac..57b1bd6f6309694592c69c6cd09ec4fdcffdf04a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * read_body.php
  *
@@ -184,16 +185,16 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
     $now = getLongDateString( time() );
     set_my_charset();
     $body = _("Your message") . "\r\n\r\n" .
-            "\t" . _("To:") . ' ' . decodeHeader($to,false,false) . "\r\n" .
-            "\t" . _("Subject:") . ' ' . decodeHeader($header->subject,false,false) . "\r\n" .
-            "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
+            "\t" . _("To") . ': ' . decodeHeader($to,false,false) . "\r\n" .
+            "\t" . _("Subject") . ': ' . decodeHeader($header->subject,false,false) . "\r\n" .
+            "\t" . _("Sent") . ': ' . $senton . "\r\n" .
             "\r\n" .
             sprintf( _("Was displayed on %s"), $now );
 
     $special_encoding = '';
     if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
-        function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
-        $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
+        function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode')) {
+        $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_encode', $body);
         if (strtolower($default_charset) == 'iso-2022-jp') {
             if (mb_detect_encoding($body) == 'ASCII') {
                 $special_encoding = '8bit';
@@ -202,6 +203,8 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
                 $special_encoding = '7bit';
             }
         }
+    } elseif (sq_is8bit($body)) {
+        $special_encoding = '8bit';
     }
     $part1 = new Message();
     $part1->setBody($body);
@@ -265,7 +268,7 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
         $success = $deliver->finalizeStream($stream);
     }
     if (!$success) {
-        $msg  = $deliver->dlv_msg . '<br>' .
+        $msg  = $deliver->dlv_msg . '<br />' .
                 _("Server replied: ") . $deliver->dlv_ret_nr . ' '.
                 $deliver->dlv_server_msg;
         require_once(SM_PATH . 'functions/display_messages.php');
@@ -302,7 +305,7 @@ function ClearAttachments() {
             if ($info['session'] == -1) {
                 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
                 if (file_exists($attached_file)) {
-                        unlink($attached_file);
+                    unlink($attached_file);
                 }
             } else {
                 $rem_attachments[] = $info;
@@ -347,15 +350,15 @@ function formatRecipientString($recipients, $item ) {
         foreach($recipients as $r) {
             $add = decodeHeader($r->getAddress(true));
             if ($string) {
-                $string .= '<BR>' . $add;
+                $string .= '<br />' . $add;
             } else {
                 $string = $add;
                 if ($cnt > 1) {
-                    $string .= '&nbsp;(<A HREF="'.$url;
+                    $string .= '&nbsp;(<a href="'.$url;
                     if ($show) {
-                       $string .= '">'._("less").'</A>)';
+                       $string .= '">'._("less").'</a>)';
                     } else {
-                       $string .= '">'._("more").'</A>)';
+                       $string .= '">'._("more").'</a>)';
                        break;
                     }
                 }
@@ -369,9 +372,9 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
                          $color, $FirstTimeSee) {
     global $msn_user_support, $default_use_mdn, $default_use_priority,
            $show_xmailer_default, $mdn_user_support, $PHP_SELF, $javascript_on,
-          $squirrelmail_language;
+           $squirrelmail_language;
 
-    $mailbox = $aMailbox['NAME']       ;
+    $mailbox = $aMailbox['NAME'];
 
     $header = $message->rfc822_header;
     $env = array();
@@ -425,26 +428,26 @@ function formatEnvheader($aMailbox, $passed_id, $passed_ent_id, $message,
         }
     }
 
-    $s  = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="2" BORDER="0"';
-    $s .= ' ALIGN="center" BGCOLOR="'.$color[0].'">';
+    $s  = '<table width="100%" cellpadding="0" cellspacing="2" border="0"';
+    $s .= ' align="center" bgcolor="'.$color[0].'">';
     foreach ($env as $key => $val) {
         if ($val) {
-            $s .= '<TR>';
-            $s .= html_tag('TD', '<B>' . $key . ':&nbsp;&nbsp;</B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
-            $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
-            $s .= '</TR>';
+            $s .= '<tr>';
+            $s .= html_tag('td', '<b>' . $key . ':&nbsp;&nbsp;</b>', 'right', '', 'valign="top" width="20%"') . "\n";
+            $s .= html_tag('td', $val, 'left', '', 'valign="top" width="80%"') . "\n";
+            $s .= '</tr>';
         }
     }
-    echo '<TABLE BGCOLOR="'.$color[9].'" WIDTH="100%" CELLPADDING="1"'.
-         ' CELLSPACING="0" BORDER="0" ALIGN="center">'."\n";
-    echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.
-          $color[4].'"></TD></TR><TR><TD align=center>'."\n";
+    echo '<table bgcolor="'.$color[9].'" width="100%" cellpadding="1"'.
+         ' cellspacing="0" border="0" align="center">'."\n";
+    echo '<tr><td height="5" colspan="2" bgcolor="'.
+          $color[4].'"></td></tr><tr><td align="center">'."\n";
     echo $s;
     do_hook('read_body_header');
     formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
-    echo '</TABLE>';
-    echo '</TD></TR><TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.$color[4].'"></TD></TR>'."\n";
-    echo '</TABLE>';
+    echo '</table>';
+    echo '</td></tr><tr><td height="5" colspan="2" bgcolor="'.$color[4].'"></td></tr>'."\n";
+    echo '</table>';
 }
 
 /**
@@ -596,7 +599,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
 
 
     // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc.
-    $menu_row = '<tr bgcolor="'.$color[9].'"><td><small>';
+    $menu_row = '<tr bgcolor="'.$color[0].'"><td><small>';
     $comp_uri = $base_uri.'src/compose.php' .
                 '?passed_id=' . $passed_id .
                 '&amp;mailbox=' . $urlMailbox .
@@ -630,13 +633,13 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
     }
     // Show Alt URI for Draft/Sent
     if (isset($comp_alt_string))
-        $menu_row .= getButton('SUBMIT', $new_button, $comp_alt_string, $on_click) . "\n";
+        $menu_row .= getButton('submit', $new_button, $comp_alt_string, $on_click) . "\n";
 
-    $menu_row .= getButton('SUBMIT', 'smaction_reply', _("Reply"), $on_click) . "\n";
-    $menu_row .= getButton('SUBMIT', 'smaction_reply_all', _("Reply All"), $on_click) ."\n";
-    $menu_row .= getButton('SUBMIT', 'smaction_forward', _("Forward"), $on_click);
+    $menu_row .= getButton('submit', 'smaction_reply', _("Reply"), $on_click) . "\n";
+    $menu_row .= getButton('submit', 'smaction_reply_all', _("Reply All"), $on_click) ."\n";
+    $menu_row .= getButton('submit', 'smaction_forward', _("Forward"), $on_click);
     if ($enable_forward_as_attachment)
-        $menu_row .= '<input type="checkbox" name="smaction_attache">' . _("As Attachment") .'&nbsp;&nbsp;'."\n";
+        $menu_row .= '<input type="checkbox" name="smaction_attache" />' . _("As Attachment") .'&nbsp;&nbsp;'."\n";
 
     $menu_row .= '</form>&nbsp;';
 
@@ -648,10 +651,11 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
         if (!(isset($passed_ent_id) && $passed_ent_id)) {
             $menu_row .= addHidden('mailbox', $aMailbox['NAME']);
             $menu_row .= addHidden('msg[0]', $passed_id);
-            $menu_row .= getButton('SUBMIT', 'delete', _("Delete"));
-            $menu_row .= '<input type="checkbox" name="bypass_trash">' . _("Bypass Trash");
+            $menu_row .= addHidden('startMessage', $startMessage);
+            $menu_row .= getButton('submit', 'delete', _("Delete"));
+            $menu_row .= '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
         } else {
-            $menu_row .= getButton('SUBMIT', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled
+            $menu_row .= getButton('submit', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled
         }
 
         $menu_row .= '</form>';
@@ -676,7 +680,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removed
         }
         $menu_row .= '</select> ';
 
-        $menu_row .= getButton('SUBMIT', 'moveButton',_("Move")) . "\n" . '</form>';
+        $menu_row .= getButton('submit', 'moveButton',_("Move")) . "\n" . '</form>';
     }
     $menu_row .= '</td></tr>';
 
@@ -715,9 +719,9 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
 
     $url = $base_uri.'src/view_header.php?'.$query_string;
 
-    $s  = "<TR>\n" .
-          html_tag( 'td', '', 'right', '', 'VALIGN="MIDDLE" WIDTH="20%"' ) . '<B>' . _("Options") . ":&nbsp;&nbsp;</B></TD>\n" .
-          html_tag( 'td', '', 'left', '', 'VALIGN="MIDDLE" WIDTH="80%"' ) . '<SMALL>' .
+    $s  = "<tr>\n" .
+          html_tag( 'td', '', 'right', '', 'valign="middle" width="20%"' ) . '<b>' . _("Options") . ":&nbsp;&nbsp;</b></td>\n" .
+          html_tag( 'td', '', 'left', '', 'valign="middle" width="80%"' ) . '<small>' .
           '<a href="'.$url.'">'._("View Full Header").'</a>';
 
     /* Output the printer friendly link if we are in subtle mode. */
@@ -725,8 +729,8 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
           printer_friendly_link($mailbox, $passed_id, $passed_ent_id);
     echo $s;
     do_hook("read_body_header_right");
-    $s = "</SMALL></TD>\n" .
-         "</TR>\n";
+    $s = "</small></td>\n" .
+         "</tr>\n";
     echo $s;
 
 }
@@ -849,7 +853,7 @@ $header = $message->header;
 if (isset($sendreceipt)) {
    if ( !$message->is_mdnsent ) {
       $final_recipient = '';
-      if ((isset($identity)) && ($identity != 0))      //Main identity
+      if ((isset($identity)) && ($identity != 0)) //Main identity
          $final_recipient = trim(getPref($data_dir, $username, 'email_address' . $identity, '' ));
       if ($final_recipient == '' )
          $final_recipient = trim(getPref($data_dir, $username, 'email_address', '' ));
@@ -879,7 +883,7 @@ $cnt = count($ent_ar);
 for ($i = 0; $i < $cnt; $i++) {
    $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
    if ($i != $cnt-1) {
-       $messagebody .= '<hr noshade size=1>';
+       $messagebody .= '<hr style="height: 1px;" />';
    }
 }
 
@@ -894,7 +898,7 @@ echo '        <table width="100%" cellpadding="3" cellspacing="0" align="center"
 echo '          <tr bgcolor="'.$color[4].'"><td>';
 // echo '            <table cellpadding="1" cellspacing="5" align="left" border="0">';
 echo html_tag( 'table' ,'' , 'left', '', 'cellpadding="1" cellspacing="5" border="0"' );
-echo '              <tr>' . html_tag( 'td', '<br>'. $messagebody."\n", 'left')
+echo '              <tr>' . html_tag( 'td', '<br />'. $messagebody."\n", 'left')
                         . '</tr>';
 echo '            </table>';
 echo '          </td></tr>';
@@ -902,8 +906,8 @@ echo '        </table></td></tr>';
 echo '    </table>';
 echo '  </td></tr>';
 
-echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.
-          $color[4].'"></TD></TR>'."\n";
+echo '<tr><td height="5" colspan="2" bgcolor="'.
+          $color[4].'"></td></tr>'."\n";
 
 $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
 if ($attachmentsdisplay) {
@@ -920,8 +924,8 @@ if ($attachmentsdisplay) {
    echo '          </td></tr></table>';
    echo '       </td></tr></table>';
    echo '  </td></tr>';
-   echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.
-          $color[4].'"></TD></TR>';
+   echo '<tr><td height="5" colspan="2" bgcolor="'.
+          $color[4].'"></td></tr>';
 }
 echo '</table>';
 
@@ -938,10 +942,10 @@ if (($attachment_common_show_images) &&
 
         echo html_tag( 'table', "\n" .
                     html_tag( 'tr', "\n" .
-                        html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
+                        html_tag( 'td', '<img src="' . $imgurl . '" />' ."\n", 'left'
                         )
                     ) ,
-        'center', '', 'cellspacing=0 border="0" cellpadding="2"');
+        'center', '', 'cellspacing="0" border="0" cellpadding="2"');
     }
 }
 
@@ -955,5 +959,4 @@ sqimap_logout($imapConnection);
 $mailbox_cache[$aMailbox['NAME']] = $aMailbox;
 sqsession_register($mailbox_cache,'mailbox_cache');
 ?>
-</body>
-</html>
+</body></html>
\ No newline at end of file