Added Turkish translation.
[squirrelmail.git] / src / compose.php
index f7817bf607834dab4bd8331e3d939ba6e6075981..06c676fb59532f55ac96390aa659fb1a064aa34f 100644 (file)
               while (file_exists($attachment_dir . $localfilename))
                   $localfilename = GenerateRandomString(32, '', 7);
 
+              $newAttachment = array();
               $newAttachment['localfilename'] = $localfilename;
               $newAttachment['remotefilename'] = $filename;
               $newAttachment['type'] = strtolower($message->header->type0 .
          // Set $default_charset to correspond with the user's selection
          // of language interface.
          set_my_charset();
+
+         // This is to change all newlines to \n
+        // We'll change them to \r\n later (in the sendMessage function)
+        $body = str_replace("\r\n", "\n", $body);
+        $body = str_replace("\r", "\n", $body);
+        
+        // Rewrap $body so that no line is bigger than $editor_size
+        // This should only really kick in the sqWordWrap function
+        // if the browser doesn't support "HARD" as the wrap type
+        $body = explode("\n", $body);
+        $newBody = '';
+        foreach ($body as $line) {
+           $line = trim($line);
+           if (strlen($line) <= $editor_size)
+              $newBody .= $line . "\n";
+           else {
+              sqWordWrap($line, $editor_size) . "\n";
+              $newBody .= $line;
+           }
+        }
+        $body = $newBody;
+        
          do_hook("compose_send");
 
          if (! sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
          //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
          displayPageHeader($color, $mailbox);
          
-         if ($AttachFailure)
+         if (isset($AttachFailure))
              plain_error_message(_("Could not move/copy file. File not attached"), $color);
 
          checkInput(true);