From: Michael M Slusarz Date: Wed, 10 Feb 2010 19:20:03 +0000 (-0700) Subject: Improvements to the Html2Text filter. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ff2e1dc60e9e3f6c4adba4d1fb446b57ccc7a89f;p=horde.git Improvements to the Html2Text filter. --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php index bfaf9e47d..f1fbe6f74 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php @@ -18,13 +18,17 @@ * * @author Jon Abernathy * @author Jan Schneider + * @author Michael Slusarz * @package Horde_Text */ class Horde_Text_Filter_Html2text extends Horde_Text_Filter { - /* TODO */ - static public $linkList; - static public $linkCount; + /** + * The list of links contained in the message. + * + * @var array + */ + protected $_linkList = array(); /** * Filter parameters. @@ -38,7 +42,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter ); /** - * Executes any code necessaray before applying the filter patterns. + * Executes any code necessary before applying the filter patterns. * * @param string $text The text before the filtering. * @@ -50,8 +54,7 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter $this->_params['charset'] = isset($GLOBALS['_HORDE_STRING_CHARSET']) ? $GLOBALS['_HORDE_STRING_CHARSET'] : 'ISO-8859-1'; } - self::$linkList = ''; - self::$linkCount = 0; + $this->_linkList = array(); return trim($text); } @@ -63,93 +66,92 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter */ public function getPatterns() { - $regexp = array( + $replace = array( // Non-legal carriage return. - '/\r/' => '', - - // Leading and trailing whitespace. - '/^\s*(.*?)\s*$/m' => '\1', - - // Normalize
. - '/]*>([^\n]*)\n/i' => "
\\1", + '/\r/' => '' + ); + $regexp = array( // Newlines and tabs. '/[\n\t]+/' => ' ', //