Fix outgoing body wrapping in devel, by forwardporting the working code
[squirrelmail.git] / src / compose.php
index c0fe87952aa498403fc8147a609d99a1287fe573..6d4c72383f3f9896c21ab1ed8efcf112508a2aef 100644 (file)
@@ -369,12 +369,24 @@ if ($send) {
         $body = str_replace("\r", "\n", $body);
 
         /**
-         * If the browser doesn't support "VIRTUAL" as the wrap type.
-         * then the line length will be longer than $editor_size
-         * almost all browsers support VIRTUAL, so remove the line by line checking
-         * If this causes a problem, call sqBodyWrap
+         * Rewrap $body so that no line is bigger than $editor_size
          */
-        // sqBodyWrap($body, $editor_size);
+        $body = explode("\n", $body);
+        $newBody = '';
+        foreach ($body as $line) {
+            if( $line <> '-- ' ) {
+               $line = rtrim($line);
+            }
+            if (strlen($line) <= $editor_size + 1) {
+                $newBody .= $line . "\n";
+            } else {
+                sqWordWrap($line, $editor_size);
+                $newBody .= $line . "\n";
+
+            }
+
+        }
+        $body = $newBody;
 
         $composeMessage=$compose_messages[$session];
 
@@ -996,28 +1008,28 @@ function showInputForm ($session, $values=false) {
 
     echo '   <tr>' . "\n" .
                 html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
-                _("To:") . '</td>' . "\n" .
+                _("To") . ':</td>' . "\n" .
                 html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
                 addInput('send_to', $send_to, 60). '<br />' . "\n" .
          '      </td>' . "\n" .
          '   </tr>' . "\n" .
          '   <tr>' . "\n" .
                 html_tag( 'td', '', 'right', $color[4] ) .
-                _("CC:") . '</td>' . "\n" .
+                _("Cc") . ':</td>' . "\n" .
                 html_tag( 'td', '', 'left', $color[4] ) .
-      addInput('send_to_cc', $send_to_cc, 60). '<br />' . "\n" .
+                addInput('send_to_cc', $send_to_cc, 60). '<br />' . "\n" .
          '      </td>' . "\n" .
          '   </tr>' . "\n" .
          '   <tr>' . "\n" .
                 html_tag( 'td', '', 'right', $color[4] ) .
-                _("BCC:") . '</td>' . "\n" .
+                _("Bcc") . ':</td>' . "\n" .
                 html_tag( 'td', '', 'left', $color[4] ) .
-      addInput('send_to_bcc', $send_to_bcc, 60).'<br />' . "\n" .
+                addInput('send_to_bcc', $send_to_bcc, 60).'<br />' . "\n" .
          '      </td>' . "\n" .
          '   </tr>' . "\n" .
          '   <tr>' . "\n" .
                 html_tag( 'td', '', 'right', $color[4] ) .
-                _("Subject:") . '</td>' . "\n" .
+                _("Subject") . ':</td>' . "\n" .
                 html_tag( 'td', '', 'left', $color[4] ) . "\n";
     echo '         '.addInput('subject', $subject, 60).
          '      </td>' . "\n" .
@@ -1074,7 +1086,7 @@ function showInputForm ($session, $values=false) {
     } else {
         echo '   <tr>' . "\n" .
                     html_tag( 'td', '', 'right', '', 'colspan="2"' ) . "\n" .
-             '         <input type="submit" name="send" value="' . _("Send") . '" />' . "\n" .
+             '         ' . addSubmit(_("Send"), 'send').
              '         &nbsp;&nbsp;&nbsp;&nbsp;<br /><br />' . "\n" .
              '      </td>' . "\n" .
              '   </tr>' . "\n";
@@ -1132,9 +1144,9 @@ function showInputForm ($session, $values=false) {
                         $attachment->mime_header->type1;
 
                 $s_a[] = '<table bgcolor="'.$color[0].
-                '" border="0"><tr><td>'.
-                  addCheckBox('delete[]', FALSE, $key).
-                  "</td><td>\n" . $attached_filename .
+                    '" border="0"><tr><td>'.
+                    addCheckBox('delete[]', FALSE, $key).
+                    "</td><td>\n" . $attached_filename .
                     '</td><td>-</td><td> ' . $type . '</td><td>('.
                     show_readable_size( filesize( $attached_file ) ) . ')</td></tr></table>'."\n";
            }
@@ -1161,18 +1173,18 @@ function showInputForm ($session, $values=false) {
     }
 
     echo '</table>' . "\n" .
-      addHidden('username', $username).
-      addHidden('smaction', $action).
-      addHidden('mailbox', $mailbox);
+        addHidden('username', $username).
+        addHidden('smaction', $action).
+        addHidden('mailbox', $mailbox);
     /*
        store the complete ComposeMessages array in a hidden input value
        so we can restore them in case of a session timeout.
     */
     sqgetGlobalVar('QUERY_STRING', $queryString, SQ_SERVER);
     echo addHidden('restoremessages', serialize($compose_messages)).
-      addHidden('composesession', $composesession).
-      addHidden('querystring', $queryString).
-      "</form>\n";
+         addHidden('composesession', $composesession).
+         addHidden('querystring', $queryString).
+         "</form>\n";
     if (!(bool) ini_get('file_uploads')) {
       /* File uploads are off, so we didn't show that part of the form.
          To avoid bogus bug reports, tell the user why. */
@@ -1222,7 +1234,7 @@ function showComposeButtonRow() {
     if ($use_javascript_addr_book) {
         echo "         <script language=\"JavaScript\"><!--\n document.write(\"".
              "            <input type=button value=\\\""._("Addresses").
-                                 "\\\" onclick=\"javascript:open_abook();\" />\");".
+                                 "\\\" onclick=\\\"javascript:open_abook();\\\" />\");".
              "            // --></script><noscript>\n".
              '            <input type="submit" name="html_addr_search" value="'.
                               _("Addresses").'" />'.
@@ -1546,4 +1558,5 @@ function deliverMessage($composeMessage, $draft=false) {
     return $succes;
 }
 
-?>
\ No newline at end of file
+// vim: et ts=4
+?>