From: fidian Date: Sat, 14 Oct 2000 15:22:16 +0000 (+0000) Subject: Changed how replied-to messages are wrapped. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=01aab860705725d4ba5b003fc01cb6bac92a8390 Changed how replied-to messages are wrapped. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@798 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/strings.php b/functions/strings.php index 40f5f15b..e59f556e 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -48,10 +48,10 @@ // Has a problem with special HTML characters, so call this before // you do character translation. // Specifically, ' 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; @@ -81,6 +81,39 @@ } } } + + + // 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) { diff --git a/src/compose.php b/src/compose.php index 48e7087a..e7f94025 100644 --- a/src/compose.php +++ b/src/compose.php @@ -71,39 +71,43 @@ 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) { @@ -149,7 +153,7 @@ $reply_subj = decodeHeader($reply_subj); $forward_subj = decodeHeader($forward_subj); $body = sqStripSlashes($body); - + if ($use_javascript_addr_book) { echo "\n