From 341abbd6190f10bcbcf8c7a341612facae60d1cf Mon Sep 17 00:00:00 2001 From: stekkel Date: Thu, 25 Jul 2002 18:32:15 +0000 Subject: [PATCH] moved sqUnwordWrap from compose to this file git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3134 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/strings.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/functions/strings.php b/functions/strings.php index df0a7117..c232e672 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -69,6 +69,36 @@ function sqWordWrap(&$line, $wrap) { } } +/** + * Does the opposite of sqWordWrap() + */ +function sqUnWordWrap(&$body) { + $lines = explode("\n", $body); + $body = ''; + $PreviousSpaces = ''; + $cnt = count($lines); + for ($i = 0; $i < $cnt; $i ++) { + preg_match("/^([\t >]*)([^\t >].*)?$/", $lines[$i], $regs); + $CurrentSpaces = $regs[1]; + if (isset($regs[2])) { + $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"; +} + /** * If $haystack is a full mailbox name and $needle is the mailbox * separator character, returns the last part of the mailbox name. -- 2.25.1