From a07a670b86c2a5d7c611d903ffbd516f99f30ee7 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 4 Mar 2010 22:58:16 -0700 Subject: [PATCH] Merge width & wrap options for Html2text; use correct case for driver name --- framework/Mime/lib/Horde/Mime/Mail.php | 2 +- framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php | 10 ++++------ framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt | 2 +- framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt | 4 ++-- imp/compose.php | 2 +- imp/lib/Ajax/Application.php | 2 +- imp/lib/Compose.php | 2 +- imp/lib/Contents.php | 2 +- imp/lib/Mime/Viewer/Html.php | 2 +- imp/stationery.php | 2 +- 10 files changed, 14 insertions(+), 16 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Mail.php b/framework/Mime/lib/Horde/Mime/Mail.php index 720d42628..42feafeca 100644 --- a/framework/Mime/lib/Horde/Mime/Mail.php +++ b/framework/Mime/lib/Horde/Mime/Mail.php @@ -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); } } diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php index 593ad3039..382c0ab7b 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -5,8 +5,7 @@ * Parameters: *
  * 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.
  * 
* * 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'])))); diff --git a/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt b/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt index 2a63a9d09..30d596496 100644 --- a/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt +++ b/framework/Text_Filter/test/Horde/Text/Filter/html2text.phpt @@ -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-- diff --git a/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt b/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt index 34dbd1872..d766b758a 100644 --- a/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt +++ b/framework/Text_Filter/test/Horde/Text/Filter/html2text2.phpt @@ -17,9 +17,9 @@ $html = << 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-- diff --git a/imp/compose.php b/imp/compose.php index 3270f7222..483674a89 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -636,7 +636,7 @@ if (!is_null($oldrtemode) && ($oldrtemode != $rtemode)) { array('

 

', '

' . $imp_compose->text2html($sig) . '

'), $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)); } } diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 5f08e10de..6a24a629d 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -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; } diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 7af8d7ecd..b6b61b3ed 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -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). */ diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index f8969e4c0..6a41ca283 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -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; diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index 8c9623132..ce9c7fb77 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -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( diff --git a/imp/stationery.php b/imp/stationery.php index ffc3397ae..81f9af3f0 100644 --- a/imp/stationery.php +++ b/imp/stationery.php @@ -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); -- 2.11.0