Definitly fix the message truncation bug.
[banana.git] / banana / message.func.inc.php
index de29b94..0d29f64 100644 (file)
@@ -72,12 +72,11 @@ function banana_unflowed($text)
     return $text;
 }
 
-function banana_wordwrap($text, $quote_level)
+function banana_wordwrap($text, $quote_level = 0)
 {
     if ($quote_level > 0) {
         $length = Banana::$msgshow_wrap - $quote_level - 1;
         return banana_quote(wordwrap($text, $length), $quote_level);
-    
     }
     return wordwrap($text, Banana::$msgshow_wrap);
 }
@@ -98,6 +97,24 @@ function banana_catchFormats($text)
     return preg_replace('/&&&urls&&&/e', 'array_shift($urls[0])', $text);
 }
 
+/** Build a flowed text from plain text
+ */
+function banana_flow($text)
+{
+    $lines = explode("\n", $text);
+    $text  = '';
+    while (!is_null($line = array_shift($lines))) {
+        if ($line != '-- ') {
+            $level = 0;
+            $line  = banana_removeQuotes($line, $level);
+            $text .= rtrim(str_replace("\n", " \n", banana_wordwrap($line, $level))) . "\n";
+        } else {
+            $text .= $line . "\n";
+        }
+    }
+    return $text;
+}
+
 // {{{ URL Catcher tools
 
 function banana__cutlink($link)
@@ -187,7 +204,7 @@ function banana_plainTextToHtml($text, $strict = true)
     $text = banana_catchURLs($text);
     $text = banana_catchQuotes($text, $strict);
     $text = banana_catchSignature($text);
-    return banana_cleanHtml('<pre>' . $text . '</pre>');
+    return '<pre>' . $text . '</pre>';
 }
 
 function banana_wrap($text, $base_level = 0, $strict = true)
@@ -230,7 +247,7 @@ function banana_quotePlainText(BananaMimePart &$part)
     if ($part->isFlowed()) {
         $text = banana_unflowed($text);
     }
-    return banana_wrap($text, 1);
+    return banana_quote($text, 1);
 }
 
 // }}}
@@ -356,6 +373,7 @@ function banana_cleanHtml($source, $to_xhtml = false)
             }
             tidy_set_encoding('utf8');
             $source = tidy_repair_string($source);
+
         } else { // Tidy 2.0
             $source = tidy_repair_string($source, $tidy_config, 'utf8');
         }
@@ -482,7 +500,7 @@ function banana_quoteHtml(BananaMimePart &$part)
 {
     $text = $part->getText();
     $text = banana_htmlToPlainText($text);
-    return banana_wrap($text, 1);
+    return banana_quote($text, 1);
 }
 
 // }}}
@@ -534,7 +552,7 @@ function banana_quoteRichtText(BananaMimePart &$part)
     $text = $part->getText();
     $text = banana_richtextToHtml($text);
     $text = banana_htmlToPlainText($text);
-    return banana_wrap($text, 1);
+    return banana_quote($text, 1);
 }
 
 // }}}