Changed how replied-to messages are wrapped.
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 14 Oct 2000 15:22:16 +0000 (15:22 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 14 Oct 2000 15:22:16 +0000 (15:22 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@798 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php
src/compose.php

index 40f5f15..e59f556 100644 (file)
    // Has a problem with special HTML characters, so call this before
    // you do character translation.
    // Specifically, &#039 comes up as 5 characters instead of 1.
+   // This should not add newlines to the end of lines.
    function sqWordWrap(&$line, $wrap) {
       preg_match("/^([\s>]*)([^\s>].*)?$/", $line, $regs);
       $beginning_spaces = $regs[1];
-      $regs[2] .= "\n"; 
       $words = explode(" ", $regs[2]);
 
       $i = 0;
          }
       }
    }
+   
+   
+   // Does the opposite of sqWordWrap()
+   function sqUnWordWrap(&$body)
+   {
+       $lines = explode("\n", $body);
+       $body = "";
+       $PreviousSpaces = "";
+       for ($i = 0; $i < count($lines); $i ++)
+       {
+           preg_match("/^([\s>]*)([^\s>].*)?$/", $lines[$i], $regs);
+           $CurrentSpaces = $regs[1];
+           $CurrentRest = $regs[2];
+           if ($i == 0)
+           {
+               $PreviousSpaces = $CurrentSpaces;
+               $body = $lines[$i];
+           }
+           else if ($PreviousSpaces == $CurrentSpaces &&  // Do the beginnings match
+               strlen($lines[$i - 1]) > 65 &&             // Over 65 characters long
+               strlen($CurrentRest))                      // and there's a line to continue with
+           {
+               $body .= ' ' . $CurrentRest;
+           }
+           else
+           {
+               $body .= "\n" . $lines[$i];
+               $PreviousSpaces = $CurrentSpaces;
+           }
+       }
+       $body .= "\n";
+   }
+   
 
    /** Returns an array of email addresses **/
    function parseAddrs($text) {
index 48e7087..e7f9402 100644 (file)
          
          if ($message->header->type1 == "html")
             $body = strip_tags($body);
-            
+         
+         sqUnWordWrap($body);   
          $body_ary = explode("\n", $body);
          $body = "";
          for ($i=0; $i < count($body_ary); $i++) {
+            if (! $forward_id)
+            {
+                if (preg_match('/^[\s>]+/', $body_ary[$i]))
+                {
+                    $body_ary[$i] = '>' . $body_ary[$i];
+                }
+                else
+                {
+                    $body_ary[$i] = '> ' . $body_ary[$i];
+                }
+            }
             sqWordWrap($body_ary[$i], $editor_size - 1);
-            $body .= $body_ary[$i];
+            $body .= $body_ary[$i] . "\n";
+            $body_ary[$i] = '';
          }
-         $body_ary = array();
-         $body_ary = explode("\n", $body);
-         $body = "";
-         for ($i=0; $i < count($body_ary); $i++) {
-            if ($i==0 && $forward_id) {
-               $tmp = "-------- " . _("Original Message") . " --------\n";
-               $tmp .= _("Subject") . ": " . $orig_header->subject . "\n"; 
-               $tmp .= _("From") . ": " . $orig_header->from . "\n"; 
-               $tmp .= _("To") . ": " . $orig_header->to[0] . "\n"; 
-               if (count($orig_header->to) > 1) {
-                  for ($x=1; $x < count($orig_header->to); $x++) {
-                     $tmp .= "         " . $orig_header->to[$x] . "\n";
-                  }
-               }
-               $tmp .= "\n" . $body_ary[$i];
-            } else {
-               $tmp = $body_ary[$i];
-            }
-            if ($forward_id)
-               $body = "$body$tmp\n";
-            else
-               $body = "$body> $tmp\n";
+         if ($forward_id)
+         {
+             $bodyTop =  "-------- " . _("Original Message") . " --------\n";
+             $bodyTop .= _("Subject") . ": " . $orig_header->subject . "\n"; 
+             $bodyTop .= _("From") . ": " . $orig_header->from . "\n"; 
+             $bodyTop .= _("To") . ": " . $orig_header->to[0] . "\n"; 
+             if (count($orig_header->to) > 1) {
+                 for ($x=1; $x < count($orig_header->to); $x++) {
+                     $bodyTop .= "         " . $orig_header->to[$x] . "\n";
+                 }
+             }
+             $bodyTop .= "\n";
+             $body = $bodyTop . $body;
          }
 
          sqimap_mailbox_close($imapConnection);
-         return $body;   
+         return;
       }
 
       if (!$send_to) {
       $reply_subj = decodeHeader($reply_subj);
       $forward_subj = decodeHeader($forward_subj);
       $body = sqStripSlashes($body);
-
+      
       if ($use_javascript_addr_book) {
          echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
          echo "function open_abook() { \n";
          sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id);
          header ("Location: right_main.php?mailbox=$urlMailbox&sort=$sort&startMessage=1");
       } else {
-         $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+         //$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
          displayPageHeader($color, $mailbox);
          checkInput(true);
          
          showInputForm();
-         sqimap_logout($imapConnection);
+         //sqimap_logout($imapConnection);
       }
    } else if ($html_addr_search_done) {
       is_logged_in();