From: Chuck Hagenbuch Date: Thu, 16 Jul 2009 03:39:58 +0000 (-0400) Subject: these are stream filters, so put them in a Horde_Stream_Filter package instead of... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d8751362c943c07438a1e804b6559f4af193fb8f;p=horde.git these are stream filters, so put them in a Horde_Stream_Filter package instead of in Util:: --- diff --git a/framework/Mime/lib/Horde/Mime/Part.php b/framework/Mime/lib/Horde/Mime/Part.php index d659922ea..e60bd54d1 100644 --- a/framework/Mime/lib/Horde/Mime/Part.php +++ b/framework/Mime/lib/Horde/Mime/Part.php @@ -1155,7 +1155,7 @@ class Horde_Mime_Part $fp = $this->_writeStream($text); - stream_filter_register('horde_eol', 'Horde_Util_Filter_Eol'); + stream_filter_register('horde_eol', 'Horde_Stream_Filter_Eol'); stream_filter_append($fp, 'horde_eol', STREAM_FILTER_READ, array('eol' => $eol)); return $stream ? $fp : $this->_readStream($fp, true); diff --git a/framework/Stream_Filter/lib/Horde/Stream/Filter/Eol.php b/framework/Stream_Filter/lib/Horde/Stream/Filter/Eol.php new file mode 100644 index 000000000..ee031ad1f --- /dev/null +++ b/framework/Stream_Filter/lib/Horde/Stream/Filter/Eol.php @@ -0,0 +1,56 @@ + + * 'eol' - The EOL string to use. + * DEFAULT: ("\r\n") + * + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Michael Slusarz + * @package Horde_Stream_Filter + */ +class Horde_Stream_Filter_Eol extends php_user_filter +{ + protected $_search; + protected $_replace; + + public function onCreate() + { + $eol = isset($this->params['eol']) ? $this->params['eol'] : "\r\n"; + if (!strlen($eol)) { + $this->_search = array("\r", "\n"); + $this->_replace = ''; + } elseif (in_array($eol, array("\r", "\n"))) { + $this->_search = array("\r\n", ($eol == "\r") ? "\n" : "\r"); + $this->_replace = $eol; + } else { + $this->_search = array("\r\n", "\r", "\n"); + $this->_replace = array("\n", "\n", $eol); + } + + return true; + } + + public function filter($in, $out, &$consumed, $closing) + { + while ($bucket = stream_bucket_make_writeable($in)) { + $bucket->data = str_replace($this->_search, $this->_replace, $bucket->data); + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + + return PSFS_PASS_ON; + } + +} diff --git a/framework/Stream_Filter/package.xml b/framework/Stream_Filter/package.xml new file mode 100644 index 000000000..f6a208ba8 --- /dev/null +++ b/framework/Stream_Filter/package.xml @@ -0,0 +1,70 @@ + + + Stream_Filter + pear.horde.org + Horde Stream filters + This package provides various stream filters. + + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + + Jan Schneider + jan + jan@horde.org + yes + + + Michael Slusarz + slusarz + slusarz@horde.org + yes + + 2009-07-08 + + 0.1.0 + 0.1.0 + + + beta + beta + + LGPL + * Initial release. + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.7.0 + + + + + + + + + + diff --git a/framework/Stream_Filter/test/Horde/Stream/Filter/AllTests.php b/framework/Stream_Filter/test/Horde/Stream/Filter/AllTests.php new file mode 100644 index 000000000..a004b7494 --- /dev/null +++ b/framework/Stream_Filter/test/Horde/Stream/Filter/AllTests.php @@ -0,0 +1,62 @@ +isFile() && preg_match('/Test.php$/', $file->getFilename())) { + $pathname = $file->getPathname(); + require $pathname; + + $class = str_replace(DIRECTORY_SEPARATOR, '_', + preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname)); + $suite->addTestSuite('Horde_Stream_Filter_' . $class); + } + } + + return $suite; + } + +} + +if (PHPUnit_MAIN_METHOD == 'Horde_Stream_Filter_AllTests::main') { + Horde_Stream_Filter_AllTests::main(); +} diff --git a/framework/Stream_Filter/test/Horde/Stream/Filter/EolTest.php b/framework/Stream_Filter/test/Horde/Stream/Filter/EolTest.php new file mode 100644 index 000000000..d8acfe41d --- /dev/null +++ b/framework/Stream_Filter/test/Horde/Stream/Filter/EolTest.php @@ -0,0 +1,66 @@ +/** + * @package Horde_Stream_Filter + * @subpackage UnitTests + */ +--TEST-- +Horde_Stream_Filter_Eol:: tests +--FILE-- + $val)); + rewind($test); + fpassthru($test); + stream_filter_remove($filter); + + echo "\n---\n"; +} + +fclose($test); +?> +--EXPECT-- +A B C D E F G H I +--- +A +B +C +D + +E + +F + +G + + +H + + +I +--- +A +B +C +D + +E + +F + +G + + +H + + +I +--- +ABCDEFGHI +--- diff --git a/framework/Util/lib/Horde/Util/Filter/Eol.php b/framework/Util/lib/Horde/Util/Filter/Eol.php deleted file mode 100644 index b2f02f7ff..000000000 --- a/framework/Util/lib/Horde/Util/Filter/Eol.php +++ /dev/null @@ -1,56 +0,0 @@ - - * 'eol' - The EOL string to use. - * DEFAULT: ("\r\n") - * - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @author Michael Slusarz - * @package Horde_Util - */ -class Horde_Util_Filter_Eol extends php_user_filter -{ - protected $_search; - protected $_replace; - - public function onCreate() - { - $eol = isset($this->params['eol']) ? $this->params['eol'] : "\r\n"; - if (!strlen($eol)) { - $this->_search = array("\r", "\n"); - $this->_replace = ''; - } elseif (in_array($eol, array("\r", "\n"))) { - $this->_search = array("\r\n", ($eol == "\r") ? "\n" : "\r"); - $this->_replace = $eol; - } else { - $this->_search = array("\r\n", "\r", "\n"); - $this->_replace = array("\n", "\n", $eol); - } - - return true; - } - - public function filter($in, $out, &$consumed, $closing) - { - while ($bucket = stream_bucket_make_writeable($in)) { - $bucket->data = str_replace($this->_search, $this->_replace, $bucket->data); - $consumed += $bucket->datalen; - stream_bucket_append($out, $bucket); - } - - return PSFS_PASS_ON; - } - -} diff --git a/framework/Util/package.xml b/framework/Util/package.xml index fa2fe8d54..595c00e86 100644 --- a/framework/Util/package.xml +++ b/framework/Util/package.xml @@ -29,7 +29,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta LGPL - * Added Horde_Util_Filter_Eol. + * Removed Horde_Array::combine() and Horde_Util::hmac(). * Initial Horde 4 package. @@ -42,11 +42,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - @@ -61,7 +56,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - @@ -103,7 +97,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - diff --git a/framework/Util/test/Horde/Util/eol_filter.phpt b/framework/Util/test/Horde/Util/eol_filter.phpt deleted file mode 100644 index b2f55824e..000000000 --- a/framework/Util/test/Horde/Util/eol_filter.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -Horde_Util_Filter_Eol:: tests ---FILE-- - $val)); - rewind($test); - fpassthru($test); - stream_filter_remove($filter); - - echo "\n---\n"; -} - -fclose($test); -?> ---EXPECT-- -A B C D E F G H I ---- -A -B -C -D - -E - -F - -G - - -H - - -I ---- -A -B -C -D - -E - -F - -G - - -H - - -I ---- -ABCDEFGHI ----