moved sqUnwordWrap from compose to this file
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 25 Jul 2002 18:32:15 +0000 (18:32 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 25 Jul 2002 18:32:15 +0000 (18:32 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3134 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index df0a7117452152f1ae87e3d0671ede0cd115437c..c232e6720e07e647e5ffc18d002994cd0701e68b 100644 (file)
@@ -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.