Merge width & wrap options for Html2text; use correct case for driver name
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 05:58:16 +0000 (22:58 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 07:09:41 +0000 (00:09 -0700)
framework/Mime/lib/Horde/Mime/Mail.php
framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php
framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt
framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt
imp/compose.php
imp/lib/Ajax/Application.php
imp/lib/Compose.php
imp/lib/Contents.php
imp/lib/Mime/Viewer/Html.php
imp/stationery.php

index 720d426..42feafe 100644 (file)
@@ -234,7 +234,7 @@ class Horde_Mime_Mail
         $this->_htmlBody->setCharset($charset);
         $this->_htmlBody->setContents($body);
         if ($alternative) {
-            $this->setBody(Horde_Text_Filter::filter($body, 'html2text', array('wrap' => false)), $charset);
+            $this->setBody(Horde_Text_Filter::filter($body, 'Html2text', array('wrap' => false)), $charset);
         }
     }
 
index 593ad30..382c0ab 100644 (file)
@@ -5,8 +5,7 @@
  * Parameters:
  * <pre>
  * charset - (string) The charset to use for html_entity_decode() calls.
- * width - (integer) The wrapping width.
- * wrap - (boolean) Whether to wrap the text or not.
+ * width - (integer) The wrapping width. Set to 0 to not wrap.
  * </pre>
  *
  * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
@@ -55,8 +54,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base
      */
     protected $_params = array(
         'charset' => 'UTF-8',
-        'width' => 70,
-        'wrap' => true
+        'width' => 75
     );
 
     /**
@@ -117,7 +115,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base
         $text = preg_replace(array("/\s*\n{3,}/", "/ +\n/"), array("\n\n", "\n"), $text);
 
         /* Wrap the text to a readable format. */
-        if ($this->_params['wrap']) {
+        if ($this->_params['width']) {
             $text = wordwrap($text, $this->_params['width']);
         }
 
@@ -244,7 +242,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base
                                     continue;
                                 }
 
-                                if ($this->_params['wrap']) {
+                                if ($this->_params['width']) {
                                     $tmp = array();
                                     foreach (explode("\n", $val['text']) as $val2) {
                                         $tmp = array_merge($tmp, explode("\n", wordwrap($val2, $this->_params['width'] - (2 * $val['level']))));
index 2a63a9d..30d5964 100644 (file)
@@ -9,7 +9,7 @@ require dirname(__FILE__) . '/../../../../lib/Horde/Text/Filter.php';
 require dirname(__FILE__) . '/../../../../lib/Horde/Text/Filter/Base.php';
 require dirname(__FILE__) . '/../../../../lib/Horde/Text/Filter/Html2text.php';
 $html = file_get_contents(dirname(__FILE__) . '/fixtures/html2text.html');
-echo Horde_Text_Filter::filter($html, 'html2text', array('charset' => 'UTF-8'));
+echo Horde_Text_Filter::filter($html, 'Html2text', array('charset' => 'UTF-8'));
 
 ?>
 --EXPECT--
index 34dbd18..d766b75 100644 (file)
@@ -17,9 +17,9 @@ $html = <<<EOT
 </ul>
 EOT;
 
-echo Horde_Text_Filter::filter($html, 'html2text', array('width' => 50));
+echo Horde_Text_Filter::filter($html, 'Html2text', array('wrap' => 50));
 echo "\n\n";
-echo Horde_Text_Filter::filter($html, 'html2text', array('wrap' => false));
+echo Horde_Text_Filter::filter($html, 'Html2text', array('wrap' => false));
 
 ?>
 --EXPECT--
index 3270f72..483674a 100644 (file)
@@ -636,7 +636,7 @@ if (!is_null($oldrtemode) && ($oldrtemode != $rtemode)) {
                            array('<p>&nbsp;</p>', '<p><!--begin_signature-->' . $imp_compose->text2html($sig) . '<!--end_signature--></p>'),
                            $msg);
     } else {
-        $msg = Horde_Text_Filter::filter($msg, 'html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false));
+        $msg = Horde_Text_Filter::filter($msg, 'Html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false));
     }
 }
 
index 5f08e10..6a24a62 100644 (file)
@@ -883,7 +883,7 @@ class IMP_Ajax_Application extends Horde_Ajax_Application_Base
         $result = new stdClass;
         // Need to replace line endings or else IE won't display line endings
         // properly.
-        $result->text = str_replace("\n", "\r\n", Horde_Text_Filter::filter($this->_vars->text, 'html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false)));
+        $result->text = str_replace("\n", "\r\n", Horde_Text_Filter::filter($this->_vars->text, 'Html2text', array('charset' => Horde_Nls::getCharset())));
 
         return $result;
     }
index 7af8d7e..b6b61b3 100644 (file)
@@ -1045,7 +1045,7 @@ class IMP_Compose
 
         if (!empty($options['html'])) {
             $body_html = $body;
-            $body = Horde_Text_Filter::filter($body, 'html2text', array('wrap' => false, 'charset' => $charset));
+            $body = Horde_Text_Filter::filter($body, 'Html2text', array('wrap' => false, 'charset' => $charset));
         }
 
         /* Get trailer message (if any). */
index f8969e4..6a41ca2 100644 (file)
@@ -558,7 +558,7 @@ class IMP_Contents
         $ptext = $pmime->getContents();
         $ptext = Horde_String::convertCharset($ptext, $pmime->getCharset());
         if ($pmime->getType() == 'text/html') {
-            $ptext = Horde_Text_Filter::filter($ptext, 'html2text', array('charset' => Horde_Nls::getCharset()));
+            $ptext = Horde_Text_Filter::filter($ptext, 'Html2text', array('charset' => Horde_Nls::getCharset()));
         }
 
         $this->_build = $oldbuild;
index 8c96231..ce9c7fb 100644 (file)
@@ -179,7 +179,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
          * text. */
         if (($_SESSION['imp']['view'] == 'mimp') ||
             (!$inline && Horde_Util::getFormData('convert_text'))) {
-            $data = Horde_Text_Filter::filter($data, 'html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false));
+            $data = Horde_Text_Filter::filter($data, 'Html2text', array('charset' => Horde_Nls::getCharset(), 'wrap' => false));
 
             // Filter bad language.
             return array(
index ffc3397..81f9af3 100644 (file)
@@ -39,7 +39,7 @@ $name = Horde_Util::getFormData('name', '');
 $type = Horde_Util::getFormData('type', 'plain');
 if (!empty($last_type) && $last_type != $type) {
     $content = ($type == 'plain')
-        ? Horde_Text_Filter::filter($content, 'html2text', array('charset' => Horde_Nls::getCharset()))
+        ? Horde_Text_Filter::filter($content, 'Html2text', array('charset' => Horde_Nls::getCharset()))
         : nl2br(htmlspecialchars(htmlspecialchars($content)));
 }
 $stationery = array('n' => $name, 't' => $type, 'c' => $content);