From 17ae1c2b05b36989a41514433592b0588d08c060 Mon Sep 17 00:00:00 2001 From: robocoder <anthon.pang@gmail.com> Date: Fri, 2 Jul 2010 23:15:33 +0000 Subject: [PATCH] refs #1449 - remove Zend_Filter ... not going to use it in #1442 git-svn-id: http://dev.piwik.org/svn/trunk@2416 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- libs/Zend/Filter.php | 239 ---- libs/Zend/Filter/Alnum.php | 146 --- libs/Zend/Filter/Alpha.php | 146 --- libs/Zend/Filter/BaseName.php | 50 - libs/Zend/Filter/Boolean.php | 375 ------ libs/Zend/Filter/Callback.php | 152 --- libs/Zend/Filter/Compress.php | 197 --- libs/Zend/Filter/Compress/Bz2.php | 188 --- .../Zend/Filter/Compress/CompressAbstract.php | 89 -- .../Filter/Compress/CompressInterface.php | 54 - libs/Zend/Filter/Compress/Gz.php | 228 ---- libs/Zend/Filter/Compress/Lzf.php | 91 -- libs/Zend/Filter/Compress/Rar.php | 252 ---- libs/Zend/Filter/Compress/Tar.php | 245 ---- libs/Zend/Filter/Compress/Zip.php | 355 ------ libs/Zend/Filter/Decompress.php | 49 - libs/Zend/Filter/Decrypt.php | 49 - libs/Zend/Filter/Digits.php | 82 -- libs/Zend/Filter/Dir.php | 50 - libs/Zend/Filter/Encrypt.php | 138 -- libs/Zend/Filter/Encrypt/Interface.php | 47 - libs/Zend/Filter/Encrypt/Mcrypt.php | 312 ----- libs/Zend/Filter/Encrypt/Openssl.php | 353 ------ libs/Zend/Filter/Exception.php | 37 - libs/Zend/Filter/File/Decrypt.php | 106 -- libs/Zend/Filter/File/Encrypt.php | 106 -- libs/Zend/Filter/File/LowerCase.php | 84 -- libs/Zend/Filter/File/Rename.php | 304 ----- libs/Zend/Filter/File/UpperCase.php | 84 -- libs/Zend/Filter/HtmlEntities.php | 202 --- libs/Zend/Filter/Inflector.php | 527 -------- libs/Zend/Filter/Input.php | 1126 ----------------- libs/Zend/Filter/Int.php | 50 - libs/Zend/Filter/Interface.php | 40 - libs/Zend/Filter/LocalizedToNormalized.php | 112 -- libs/Zend/Filter/NormalizedToLocalized.php | 111 -- libs/Zend/Filter/Null.php | 183 --- libs/Zend/Filter/PregReplace.php | 174 --- libs/Zend/Filter/RealPath.php | 134 -- libs/Zend/Filter/StringToLower.php | 117 -- libs/Zend/Filter/StringToUpper.php | 117 -- libs/Zend/Filter/StringTrim.php | 124 -- libs/Zend/Filter/StripNewlines.php | 48 - libs/Zend/Filter/StripTags.php | 345 ----- libs/Zend/Filter/Word/CamelCaseToDash.php | 44 - .../Zend/Filter/Word/CamelCaseToSeparator.php | 49 - .../Filter/Word/CamelCaseToUnderscore.php | 44 - libs/Zend/Filter/Word/DashToCamelCase.php | 44 - libs/Zend/Filter/Word/DashToSeparator.php | 42 - libs/Zend/Filter/Word/DashToUnderscore.php | 45 - libs/Zend/Filter/Word/Separator/Abstract.php | 76 -- .../Zend/Filter/Word/SeparatorToCamelCase.php | 52 - libs/Zend/Filter/Word/SeparatorToDash.php | 46 - .../Zend/Filter/Word/SeparatorToSeparator.php | 129 -- .../Filter/Word/UnderscoreToCamelCase.php | 44 - libs/Zend/Filter/Word/UnderscoreToDash.php | 45 - .../Filter/Word/UnderscoreToSeparator.php | 45 - 57 files changed, 8723 deletions(-) delete mode 100644 libs/Zend/Filter.php delete mode 100644 libs/Zend/Filter/Alnum.php delete mode 100644 libs/Zend/Filter/Alpha.php delete mode 100644 libs/Zend/Filter/BaseName.php delete mode 100644 libs/Zend/Filter/Boolean.php delete mode 100644 libs/Zend/Filter/Callback.php delete mode 100644 libs/Zend/Filter/Compress.php delete mode 100644 libs/Zend/Filter/Compress/Bz2.php delete mode 100644 libs/Zend/Filter/Compress/CompressAbstract.php delete mode 100644 libs/Zend/Filter/Compress/CompressInterface.php delete mode 100644 libs/Zend/Filter/Compress/Gz.php delete mode 100644 libs/Zend/Filter/Compress/Lzf.php delete mode 100644 libs/Zend/Filter/Compress/Rar.php delete mode 100644 libs/Zend/Filter/Compress/Tar.php delete mode 100644 libs/Zend/Filter/Compress/Zip.php delete mode 100644 libs/Zend/Filter/Decompress.php delete mode 100644 libs/Zend/Filter/Decrypt.php delete mode 100644 libs/Zend/Filter/Digits.php delete mode 100644 libs/Zend/Filter/Dir.php delete mode 100644 libs/Zend/Filter/Encrypt.php delete mode 100644 libs/Zend/Filter/Encrypt/Interface.php delete mode 100644 libs/Zend/Filter/Encrypt/Mcrypt.php delete mode 100644 libs/Zend/Filter/Encrypt/Openssl.php delete mode 100644 libs/Zend/Filter/Exception.php delete mode 100644 libs/Zend/Filter/File/Decrypt.php delete mode 100644 libs/Zend/Filter/File/Encrypt.php delete mode 100644 libs/Zend/Filter/File/LowerCase.php delete mode 100644 libs/Zend/Filter/File/Rename.php delete mode 100644 libs/Zend/Filter/File/UpperCase.php delete mode 100644 libs/Zend/Filter/HtmlEntities.php delete mode 100644 libs/Zend/Filter/Inflector.php delete mode 100644 libs/Zend/Filter/Input.php delete mode 100644 libs/Zend/Filter/Int.php delete mode 100644 libs/Zend/Filter/Interface.php delete mode 100644 libs/Zend/Filter/LocalizedToNormalized.php delete mode 100644 libs/Zend/Filter/NormalizedToLocalized.php delete mode 100644 libs/Zend/Filter/Null.php delete mode 100644 libs/Zend/Filter/PregReplace.php delete mode 100644 libs/Zend/Filter/RealPath.php delete mode 100644 libs/Zend/Filter/StringToLower.php delete mode 100644 libs/Zend/Filter/StringToUpper.php delete mode 100644 libs/Zend/Filter/StringTrim.php delete mode 100644 libs/Zend/Filter/StripNewlines.php delete mode 100644 libs/Zend/Filter/StripTags.php delete mode 100644 libs/Zend/Filter/Word/CamelCaseToDash.php delete mode 100644 libs/Zend/Filter/Word/CamelCaseToSeparator.php delete mode 100644 libs/Zend/Filter/Word/CamelCaseToUnderscore.php delete mode 100644 libs/Zend/Filter/Word/DashToCamelCase.php delete mode 100644 libs/Zend/Filter/Word/DashToSeparator.php delete mode 100644 libs/Zend/Filter/Word/DashToUnderscore.php delete mode 100644 libs/Zend/Filter/Word/Separator/Abstract.php delete mode 100644 libs/Zend/Filter/Word/SeparatorToCamelCase.php delete mode 100644 libs/Zend/Filter/Word/SeparatorToDash.php delete mode 100644 libs/Zend/Filter/Word/SeparatorToSeparator.php delete mode 100644 libs/Zend/Filter/Word/UnderscoreToCamelCase.php delete mode 100644 libs/Zend/Filter/Word/UnderscoreToDash.php delete mode 100644 libs/Zend/Filter/Word/UnderscoreToSeparator.php diff --git a/libs/Zend/Filter.php b/libs/Zend/Filter.php deleted file mode 100644 index 585f07fb6d..0000000000 --- a/libs/Zend/Filter.php +++ /dev/null @@ -1,239 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Filter.php 21097 2010-02-19 20:11:34Z thomas $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter implements Zend_Filter_Interface -{ - - const CHAIN_APPEND = 'append'; - const CHAIN_PREPEND = 'prepend'; - - /** - * Filter chain - * - * @var array - */ - protected $_filters = array(); - - /** - * Default Namespaces - * - * @var array - */ - protected static $_defaultNamespaces = array(); - - /** - * Adds a filter to the chain - * - * @param Zend_Filter_Interface $filter - * @param string $placement - * @return Zend_Filter Provides a fluent interface - */ - public function addFilter(Zend_Filter_Interface $filter, $placement = self::CHAIN_APPEND) - { - if ($placement == self::CHAIN_PREPEND) { - array_unshift($this->_filters, $filter); - } else { - $this->_filters[] = $filter; - } - return $this; - } - - /** - * Add a filter to the end of the chain - * - * @param Zend_Filter_Interface $filter - * @return Zend_Filter Provides a fluent interface - */ - public function appendFilter(Zend_Filter_Interface $filter) - { - return $this->addFilter($filter, self::CHAIN_APPEND); - } - - /** - * Add a filter to the start of the chain - * - * @param Zend_Filter_Interface $filter - * @return Zend_Filter Provides a fluent interface - */ - public function prependFilter(Zend_Filter_Interface $filter) - { - return $this->addFilter($filter, self::CHAIN_PREPEND); - } - - /** - * Get all the filters - * - * @return array - */ - public function getFilters() - { - return $this->_filters; - } - - /** - * Returns $value filtered through each filter in the chain - * - * Filters are run in the order in which they were added to the chain (FIFO) - * - * @param mixed $value - * @return mixed - */ - public function filter($value) - { - $valueFiltered = $value; - foreach ($this->_filters as $filter) { - $valueFiltered = $filter->filter($valueFiltered); - } - return $valueFiltered; - } - - /** - * Returns the set default namespaces - * - * @return array - */ - public static function getDefaultNamespaces() - { - return self::$_defaultNamespaces; - } - - /** - * Sets new default namespaces - * - * @param array|string $namespace - * @return null - */ - public static function setDefaultNamespaces($namespace) - { - if (!is_array($namespace)) { - $namespace = array((string) $namespace); - } - - self::$_defaultNamespaces = $namespace; - } - - /** - * Adds a new default namespace - * - * @param array|string $namespace - * @return null - */ - public static function addDefaultNamespaces($namespace) - { - if (!is_array($namespace)) { - $namespace = array((string) $namespace); - } - - self::$_defaultNamespaces = array_unique(array_merge(self::$_defaultNamespaces, $namespace)); - } - - /** - * Returns true when defaultNamespaces are set - * - * @return boolean - */ - public static function hasDefaultNamespaces() - { - return (!empty(self::$_defaultNamespaces)); - } - - /** - * @deprecated - * @see Zend_Filter::filterStatic() - * - * @param mixed $value - * @param string $classBaseName - * @param array $args OPTIONAL - * @param array|string $namespaces OPTIONAL - * @return mixed - * @throws Zend_Filter_Exception - */ - public static function get($value, $classBaseName, array $args = array(), $namespaces = array()) - { - trigger_error( - 'Zend_Filter::get() is deprecated as of 1.9.0; please update your code to utilize Zend_Filter::filterStatic()', - E_USER_NOTICE - ); - - return self::filterStatic($value, $classBaseName, $args, $namespaces); - } - - /** - * Returns a value filtered through a specified filter class, without requiring separate - * instantiation of the filter object. - * - * The first argument of this method is a data input value, that you would have filtered. - * The second argument is a string, which corresponds to the basename of the filter class, - * relative to the Zend_Filter namespace. This method automatically loads the class, - * creates an instance, and applies the filter() method to the data input. You can also pass - * an array of constructor arguments, if they are needed for the filter class. - * - * @param mixed $value - * @param string $classBaseName - * @param array $args OPTIONAL - * @param array|string $namespaces OPTIONAL - * @return mixed - * @throws Zend_Filter_Exception - */ - public static function filterStatic($value, $classBaseName, array $args = array(), $namespaces = array()) - { - // require_once 'Zend/Loader.php'; - $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Filter')); - foreach ($namespaces as $namespace) { - $className = $namespace . '_' . ucfirst($classBaseName); - // if (!class_exists($className, false)) { - // try { - // $file = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - // if (Zend_Loader::isReadable($file)) { - // Zend_Loader::loadClass($className); - // } else { - // continue; - // } - // } catch (Zend_Exception $ze) { - // continue; - // } - // } - - $class = new ReflectionClass($className); - if ($class->implementsInterface('Zend_Filter_Interface')) { - if ($class->hasMethod('__construct')) { - $object = $class->newInstanceArgs($args); - } else { - $object = $class->newInstance(); - } - return $object->filter($value); - } - } - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Filter class not found from basename '$classBaseName'"); - } -} diff --git a/libs/Zend/Filter/Alnum.php b/libs/Zend/Filter/Alnum.php deleted file mode 100644 index 8a6ad4a0e5..0000000000 --- a/libs/Zend/Filter/Alnum.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Alnum.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; -/** - * @see Zend_Locale - */ -// require_once 'Zend/Locale.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Alnum implements Zend_Filter_Interface -{ - /** - * Whether to allow white space characters; off by default - * - * @var boolean - * @deprecated - */ - public $allowWhiteSpace; - - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Locale in browser. - * - * @var Zend_Locale object - */ - protected $_locale; - - /** - * The Alphabet means english alphabet. - * - * @var boolean - */ - protected static $_meansEnglishAlphabet; - - /** - * Sets default option values for this instance - * - * @param boolean $allowWhiteSpace - * @return void - */ - public function __construct($allowWhiteSpace = false) - { - if ($allowWhiteSpace instanceof Zend_Config) { - $allowWhiteSpace = $allowWhiteSpace->toArray(); - } else if (is_array($allowWhiteSpace)) { - if (array_key_exists('allowwhitespace', $allowWhiteSpace)) { - $allowWhiteSpace = $allowWhiteSpace['allowwhitespace']; - } else { - $allowWhiteSpace = false; - } - } - - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - - if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja', 'ko', 'zh') - ); - } - - } - - /** - * Returns the allowWhiteSpace option - * - * @return boolean - */ - public function getAllowWhiteSpace() - { - return $this->allowWhiteSpace; - } - - /** - * Sets the allowWhiteSpace option - * - * @param boolean $allowWhiteSpace - * @return Zend_Filter_Alnum Provides a fluent interface - */ - public function setAllowWhiteSpace($allowWhiteSpace) - { - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, removing all but alphabetic and digit characters - * - * @param string $value - * @return string - */ - public function filter($value) - { - $whiteSpace = $this->allowWhiteSpace ? '\s' : ''; - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z0-9 match - $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/'; - } else if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - $pattern = '/[^a-zA-Z0-9' . $whiteSpace . ']/u'; - } else { - //The Alphabet means each language's alphabet. - $pattern = '/[^\p{L}\p{N}' . $whiteSpace . ']/u'; - } - - return preg_replace($pattern, '', (string) $value); - } -} diff --git a/libs/Zend/Filter/Alpha.php b/libs/Zend/Filter/Alpha.php deleted file mode 100644 index cdb01e1660..0000000000 --- a/libs/Zend/Filter/Alpha.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Alpha.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; -/** - * @see Zend_Locale - */ -// require_once 'Zend/Locale.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Alpha implements Zend_Filter_Interface -{ - /** - * Whether to allow white space characters; off by default - * - * @var boolean - * @deprecated - */ - public $allowWhiteSpace; - - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Locale in browser. - * - * @var Zend_Locale object - */ - protected $_locale; - - /** - * The Alphabet means english alphabet. - * - * @var boolean - */ - protected static $_meansEnglishAlphabet; - - /** - * Sets default option values for this instance - * - * @param boolean $allowWhiteSpace - * @return void - */ - public function __construct($allowWhiteSpace = false) - { - if ($allowWhiteSpace instanceof Zend_Config) { - $allowWhiteSpace = $allowWhiteSpace->toArray(); - } else if (is_array($allowWhiteSpace)) { - if (array_key_exists('allowwhitespace', $allowWhiteSpace)) { - $allowWhiteSpace = $allowWhiteSpace['allowwhitespace']; - } else { - $allowWhiteSpace = false; - } - } - - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - - if (null === self::$_meansEnglishAlphabet) { - $this->_locale = new Zend_Locale('auto'); - self::$_meansEnglishAlphabet = in_array($this->_locale->getLanguage(), - array('ja', 'ko', 'zh') - ); - } - - } - - /** - * Returns the allowWhiteSpace option - * - * @return boolean - */ - public function getAllowWhiteSpace() - { - return $this->allowWhiteSpace; - } - - /** - * Sets the allowWhiteSpace option - * - * @param boolean $allowWhiteSpace - * @return Zend_Filter_Alpha Provides a fluent interface - */ - public function setAllowWhiteSpace($allowWhiteSpace) - { - $this->allowWhiteSpace = (boolean) $allowWhiteSpace; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, removing all but alphabetic characters - * - * @param string $value - * @return string - */ - public function filter($value) - { - $whiteSpace = $this->allowWhiteSpace ? '\s' : ''; - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative a-zA-Z match - $pattern = '/[^a-zA-Z' . $whiteSpace . ']/'; - } else if (self::$_meansEnglishAlphabet) { - //The Alphabet means english alphabet. - $pattern = '/[^a-zA-Z' . $whiteSpace . ']/u'; - } else { - //The Alphabet means each language's alphabet. - $pattern = '/[^\p{L}' . $whiteSpace . ']/u'; - } - - return preg_replace($pattern, '', (string) $value); - } -} diff --git a/libs/Zend/Filter/BaseName.php b/libs/Zend/Filter/BaseName.php deleted file mode 100644 index aad6a7b78e..0000000000 --- a/libs/Zend/Filter/BaseName.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: BaseName.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_BaseName implements Zend_Filter_Interface -{ - /** - * Defined by Zend_Filter_Interface - * - * Returns basename($value) - * - * @param string $value - * @return string - */ - public function filter($value) - { - return basename((string) $value); - } -} diff --git a/libs/Zend/Filter/Boolean.php b/libs/Zend/Filter/Boolean.php deleted file mode 100644 index e697f064bb..0000000000 --- a/libs/Zend/Filter/Boolean.php +++ /dev/null @@ -1,375 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id:$ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Boolean implements Zend_Filter_Interface -{ - const BOOLEAN = 1; - const INTEGER = 2; - const FLOAT = 4; - const STRING = 8; - const ZERO = 16; - const EMPTY_ARRAY = 32; - const NULL = 64; - const PHP = 127; - const FALSE_STRING = 128; - const YES = 256; - const ALL = 511; - - protected $_constants = array( - self::BOOLEAN => 'boolean', - self::INTEGER => 'integer', - self::FLOAT => 'float', - self::STRING => 'string', - self::ZERO => 'zero', - self::EMPTY_ARRAY => 'array', - self::NULL => 'null', - self::PHP => 'php', - self::FALSE_STRING => 'false', - self::YES => 'yes', - self::ALL => 'all', - ); - - /** - * Internal type to detect - * - * @var integer - */ - protected $_type = self::PHP; - - /** - * Internal locale - * - * @var array - */ - protected $_locale = array('auto'); - - /** - * Internal mode - * - * @var boolean - */ - protected $_casting = true; - - /** - * Constructor - * - * @param string|array|Zend_Config $options OPTIONAL - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - if (!empty($options)) { - $temp['type'] = array_shift($options); - } - - if (!empty($options)) { - $temp['casting'] = array_shift($options); - } - - if (!empty($options)) { - $temp['locale'] = array_shift($options); - } - - $options = $temp; - } - - if (array_key_exists('type', $options)) { - $this->setType($options['type']); - } - - if (array_key_exists('casting', $options)) { - $this->setCasting($options['casting']); - } - - if (array_key_exists('locale', $options)) { - $this->setLocale($options['locale']); - } - } - - /** - * Returns the set null types - * - * @return int - */ - public function getType() - { - return $this->_type; - } - - /** - * Set the null types - * - * @param integer|array $type - * @throws Zend_Filter_Exception - * @return Zend_Filter_Boolean - */ - public function setType($type = null) - { - if (is_array($type)) { - $detected = 0; - foreach($type as $value) { - if (is_int($value)) { - $detected += $value; - } elseif (in_array($value, $this->_constants)) { - $detected += array_search($value, $this->_constants); - } - } - - $type = $detected; - } elseif (is_string($type) && in_array($type, $this->_constants)) { - $type = array_search($type, $this->_constants); - } - - if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Unknown type'); - } - - $this->_type = $type; - return $this; - } - - /** - * Returns the set locale - * - * @return array - */ - public function getLocale() - { - return $this->_locale; - } - - /** - * Set the locales which are accepted - * - * @param string|array|Zend_Locale $locale - * @throws Zend_Filter_Exception - * @return Zend_Filter_Boolean - */ - public function setLocale($locale = null) - { - if (is_string($locale)) { - $locale = array($locale); - } elseif ($locale instanceof Zend_Locale) { - $locale = array($locale->toString()); - } elseif (!is_array($locale)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Locale has to be string, array or an instance of Zend_Locale'); - } - - // require_once 'Zend/Locale.php'; - foreach ($locale as $single) { - if (!Zend_Locale::isLocale($single)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Unknown locale '$single'"); - } - } - - $this->_locale = $locale; - return $this; - } - - /** - * Returns the casting option - * - * @return boolean - */ - public function getCasting() - { - return $this->_casting; - } - - /** - * Set the working mode - * - * @param boolean $locale When true this filter works like cast - * When false it recognises only true and false - * and all other values are returned as is - * @throws Zend_Filter_Exception - * @return Zend_Filter_Boolean - */ - public function setCasting($casting = true) - { - $this->_casting = (boolean) $casting; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns a boolean representation of $value - * - * @param string $value - * @return string - */ - public function filter($value) - { - $type = $this->getType(); - $casting = $this->getCasting(); - - // STRING YES (Localized) - if ($type >= self::YES) { - $type -= self::YES; - if (is_string($value)) { - // require_once 'Zend/Locale.php'; - $locales = $this->getLocale(); - foreach ($locales as $locale) { - if ($this->_getLocalizedQuestion($value, false, $locale) === false) { - return false; - } - - if (!$casting && ($this->_getLocalizedQuestion($value, true, $locale) === true)) { - return true; - } - } - } - } - - // STRING FALSE ('false') - if ($type >= self::FALSE_STRING) { - $type -= self::FALSE_STRING; - if (is_string($value) && (strtolower($value) == 'false')) { - return false; - } - - if ((!$casting) && is_string($value) && (strtolower($value) == 'true')) { - return true; - } - } - - // NULL (null) - if ($type >= self::NULL) { - $type -= self::NULL; - if (is_null($value)) { - return false; - } - } - - // EMPTY_ARRAY (array()) - if ($type >= self::EMPTY_ARRAY) { - $type -= self::EMPTY_ARRAY; - if (is_array($value) && ($value == array())) { - return false; - } - } - - // ZERO ('0') - if ($type >= self::ZERO) { - $type -= self::ZERO; - if (is_string($value) && ($value == '0')) { - return false; - } - - if ((!$casting) && (is_string($value)) && ($value == '1')) { - return true; - } - } - - // STRING ('') - if ($type >= self::STRING) { - $type -= self::STRING; - if (is_string($value) && ($value == '')) { - return false; - } - } - - // FLOAT (0.0) - if ($type >= self::FLOAT) { - $type -= self::FLOAT; - if (is_float($value) && ($value == 0.0)) { - return false; - } - - if ((!$casting) && is_float($value) && ($value == 1.0)) { - return true; - } - } - - // INTEGER (0) - if ($type >= self::INTEGER) { - $type -= self::INTEGER; - if (is_int($value) && ($value == 0)) { - return false; - } - - if ((!$casting) && is_int($value) && ($value == 1)) { - return true; - } - } - - // BOOLEAN (false) - if ($type >= self::BOOLEAN) { - $type -= self::BOOLEAN; - if (is_bool($value)) { - return $value; - } - } - - if ($casting) { - return true; - } - - return $value; - } - - /** - * Determine the value of a localized string, and compare it to a given value - * - * @param string $value - * @param boolean $yes - * @param array $locale - * @return boolean - */ - protected function _getLocalizedQuestion($value, $yes, $locale) - { - if ($yes == true) { - $question = 'yes'; - $return = true; - } else { - $question = 'no'; - $return = false; - } - $str = Zend_Locale::getTranslation($question, 'question', $locale); - $str = explode(':', $str); - if (!empty($str)) { - foreach($str as $no) { - if (($no == $value) || (strtolower($no) == strtolower($value))) { - return $return; - } - } - } - } -} diff --git a/libs/Zend/Filter/Callback.php b/libs/Zend/Filter/Callback.php deleted file mode 100644 index ee091427ba..0000000000 --- a/libs/Zend/Filter/Callback.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Callback.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Callback implements Zend_Filter_Interface -{ - /** - * Callback in a call_user_func format - * - * @var string|array - */ - protected $_callback = null; - - /** - * Default options to set for the filter - * - * @var mixed - */ - protected $_options = null; - - /** - * Constructor - * - * @param string|array $callback Callback in a call_user_func format - * @param mixed $options (Optional) Default options for this filter - */ - public function __construct($options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options) || !array_key_exists('callback', $options)) { - $options = func_get_args(); - $temp['callback'] = array_shift($options); - if (!empty($options)) { - $temp['options'] = array_shift($options); - } - - $options = $temp; - } - - if (!array_key_exists('callback', $options)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Missing callback to use'); - } - - $this->setCallback($options['callback']); - if (array_key_exists('options', $options)) { - $this->setOptions($options['options']); - } - } - - /** - * Returns the set callback - * - * @return string|array Set callback - */ - public function getCallback() - { - return $this->_callback; - } - - /** - * Sets a new callback for this filter - * - * @param unknown_type $callback - * @return unknown - */ - public function setCallback($callback, $options = null) - { - if (!is_callable($callback)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Callback can not be accessed'); - } - - $this->_callback = $callback; - $this->setOptions($options); - return $this; - } - - /** - * Returns the set default options - * - * @return mixed - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets new default options to the callback filter - * - * @param mixed $options Default options to set - * @return Zend_Filter_Callback - */ - public function setOptions($options) - { - $this->_options = $options; - return $this; - } - - /** - * Calls the filter per callback - * - * @param $value mixed Options for the set callback - * @return mixed Result from the filter which was callbacked - */ - public function filter($value) - { - $options = array(); - - if ($this->_options !== null) { - if (!is_array($this->_options)) { - $options = array($this->_options); - } else { - $options = $this->_options; - } - } - - array_unshift($options, $value); - - return call_user_func_array($this->_callback, $options); - } -} \ No newline at end of file diff --git a/libs/Zend/Filter/Compress.php b/libs/Zend/Filter/Compress.php deleted file mode 100644 index 3fbb78e087..0000000000 --- a/libs/Zend/Filter/Compress.php +++ /dev/null @@ -1,197 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Compress.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * Compresses a given string - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress implements Zend_Filter_Interface -{ - /** - * Compression adapter - */ - protected $_adapter = 'Gz'; - - /** - * Compression adapter constructor options - */ - protected $_adapterOptions = array(); - - /** - * Class constructor - * - * @param string|array $options (Optional) Options to set - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - if (is_string($options)) { - $this->setAdapter($options); - } elseif ($options instanceof Zend_Filter_Compress_CompressInterface) { - $this->setAdapter($options); - } elseif (is_array($options)) { - $this->setOptions($options); - } - } - - /** - * Set filter setate - * - * @param array $options - * @return Zend_Filter_Compress - */ - public function setOptions(array $options) - { - foreach ($options as $key => $value) { - if ($key == 'options') { - $key = 'adapterOptions'; - } - $method = 'set' . ucfirst($key); - if (method_exists($this, $method)) { - $this->$method($value); - } - } - return $this; - } - - /** - * Returns the current adapter, instantiating it if necessary - * - * @return string - */ - public function getAdapter() - { - if ($this->_adapter instanceof Zend_Filter_Compress_CompressInterface) { - return $this->_adapter; - } - - $adapter = $this->_adapter; - $options = $this->getAdapterOptions(); - // if (!class_exists($adapter)) { - // require_once 'Zend/Loader.php'; - // if (Zend_Loader::isReadable('Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) { - // $adapter = 'Zend_Filter_Compress_' . ucfirst($adapter); - // } - // Zend_Loader::loadClass($adapter); - // } - - $this->_adapter = new $adapter($options); - if (!$this->_adapter instanceof Zend_Filter_Compress_CompressInterface) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Compression adapter '" . $adapter . "' does not implement Zend_Filter_Compress_CompressInterface"); - } - return $this->_adapter; - } - - /** - * Retrieve adapter name - * - * @return string - */ - public function getAdapterName() - { - return $this->getAdapter()->toString(); - } - - /** - * Sets compression adapter - * - * @param string|Zend_Filter_Compress_CompressInterface $adapter Adapter to use - * @return Zend_Filter_Compress - */ - public function setAdapter($adapter) - { - if ($adapter instanceof Zend_Filter_Compress_CompressInterface) { - $this->_adapter = $adapter; - return $this; - } - if (!is_string($adapter)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Invalid adapter provided; must be string or instance of Zend_Filter_Compress_CompressInterface'); - } - $this->_adapter = $adapter; - - return $this; - } - - /** - * Retrieve adapter options - * - * @return array - */ - public function getAdapterOptions() - { - return $this->_adapterOptions; - } - - /** - * Set adapter options - * - * @param array $options - * @return void - */ - public function setAdapterOptions(array $options) - { - $this->_adapterOptions = $options; - return $this; - } - - /** - * Calls adapter methods - * - * @param string $method Method to call - * @param string|array $options Options for this method - */ - public function __call($method, $options) - { - $adapter = $this->getAdapter(); - if (!method_exists($adapter, $method)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Unknown method '{$method}'"); - } - - return call_user_func_array(array($adapter, $method), $options); - } - - /** - * Defined by Zend_Filter_Interface - * - * Compresses the content $value with the defined settings - * - * @param string $value Content to compress - * @return string The compressed content - */ - public function filter($value) - { - return $this->getAdapter()->compress($value); - } -} diff --git a/libs/Zend/Filter/Compress/Bz2.php b/libs/Zend/Filter/Compress/Bz2.php deleted file mode 100644 index 8241a08991..0000000000 --- a/libs/Zend/Filter/Compress/Bz2.php +++ /dev/null @@ -1,188 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Bz2.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressAbstract - */ -// require_once 'Zend/Filter/Compress/CompressAbstract.php'; - -/** - * Compression adapter for Bz2 - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Bz2 extends Zend_Filter_Compress_CompressAbstract -{ - /** - * Compression Options - * array( - * 'blocksize' => Blocksize to use from 0-9 - * 'archive' => Archive to use - * ) - * - * @var array - */ - protected $_options = array( - 'blocksize' => 4, - 'archive' => null, - ); - - /** - * Class constructor - * - * @param array|Zend_Config $options (Optional) Options to set - */ - public function __construct($options = null) - { - if (!extension_loaded('bz2')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the bz2 extension'); - } - parent::__construct($options); - } - - /** - * Returns the set blocksize - * - * @return integer - */ - public function getBlocksize() - { - return $this->_options['blocksize']; - } - - /** - * Sets a new blocksize - * - * @param integer $level - * @return Zend_Filter_Compress_Bz2 - */ - public function setBlocksize($blocksize) - { - if (($blocksize < 0) || ($blocksize > 9)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Blocksize must be between 0 and 9'); - } - - $this->_options['blocksize'] = (int) $blocksize; - return $this; - } - - /** - * Returns the set archive - * - * @return string - */ - public function getArchive() - { - return $this->_options['archive']; - } - - /** - * Sets the archive to use for de-/compression - * - * @param string $archive Archive to use - * @return Zend_Filter_Compress_Bz2 - */ - public function setArchive($archive) - { - $this->_options['archive'] = (string) $archive; - return $this; - } - - /** - * Compresses the given content - * - * @param string $content - * @return string - */ - public function compress($content) - { - $archive = $this->getArchive(); - if (!empty($archive)) { - $file = bzopen($archive, 'w'); - if (!$file) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'"); - } - - bzwrite($file, $content); - bzclose($file); - $compressed = true; - } else { - $compressed = bzcompress($content, $this->getBlocksize()); - } - - if (is_int($compressed)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during compression'); - } - - return $compressed; - } - - /** - * Decompresses the given content - * - * @param string $content - * @return string - */ - public function decompress($content) - { - $archive = $this->getArchive(); - if (file_exists($content)) { - $archive = $content; - } - - if (file_exists($archive)) { - $file = bzopen($archive, 'r'); - if (!$file) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error opening the archive '" . $content . "'"); - } - - $compressed = bzread($file); - bzclose($file); - } else { - $compressed = bzdecompress($content); - } - - if (is_int($compressed)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during decompression'); - } - - return $compressed; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Bz2'; - } -} diff --git a/libs/Zend/Filter/Compress/CompressAbstract.php b/libs/Zend/Filter/Compress/CompressAbstract.php deleted file mode 100644 index 692aee4f09..0000000000 --- a/libs/Zend/Filter/Compress/CompressAbstract.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CompressAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressInterface - */ -// require_once 'Zend/Filter/Compress/CompressInterface.php'; - -/** - * Abstract compression adapter - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Filter_Compress_CompressAbstract implements Zend_Filter_Compress_CompressInterface -{ - /** - * Class constructor - * - * @param array|Zend_Config $options (Optional) Options to set - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - if (is_array($options)) { - $this->setOptions($options); - } - } - - /** - * Returns one or all set options - * - * @param string $option (Optional) Option to return - * @return mixed - */ - public function getOptions($option = null) - { - if ($option === null) { - return $this->_options; - } - - if (!array_key_exists($option, $this->_options)) { - return null; - } - - return $this->_options[$option]; - } - - /** - * Sets all or one option - * - * @param array $options - * @return Zend_Filter_Compress_Bz2 - */ - public function setOptions(array $options) - { - foreach ($options as $key => $option) { - $method = 'set' . $key; - if (method_exists($this, $method)) { - $this->$method($option); - } - } - - return $this; - } -} diff --git a/libs/Zend/Filter/Compress/CompressInterface.php b/libs/Zend/Filter/Compress/CompressInterface.php deleted file mode 100644 index 2503398811..0000000000 --- a/libs/Zend/Filter/Compress/CompressInterface.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CompressInterface.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * Compression interface - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Filter_Compress_CompressInterface -{ - /** - * Compresses $value with the defined settings - * - * @param string $value Data to compress - * @return string The compressed data - */ - public function compress($value); - - /** - * Decompresses $value with the defined settings - * - * @param string $value Data to decompress - * @return string The decompressed data - */ - public function decompress($value); - - /** - * Return the adapter name - * - * @return string - */ - public function toString(); -} diff --git a/libs/Zend/Filter/Compress/Gz.php b/libs/Zend/Filter/Compress/Gz.php deleted file mode 100644 index 8ad8378275..0000000000 --- a/libs/Zend/Filter/Compress/Gz.php +++ /dev/null @@ -1,228 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Gz.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressAbstract - */ -// require_once 'Zend/Filter/Compress/CompressAbstract.php'; - -/** - * Compression adapter for Gzip (ZLib) - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Gz extends Zend_Filter_Compress_CompressAbstract -{ - /** - * Compression Options - * array( - * 'level' => Compression level 0-9 - * 'mode' => Compression mode, can be 'compress', 'deflate' - * 'archive' => Archive to use - * ) - * - * @var array - */ - protected $_options = array( - 'level' => 9, - 'mode' => 'compress', - 'archive' => null, - ); - - /** - * Class constructor - * - * @param array|Zend_Config|null $options (Optional) Options to set - */ - public function __construct($options = null) - { - if (!extension_loaded('zlib')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the zlib extension'); - } - parent::__construct($options); - } - - /** - * Returns the set compression level - * - * @return integer - */ - public function getLevel() - { - return $this->_options['level']; - } - - /** - * Sets a new compression level - * - * @param integer $level - * @return Zend_Filter_Compress_Gz - */ - public function setLevel($level) - { - if (($level < 0) || ($level > 9)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Level must be between 0 and 9'); - } - - $this->_options['level'] = (int) $level; - return $this; - } - - /** - * Returns the set compression mode - * - * @return string - */ - public function getMode() - { - return $this->_options['mode']; - } - - /** - * Sets a new compression mode - * - * @param string $mode Supported are 'compress', 'deflate' and 'file' - */ - public function setMode($mode) - { - if (($mode != 'compress') && ($mode != 'deflate')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Given compression mode not supported'); - } - - $this->_options['mode'] = $mode; - return $this; - } - - /** - * Returns the set archive - * - * @return string - */ - public function getArchive() - { - return $this->_options['archive']; - } - - /** - * Sets the archive to use for de-/compression - * - * @param string $archive Archive to use - * @return Zend_Filter_Compress_Gz - */ - public function setArchive($archive) - { - $this->_options['archive'] = (string) $archive; - return $this; - } - - /** - * Compresses the given content - * - * @param string $content - * @return string - */ - public function compress($content) - { - $archive = $this->getArchive(); - if (!empty($archive)) { - $file = gzopen($archive, 'w' . $this->getLevel()); - if (!$file) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error opening the archive '" . $this->_options['archive'] . "'"); - } - - gzwrite($file, $content); - gzclose($file); - $compressed = true; - } else if ($this->_options['mode'] == 'deflate') { - $compressed = gzdeflate($content, $this->getLevel()); - } else { - $compressed = gzcompress($content, $this->getLevel()); - } - - if (!$compressed) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during compression'); - } - - return $compressed; - } - - /** - * Decompresses the given content - * - * @param string $content - * @return string - */ - public function decompress($content) - { - $archive = $this->getArchive(); - $mode = $this->getMode(); - if (file_exists($content)) { - $archive = $content; - } - - if (file_exists($archive)) { - $handler = fopen($archive, "rb"); - if (!$handler) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error opening the archive '" . $archive . "'"); - } - - fseek($handler, -4, SEEK_END); - $packet = fread($handler, 4); - $bytes = unpack("V", $packet); - $size = end($bytes); - fclose($handler); - - $file = gzopen($archive, 'r'); - $compressed = gzread($file, $size); - gzclose($file); - } else if ($mode == 'deflate') { - $compressed = gzinflate($content); - } else { - $compressed = gzuncompress($content); - } - - if (!$compressed) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during compression'); - } - - return $compressed; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Gz'; - } -} diff --git a/libs/Zend/Filter/Compress/Lzf.php b/libs/Zend/Filter/Compress/Lzf.php deleted file mode 100644 index e81e1a7b62..0000000000 --- a/libs/Zend/Filter/Compress/Lzf.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Lzf.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressInterface - */ -// require_once 'Zend/Filter/Compress/CompressInterface.php'; - -/** - * Compression adapter for Lzf - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Lzf implements Zend_Filter_Compress_CompressInterface -{ - /** - * Class constructor - */ - public function __construct() - { - if (!extension_loaded('lzf')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the lzf extension'); - } - } - - /** - * Compresses the given content - * - * @param string $content - * @return string - */ - public function compress($content) - { - $compressed = lzf_compress($content); - if (!$compressed) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during compression'); - } - - return $compressed; - } - - /** - * Decompresses the given content - * - * @param string $content - * @return string - */ - public function decompress($content) - { - $compressed = lzf_decompress($content); - if (!$compressed) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error during compression'); - } - - return $compressed; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Lzf'; - } -} diff --git a/libs/Zend/Filter/Compress/Rar.php b/libs/Zend/Filter/Compress/Rar.php deleted file mode 100644 index 35c67719dc..0000000000 --- a/libs/Zend/Filter/Compress/Rar.php +++ /dev/null @@ -1,252 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rar.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressAbstract - */ -// require_once 'Zend/Filter/Compress/CompressAbstract.php'; - -/** - * Compression adapter for Rar - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Rar extends Zend_Filter_Compress_CompressAbstract -{ - /** - * Compression Options - * array( - * 'callback' => Callback for compression - * 'archive' => Archive to use - * 'password' => Password to use - * 'target' => Target to write the files to - * ) - * - * @var array - */ - protected $_options = array( - 'callback' => null, - 'archive' => null, - 'password' => null, - 'target' => '.', - ); - - /** - * Class constructor - * - * @param array $options (Optional) Options to set - */ - public function __construct($options = null) - { - if (!extension_loaded('rar')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the rar extension'); - } - parent::__construct($options); - } - - /** - * Returns the set callback for compression - * - * @return string - */ - public function getCallback() - { - return $this->_options['callback']; - } - - /** - * Sets the callback to use - * - * @param string $callback - * @return Zend_Filter_Compress_Rar - */ - public function setCallback($callback) - { - if (!is_callable($callback)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Callback can not be accessed'); - } - - $this->_options['callback'] = $callback; - return $this; - } - - /** - * Returns the set archive - * - * @return string - */ - public function getArchive() - { - return $this->_options['archive']; - } - - /** - * Sets the archive to use for de-/compression - * - * @param string $archive Archive to use - * @return Zend_Filter_Compress_Rar - */ - public function setArchive($archive) - { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); - $this->_options['archive'] = (string) $archive; - - return $this; - } - - /** - * Returns the set password - * - * @return string - */ - public function getPassword() - { - return $this->_options['password']; - } - - /** - * Sets the password to use - * - * @param string $password - * @return Zend_Filter_Compress_Rar - */ - public function setPassword($password) - { - $this->_options['password'] = (string) $password; - return $this; - } - - /** - * Returns the set targetpath - * - * @return string - */ - public function getTarget() - { - return $this->_options['target']; - } - - /** - * Sets the targetpath to use - * - * @param string $target - * @return Zend_Filter_Compress_Rar - */ - public function setTarget($target) - { - if (!file_exists(dirname($target))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The directory '$target' does not exist"); - } - - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); - $this->_options['target'] = (string) $target; - return $this; - } - - /** - * Compresses the given content - * - * @param string|array $content - * @return string - */ - public function compress($content) - { - $callback = $this->getCallback(); - if (is_null($callback)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('No compression callback available'); - } - - $options = $this->getOptions(); - unset($options['callback']); - - $result = call_user_func($callback, $options, $content); - if ($result !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error compressing the RAR Archive'); - } - - return $this->getArchive(); - } - - /** - * Decompresses the given content - * - * @param string $content - * @return boolean - */ - public function decompress($content) - { - $archive = $this->getArchive(); - if (file_exists($content)) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content)); - } elseif (empty($archive) || !file_exists($archive)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('RAR Archive not found'); - } - - $password = $this->getPassword(); - if (!is_null($password)) { - $archive = rar_open($archive, $password); - } else { - $archive = rar_open($archive); - } - - if (!$archive) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error opening the RAR Archive"); - } - - $target = $this->getTarget(); - if (!is_dir($target)) { - $target = dirname($target); - } - - $filelist = rar_list($archive); - if (!$filelist) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Error reading the RAR Archive"); - } - - foreach($filelist as $file) { - $file->extract($target); - } - - rar_close($archive); - return true; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Rar'; - } -} diff --git a/libs/Zend/Filter/Compress/Tar.php b/libs/Zend/Filter/Compress/Tar.php deleted file mode 100644 index 4d865aafa8..0000000000 --- a/libs/Zend/Filter/Compress/Tar.php +++ /dev/null @@ -1,245 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Tar.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress_CompressAbstract - */ -// require_once 'Zend/Filter/Compress/CompressAbstract.php'; - -/** - * Compression adapter for Tar - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Tar extends Zend_Filter_Compress_CompressAbstract -{ - /** - * Compression Options - * array( - * 'archive' => Archive to use - * 'target' => Target to write the files to - * ) - * - * @var array - */ - protected $_options = array( - 'archive' => null, - 'target' => '.', - 'mode' => null, - ); - - /** - * Class constructor - * - * @param array $options (Optional) Options to set - */ - public function __construct($options = null) - { - // if (!class_exists('Archive_Tar')) { - // require_once 'Zend/Loader.php'; - // try { - // Zend_Loader::loadClass('Archive_Tar'); - // } catch (Zend_Exception $e) { - // require_once 'Zend/Filter/Exception.php'; - // throw new Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e); - // } - // } - - parent::__construct($options); - } - - /** - * Returns the set archive - * - * @return string - */ - public function getArchive() - { - return $this->_options['archive']; - } - - /** - * Sets the archive to use for de-/compression - * - * @param string $archive Archive to use - * @return Zend_Filter_Compress_Tar - */ - public function setArchive($archive) - { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); - $this->_options['archive'] = (string) $archive; - - return $this; - } - - /** - * Returns the set targetpath - * - * @return string - */ - public function getTarget() - { - return $this->_options['target']; - } - - /** - * Sets the targetpath to use - * - * @param string $target - * @return Zend_Filter_Compress_Tar - */ - public function setTarget($target) - { - if (!file_exists(dirname($target))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The directory '$target' does not exist"); - } - - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); - $this->_options['target'] = (string) $target; - return $this; - } - - /** - * Returns the set compression mode - */ - public function getMode() - { - return $this->_options['mode']; - } - - /** - * Compression mode to use - * Eighter Gz or Bz2 - * - * @param string $mode - */ - public function setMode($mode) - { - $mode = ucfirst(strtolower($mode)); - if (($mode != 'Bz2') && ($mode != 'Gz')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The mode '$mode' is unknown"); - } - - if (($mode == 'Bz2') && (!extension_loaded('bz2'))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This mode needs the bz2 extension'); - } - - if (($mode == 'Gz') && (!extension_loaded('zlib'))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This mode needs the zlib extension'); - } - } - - /** - * Compresses the given content - * - * @param string $content - * @return string - */ - public function compress($content) - { - $archive = new Archive_Tar($this->getArchive(), $this->getMode()); - if (!file_exists($content)) { - $file = $this->getTarget(); - if (is_dir($file)) { - $file .= DIRECTORY_SEPARATOR . "tar.tmp"; - } - - $result = file_put_contents($file, $content); - if ($result === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error creating the temporary file'); - } - - $content = $file; - } - - if (is_dir($content)) { - // collect all file infos - foreach (new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($content, RecursiveDirectoryIterator::KEY_AS_PATHNAME), - RecursiveIteratorIterator::SELF_FIRST - ) as $directory => $info - ) { - if ($info->isFile()) { - $file[] = $directory; - } - } - - $content = $file; - } - - $result = $archive->create($content); - if ($result === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error creating the Tar archive'); - } - - return $this->getArchive(); - } - - /** - * Decompresses the given content - * - * @param string $content - * @return boolean - */ - public function decompress($content) - { - $archive = $this->getArchive(); - if (file_exists($content)) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content)); - } elseif (empty($archive) || !file_exists($archive)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Tar Archive not found'); - } - - $archive = new Archive_Tar($archive, $this->getMode()); - $target = $this->getTarget(); - if (!is_dir($target)) { - $target = dirname($target); - } - - $result = $archive->extract($target); - if ($result === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Error while extracting the Tar archive'); - } - - return true; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Tar'; - } -} diff --git a/libs/Zend/Filter/Compress/Zip.php b/libs/Zend/Filter/Compress/Zip.php deleted file mode 100644 index a99fce786b..0000000000 --- a/libs/Zend/Filter/Compress/Zip.php +++ /dev/null @@ -1,355 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Zip.php 20126 2010-01-07 18:10:58Z ralph $ - */ - -/** - * @see Zend_Filter_Compress_CompressAbstract - */ -// require_once 'Zend/Filter/Compress/CompressAbstract.php'; - -/** - * Compression adapter for zip - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Compress_Zip extends Zend_Filter_Compress_CompressAbstract -{ - /** - * Compression Options - * array( - * 'archive' => Archive to use - * 'password' => Password to use - * 'target' => Target to write the files to - * ) - * - * @var array - */ - protected $_options = array( - 'archive' => null, - 'target' => null, - ); - - /** - * Class constructor - * - * @param string|array $options (Optional) Options to set - */ - public function __construct($options = null) - { - if (!extension_loaded('zip')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the zip extension'); - } - parent::__construct($options); - } - - /** - * Returns the set archive - * - * @return string - */ - public function getArchive() - { - return $this->_options['archive']; - } - - /** - * Sets the archive to use for de-/compression - * - * @param string $archive Archive to use - * @return Zend_Filter_Compress_Rar - */ - public function setArchive($archive) - { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $archive); - $this->_options['archive'] = (string) $archive; - - return $this; - } - - /** - * Returns the set targetpath - * - * @return string - */ - public function getTarget() - { - return $this->_options['target']; - } - - /** - * Sets the target to use - * - * @param string $target - * @return Zend_Filter_Compress_Rar - */ - public function setTarget($target) - { - if (!file_exists(dirname($target))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The directory '$target' does not exist"); - } - - $target = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $target); - $this->_options['target'] = (string) $target; - return $this; - } - - /** - * Compresses the given content - * - * @param string $content - * @return string Compressed archive - */ - public function compress($content) - { - $zip = new ZipArchive(); - $res = $zip->open($this->getArchive(), ZipArchive::CREATE | ZipArchive::OVERWRITE); - - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - - if (file_exists($content)) { - $content = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content)); - $basename = substr($content, strrpos($content, DIRECTORY_SEPARATOR) + 1); - if (is_dir($content)) { - $index = strrpos($content, DIRECTORY_SEPARATOR) + 1; - $content .= DIRECTORY_SEPARATOR; - $stack = array($content); - while (!empty($stack)) { - $current = array_pop($stack); - $files = array(); - - $dir = dir($current); - while (false !== ($node = $dir->read())) { - if (($node == '.') || ($node == '..')) { - continue; - } - - if (is_dir($current . $node)) { - array_push($stack, $current . $node . DIRECTORY_SEPARATOR); - } - - if (is_file($current . $node)) { - $files[] = $node; - } - } - - $local = substr($current, $index); - $zip->addEmptyDir(substr($local, 0, -1)); - - foreach ($files as $file) { - $zip->addFile($current . $file, $local . $file); - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - } - } - } else { - $res = $zip->addFile($content, $basename); - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - } - } else { - $file = $this->getTarget(); - if (!is_dir($file)) { - $file = basename($file); - } else { - $file = "zip.tmp"; - } - - $res = $zip->addFromString($file, $content); - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - } - - $zip->close(); - return $this->_options['archive']; - } - - /** - * Decompresses the given content - * - * @param string $content - * @return string - */ - public function decompress($content) - { - $archive = $this->getArchive(); - if (file_exists($content)) { - $archive = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, realpath($content)); - } elseif (empty($archive) || !file_exists($archive)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('ZIP Archive not found'); - } - - $zip = new ZipArchive(); - $res = $zip->open($archive); - - $target = $this->getTarget(); - - if (!empty($target) && !is_dir($target)) { - $target = dirname($target); - } - - if (!empty($target)) { - $target = rtrim($target, '/\\') . DIRECTORY_SEPARATOR; - } - - if (empty($target) || !is_dir($target)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('No target for ZIP decompression set'); - } - - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - - if (version_compare(PHP_VERSION, '5.2.8', '<')) { - for ($i = 0; $i < $zip->numFiles; $i++) { - $statIndex = $zip->statIndex($i); - $currName = $statIndex['name']; - if (($currName{0} == '/') || - (substr($currName, 0, 2) == '..') || - (substr($currName, 0, 4) == './..') - ) - { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Upward directory traversal was detected inside ' . $archive - . ' please use PHP 5.2.8 or greater to take advantage of path resolution features of ' - . 'the zip extension in this decompress() method.' - ); - } - } - } - - $res = @$zip->extractTo($target); - if ($res !== true) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception($this->_errorString($res)); - } - - $zip->close(); - return $target; - } - - /** - * Returns the proper string based on the given error constant - * - * @param string $error - */ - protected function _errorString($error) - { - switch($error) { - case ZipArchive::ER_MULTIDISK : - return 'Multidisk ZIP Archives not supported'; - - case ZipArchive::ER_RENAME : - return 'Failed to rename the temporary file for ZIP'; - - case ZipArchive::ER_CLOSE : - return 'Failed to close the ZIP Archive'; - - case ZipArchive::ER_SEEK : - return 'Failure while seeking the ZIP Archive'; - - case ZipArchive::ER_READ : - return 'Failure while reading the ZIP Archive'; - - case ZipArchive::ER_WRITE : - return 'Failure while writing the ZIP Archive'; - - case ZipArchive::ER_CRC : - return 'CRC failure within the ZIP Archive'; - - case ZipArchive::ER_ZIPCLOSED : - return 'ZIP Archive already closed'; - - case ZipArchive::ER_NOENT : - return 'No such file within the ZIP Archive'; - - case ZipArchive::ER_EXISTS : - return 'ZIP Archive already exists'; - - case ZipArchive::ER_OPEN : - return 'Can not open ZIP Archive'; - - case ZipArchive::ER_TMPOPEN : - return 'Failure creating temporary ZIP Archive'; - - case ZipArchive::ER_ZLIB : - return 'ZLib Problem'; - - case ZipArchive::ER_MEMORY : - return 'Memory allocation problem while working on a ZIP Archive'; - - case ZipArchive::ER_CHANGED : - return 'ZIP Entry has been changed'; - - case ZipArchive::ER_COMPNOTSUPP : - return 'Compression method not supported within ZLib'; - - case ZipArchive::ER_EOF : - return 'Premature EOF within ZIP Archive'; - - case ZipArchive::ER_INVAL : - return 'Invalid argument for ZLIB'; - - case ZipArchive::ER_NOZIP : - return 'Given file is no zip archive'; - - case ZipArchive::ER_INTERNAL : - return 'Internal error while working on a ZIP Archive'; - - case ZipArchive::ER_INCONS : - return 'Inconsistent ZIP archive'; - - case ZipArchive::ER_REMOVE : - return 'Can not remove ZIP Archive'; - - case ZipArchive::ER_DELETED : - return 'ZIP Entry has been deleted'; - - default : - return 'Unknown error within ZIP Archive'; - } - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Zip'; - } -} diff --git a/libs/Zend/Filter/Decompress.php b/libs/Zend/Filter/Decompress.php deleted file mode 100644 index 038f9d6a0e..0000000000 --- a/libs/Zend/Filter/Decompress.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Decompress.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Compress - */ -// require_once 'Zend/Filter/Compress.php'; - -/** - * Decompresses a given string - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Decompress extends Zend_Filter_Compress -{ - /** - * Defined by Zend_Filter_Interface - * - * Decompresses the content $value with the defined settings - * - * @param string $value Content to decompress - * @return string The decompressed content - */ - public function filter($value) - { - return $this->getAdapter()->decompress($value); - } -} diff --git a/libs/Zend/Filter/Decrypt.php b/libs/Zend/Filter/Decrypt.php deleted file mode 100644 index 7d48f495a8..0000000000 --- a/libs/Zend/Filter/Decrypt.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Decrypt.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Encrypt - */ -// require_once 'Zend/Filter/Encrypt.php'; - -/** - * Decrypts a given string - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Decrypt extends Zend_Filter_Encrypt -{ - /** - * Defined by Zend_Filter_Interface - * - * Decrypts the content $value with the defined settings - * - * @param string $value Content to decrypt - * @return string The decrypted content - */ - public function filter($value) - { - return $this->_adapter->decrypt($value); - } -} diff --git a/libs/Zend/Filter/Digits.php b/libs/Zend/Filter/Digits.php deleted file mode 100644 index c21c4f7275..0000000000 --- a/libs/Zend/Filter/Digits.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Digits.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Digits implements Zend_Filter_Interface -{ - /** - * Is PCRE is compiled with UTF-8 and Unicode support - * - * @var mixed - **/ - protected static $_unicodeEnabled; - - /** - * Class constructor - * - * Checks if PCRE is compiled with UTF-8 and Unicode support - * - * @return void - */ - public function __construct() - { - if (null === self::$_unicodeEnabled) { - self::$_unicodeEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, removing all but digit characters - * - * @param string $value - * @return string - */ - public function filter($value) - { - if (!self::$_unicodeEnabled) { - // POSIX named classes are not supported, use alternative 0-9 match - $pattern = '/[^0-9]/'; - } else if (extension_loaded('mbstring')) { - // Filter for the value with mbstring - $pattern = '/[^[:digit:]]/'; - } else { - // Filter for the value without mbstring - $pattern = '/[\p{^N}]/'; - } - - return preg_replace($pattern, '', (string) $value); - } -} diff --git a/libs/Zend/Filter/Dir.php b/libs/Zend/Filter/Dir.php deleted file mode 100644 index d2208651a8..0000000000 --- a/libs/Zend/Filter/Dir.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Dir.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Dir implements Zend_Filter_Interface -{ - /** - * Defined by Zend_Filter_Interface - * - * Returns dirname($value) - * - * @param string $value - * @return string - */ - public function filter($value) - { - return dirname((string) $value); - } -} diff --git a/libs/Zend/Filter/Encrypt.php b/libs/Zend/Filter/Encrypt.php deleted file mode 100644 index 18325bbeb5..0000000000 --- a/libs/Zend/Filter/Encrypt.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Encrypt.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @see Zend_Loader - */ -// require_once 'Zend/Loader.php'; - -/** - * Encrypts a given string - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Encrypt implements Zend_Filter_Interface -{ - /** - * Encryption adapter - */ - protected $_adapter; - - /** - * Class constructor - * - * @param string|array $options (Optional) Options to set, if null mcrypt is used - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - $this->setAdapter($options); - } - - /** - * Returns the name of the set adapter - * - * @return string - */ - public function getAdapter() - { - return $this->_adapter->toString(); - } - - /** - * Sets new encryption options - * - * @param string|array $options (Optional) Encryption options - * @return Zend_Filter_Encrypt - */ - public function setAdapter($options = null) - { - if (is_string($options)) { - $adapter = $options; - } else if (isset($options['adapter'])) { - $adapter = $options['adapter']; - unset($options['adapter']); - } else { - $adapter = 'Mcrypt'; - } - - if (!is_array($options)) { - $options = array(); - } - - if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) { - $adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter); - } - - // if (!class_exists($adapter)) { - // Zend_Loader::loadClass($adapter); - // } - - $this->_adapter = new $adapter($options); - if (!$this->_adapter instanceof Zend_Filter_Encrypt_Interface) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement Zend_Filter_Encrypt_Interface"); - } - - return $this; - } - - /** - * Calls adapter methods - * - * @param string $method Method to call - * @param string|array $options Options for this method - */ - public function __call($method, $options) - { - $part = substr($method, 0, 3); - if ((($part != 'get') and ($part != 'set')) or !method_exists($this->_adapter, $method)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Unknown method '{$method}'"); - } - - return call_user_func_array(array($this->_adapter, $method), $options); - } - - /** - * Defined by Zend_Filter_Interface - * - * Encrypts the content $value with the defined settings - * - * @param string $value Content to encrypt - * @return string The encrypted content - */ - public function filter($value) - { - return $this->_adapter->encrypt($value); - } -} diff --git a/libs/Zend/Filter/Encrypt/Interface.php b/libs/Zend/Filter/Encrypt/Interface.php deleted file mode 100644 index 949d3d6f5a..0000000000 --- a/libs/Zend/Filter/Encrypt/Interface.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * Encryption interface - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Filter_Encrypt_Interface -{ - /** - * Encrypts $value with the defined settings - * - * @param string $value Data to encrypt - * @return string The encrypted data - */ - public function encrypt($value); - - /** - * Decrypts $value with the defined settings - * - * @param string $value Data to decrypt - * @return string The decrypted data - */ - public function decrypt($value); -} diff --git a/libs/Zend/Filter/Encrypt/Mcrypt.php b/libs/Zend/Filter/Encrypt/Mcrypt.php deleted file mode 100644 index 73a9c9cb93..0000000000 --- a/libs/Zend/Filter/Encrypt/Mcrypt.php +++ /dev/null @@ -1,312 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Mcrypt.php 20132 2010-01-07 21:33:50Z ralph $ - */ - -/** - * @see Zend_Filter_Encrypt_Interface - */ -// require_once 'Zend/Filter/Encrypt/Interface.php'; - -/** - * Encryption adapter for mcrypt - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Encrypt_Mcrypt implements Zend_Filter_Encrypt_Interface -{ - /** - * Definitions for encryption - * array( - * 'key' => encryption key string - * 'algorithm' => algorithm to use - * 'algorithm_directory' => directory where to find the algorithm - * 'mode' => encryption mode to use - * 'modedirectory' => directory where to find the mode - * ) - */ - protected $_encryption = array( - 'key' => 'ZendFramework', - 'algorithm' => 'blowfish', - 'algorithm_directory' => '', - 'mode' => 'cbc', - 'mode_directory' => '', - 'vector' => null, - 'salt' => false - ); - - protected static $_srandCalled = false; - - /** - * Class constructor - * - * @param string|array|Zend_Config $options Cryption Options - */ - public function __construct($options) - { - if (!extension_loaded('mcrypt')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the mcrypt extension'); - } - - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (is_string($options)) { - $options = array('key' => $options); - } elseif (!is_array($options)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Invalid options argument provided to filter'); - } - - $this->setEncryption($options); - } - - /** - * Returns the set encryption options - * - * @return array - */ - public function getEncryption() - { - return $this->_encryption; - } - - /** - * Sets new encryption options - * - * @param string|array $options Encryption options - * @return Zend_Filter_File_Encryption - */ - public function setEncryption($options) - { - if (is_string($options)) { - $options = array('key' => $options); - } - - if (!is_array($options)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Invalid options argument provided to filter'); - } - - $options = $options + $this->getEncryption(); - $algorithms = mcrypt_list_algorithms($options['algorithm_directory']); - if (!in_array($options['algorithm'], $algorithms)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The algorithm '{$options['algorithm']}' is not supported"); - } - - $modes = mcrypt_list_modes($options['mode_directory']); - if (!in_array($options['mode'], $modes)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The mode '{$options['mode']}' is not supported"); - } - - if (!mcrypt_module_self_test($options['algorithm'], $options['algorithm_directory'])) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('The given algorithm can not be used due an internal mcrypt problem'); - } - - if (!isset($options['vector'])) { - $options['vector'] = null; - } - - $this->_encryption = $options; - $this->setVector($options['vector']); - - return $this; - } - - /** - * Returns the set vector - * - * @return string - */ - public function getVector() - { - return $this->_encryption['vector']; - } - - /** - * Sets the initialization vector - * - * @param string $vector (Optional) Vector to set - * @return Zend_Filter_Encrypt_Mcrypt - */ - public function setVector($vector = null) - { - $cipher = $this->_openCipher(); - $size = mcrypt_enc_get_iv_size($cipher); - if (empty($vector)) { - $this->_srand(); - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) { - $method = MCRYPT_RAND; - } else { - if (file_exists('/dev/urandom') || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) { - $method = MCRYPT_DEV_URANDOM; - } elseif (file_exists('/dev/random')) { - $method = MCRYPT_DEV_RANDOM; - } else { - $method = MCRYPT_RAND; - } - } - $vector = mcrypt_create_iv($size, $method); - } else if (strlen($vector) != $size) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('The given vector has a wrong size for the set algorithm'); - } - - $this->_encryption['vector'] = $vector; - $this->_closeCipher($cipher); - - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Encrypts the file $value with the defined settings - * - * @param string $value Full path of file to change - * @return string The filename which has been set, or false when there were errors - */ - public function encrypt($value) - { - $cipher = $this->_openCipher(); - $this->_initCipher($cipher); - $encrypted = mcrypt_generic($cipher, $value); - mcrypt_generic_deinit($cipher); - $this->_closeCipher($cipher); - - return $encrypted; - } - - /** - * Defined by Zend_Filter_Interface - * - * Decrypts the file $value with the defined settings - * - * @param string $value Full path of file to change - * @return string The filename which has been set, or false when there were errors - */ - public function decrypt($value) - { - $cipher = $this->_openCipher(); - $this->_initCipher($cipher); - $decrypted = mdecrypt_generic($cipher, $value); - mcrypt_generic_deinit($cipher); - $this->_closeCipher($cipher); - - return $decrypted; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Mcrypt'; - } - - /** - * Open a cipher - * - * @throws Zend_Filter_Exception When the cipher can not be opened - * @return resource Returns the opened cipher - */ - protected function _openCipher() - { - $cipher = mcrypt_module_open( - $this->_encryption['algorithm'], - $this->_encryption['algorithm_directory'], - $this->_encryption['mode'], - $this->_encryption['mode_directory']); - - if ($cipher === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Mcrypt can not be opened with your settings'); - } - - return $cipher; - } - - /** - * Close a cipher - * - * @param resource $cipher Cipher to close - * @return Zend_Filter_Encrypt_Mcrypt - */ - protected function _closeCipher($cipher) - { - mcrypt_module_close($cipher); - - return $this; - } - - /** - * Initialises the cipher with the set key - * - * @param resource $cipher - * @throws - * @return resource - */ - protected function _initCipher($cipher) - { - $key = $this->_encryption['key']; - - $keysizes = mcrypt_enc_get_supported_key_sizes($cipher); - if (empty($keysizes) || ($this->_encryption['salt'] == true)) { - $this->_srand(); - $keysize = mcrypt_enc_get_key_size($cipher); - $key = substr(md5($key), 0, $keysize); - } else if (!in_array(strlen($key), $keysizes)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('The given key has a wrong size for the set algorithm'); - } - - $result = mcrypt_generic_init($cipher, $key, $this->_encryption['vector']); - if ($result < 0) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Mcrypt could not be initialize with the given setting'); - } - - return $this; - } - - /** - * _srand() interception - * - * @see ZF-8742 - */ - protected function _srand() - { - if (version_compare(PHP_VERSION, '5.3.0', '>=')) { - return; - } - - if (!self::$_srandCalled) { - srand((double) microtime() * 1000000); - self::$_srandCalled = true; - } - } -} diff --git a/libs/Zend/Filter/Encrypt/Openssl.php b/libs/Zend/Filter/Encrypt/Openssl.php deleted file mode 100644 index 751d3f7d86..0000000000 --- a/libs/Zend/Filter/Encrypt/Openssl.php +++ /dev/null @@ -1,353 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Openssl.php 20288 2010-01-14 20:15:43Z thomas $ - */ - -/** - * @see Zend_Filter_Encrypt_Interface - */ -// require_once 'Zend/Filter/Encrypt/Interface.php'; - -/** - * Encryption adapter for openssl - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Encrypt_Openssl implements Zend_Filter_Encrypt_Interface -{ - /** - * Definitions for encryption - * array( - * 'public' => public keys - * 'private' => private keys - * 'envelope' => resulting envelope keys - * ) - */ - protected $_keys = array( - 'public' => array(), - 'private' => array(), - 'envelope' => array() - ); - - /** - * Internal passphrase - * - * @var string - */ - protected $_passphrase; - - /** - * Class constructor - * Available options - * 'public' => public key - * 'private' => private key - * 'envelope' => envelope key - * 'passphrase' => passphrase - * - * @param string|array $options Options for this adapter - */ - public function __construct($options = array()) - { - if (!extension_loaded('openssl')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('This filter needs the openssl extension'); - } - - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - if (!is_array($options)) { - $options = array('public' => $options); - } - - if (array_key_exists('passphrase', $options)) { - $this->setPassphrase($options['passphrase']); - unset($options['passphrase']); - } - - $this->_setKeys($options); - } - - /** - * Sets the encryption keys - * - * @param string|array $keys Key with type association - * @return Zend_Filter_Encrypt_Openssl - */ - protected function _setKeys($keys) - { - if (!is_array($keys)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Invalid options argument provided to filter'); - } - - foreach ($keys as $type => $key) { - if (is_file($key) and is_readable($key)) { - $file = fopen($key, 'r'); - $cert = fread($file, 8192); - fclose($file); - } else { - $cert = $key; - $key = count($this->_keys[$type]); - } - - switch ($type) { - case 'public': - $test = openssl_pkey_get_public($cert); - if ($test === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Public key '{$cert}' not valid"); - } - - openssl_free_key($test); - $this->_keys['public'][$key] = $cert; - break; - case 'private': - $test = openssl_pkey_get_private($cert, $this->_passphrase); - if ($test === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Private key '{$cert}' not valid"); - } - - openssl_free_key($test); - $this->_keys['private'][$key] = $cert; - break; - case 'envelope': - $this->_keys['envelope'][$key] = $cert; - break; - default: - break; - } - } - - return $this; - } - - /** - * Returns all public keys - * - * @return array - */ - public function getPublicKey() - { - return $this->_keys['public']; - } - - /** - * Sets public keys - * - * @param string|array $key Public keys - * @return Zend_Filter_Encrypt_Openssl - */ - public function setPublicKey($key) - { - if (is_array($key)) { - foreach($key as $type => $option) { - if ($type !== 'public') { - $key['public'] = $option; - unset($key[$type]); - } - } - } else { - $key = array('public' => $key); - } - - return $this->_setKeys($key); - } - - /** - * Returns all private keys - * - * @return array - */ - public function getPrivateKey() - { - return $this->_keys['private']; - } - - /** - * Sets private keys - * - * @param string $key Private key - * @param string $passphrase - * @return Zend_Filter_Encrypt_Openssl - */ - public function setPrivateKey($key, $passphrase = null) - { - if (is_array($key)) { - foreach($key as $type => $option) { - if ($type !== 'private') { - $key['private'] = $option; - unset($key[$type]); - } - } - } else { - $key = array('private' => $key); - } - - if ($passphrase !== null) { - $this->setPassphrase($passphrase); - } - - return $this->_setKeys($key); - } - - /** - * Returns all envelope keys - * - * @return array - */ - public function getEnvelopeKey() - { - return $this->_keys['envelope']; - } - - /** - * Sets envelope keys - * - * @param string|array $options Envelope keys - * @return Zend_Filter_Encrypt_Openssl - */ - public function setEnvelopeKey($key) - { - if (is_array($key)) { - foreach($key as $type => $option) { - if ($type !== 'envelope') { - $key['envelope'] = $option; - unset($key[$type]); - } - } - } else { - $key = array('envelope' => $key); - } - - return $this->_setKeys($key); - } - - /** - * Returns the passphrase - * - * @return string - */ - public function getPassphrase() - { - return $this->_passphrase; - } - - /** - * Sets a new passphrase - * - * @param string $passphrase - * @return Zend_Filter_Encrypt_Openssl - */ - public function setPassphrase($passphrase) - { - $this->_passphrase = $passphrase; - return $this; - } - - /** - * Encrypts the file $value with the defined settings - * Note that you also need the "encrypted" keys to be able to decrypt - * - * @param string $value Content to encrypt - * @return string The encrypted content - * @throws Zend_Filter_Exception - */ - public function encrypt($value) - { - $encrypted = array(); - $encryptedkeys = array(); - - if (count($this->_keys['public']) == 0) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Openssl can not encrypt without public keys'); - } - - foreach($this->_keys['public'] as $key => $cert) { - $keys[$key] = openssl_pkey_get_public($cert); - } - - $crypt = openssl_seal($value, $encrypted, $encryptedkeys, $keys); - foreach ($keys as $key) { - openssl_free_key($key); - } - - if ($crypt === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Openssl was not able to encrypt you content with the given options'); - } - - $this->_keys['envelope'] = $encryptedkeys; - return $encrypted; - } - - /** - * Defined by Zend_Filter_Interface - * - * Decrypts the file $value with the defined settings - * - * @param string $value Content to decrypt - * @return string The decrypted content - * @throws Zend_Filter_Exception - */ - public function decrypt($value) - { - $decrypted = ""; - $envelope = current($this->getEnvelopeKey()); - - if (count($this->_keys['private']) !== 1) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Openssl can only decrypt with one private key'); - } - - if (empty($envelope)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Openssl can only decrypt with one envelope key'); - } - - foreach($this->_keys['private'] as $key => $cert) { - $keys = openssl_pkey_get_private($cert, $this->getPassphrase()); - } - - $crypt = openssl_open($value, $decrypted, $envelope, $keys); - openssl_free_key($keys); - - if ($crypt === false) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Openssl was not able to decrypt you content with the given options'); - } - - return $decrypted; - } - - /** - * Returns the adapter name - * - * @return string - */ - public function toString() - { - return 'Openssl'; - } -} diff --git a/libs/Zend/Filter/Exception.php b/libs/Zend/Filter/Exception.php deleted file mode 100644 index 97cdb9201e..0000000000 --- a/libs/Zend/Filter/Exception.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Exception - */ -// require_once 'Zend/Exception.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Exception extends Zend_Exception -{} diff --git a/libs/Zend/Filter/File/Decrypt.php b/libs/Zend/Filter/File/Decrypt.php deleted file mode 100644 index b45a802170..0000000000 --- a/libs/Zend/Filter/File/Decrypt.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Decrypt.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Decrypt - */ -// require_once 'Zend/Filter/Decrypt.php'; - -/** - * Decrypts a given file and stores the decrypted file content - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_Decrypt extends Zend_Filter_Decrypt -{ - /** - * New filename to set - * - * @var string - */ - protected $_filename; - - /** - * Returns the new filename where the content will be stored - * - * @return string - */ - public function getFilename() - { - return $this->_filename; - } - - /** - * Sets the new filename where the content will be stored - * - * @param string $filename (Optional) New filename to set - * @return Zend_Filter_File_Encryt - */ - public function setFilename($filename = null) - { - $this->_filename = $filename; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Decrypts the file $value with the defined settings - * - * @param string $value Full path of file to change - * @return string The filename which has been set, or false when there were errors - */ - public function filter($value) - { - if (!file_exists($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' not found"); - } - - if (!isset($this->_filename)) { - $this->_filename = $value; - } - - if (file_exists($this->_filename) and !is_writable($this->_filename)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable"); - } - - $content = file_get_contents($value); - if (!$content) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while reading file '$value'"); - } - - $decrypted = parent::filter($content); - $result = file_put_contents($this->_filename, $decrypted); - - if (!$result) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'"); - } - - return $this->_filename; - } -} diff --git a/libs/Zend/Filter/File/Encrypt.php b/libs/Zend/Filter/File/Encrypt.php deleted file mode 100644 index 6570ce9a92..0000000000 --- a/libs/Zend/Filter/File/Encrypt.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Encrypt.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Encrypt - */ -// require_once 'Zend/Filter/Encrypt.php'; - -/** - * Encrypts a given file and stores the encrypted file content - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_Encrypt extends Zend_Filter_Encrypt -{ - /** - * New filename to set - * - * @var string - */ - protected $_filename; - - /** - * Returns the new filename where the content will be stored - * - * @return string - */ - public function getFilename() - { - return $this->_filename; - } - - /** - * Sets the new filename where the content will be stored - * - * @param string $filename (Optional) New filename to set - * @return Zend_Filter_File_Encryt - */ - public function setFilename($filename = null) - { - $this->_filename = $filename; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Encrypts the file $value with the defined settings - * - * @param string $value Full path of file to change - * @return string The filename which has been set, or false when there were errors - */ - public function filter($value) - { - if (!file_exists($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' not found"); - } - - if (!isset($this->_filename)) { - $this->_filename = $value; - } - - if (file_exists($this->_filename) and !is_writable($this->_filename)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable"); - } - - $content = file_get_contents($value); - if (!$content) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while reading file '$value'"); - } - - $encrypted = parent::filter($content); - $result = file_put_contents($this->_filename, $encrypted); - - if (!$result) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'"); - } - - return $this->_filename; - } -} diff --git a/libs/Zend/Filter/File/LowerCase.php b/libs/Zend/Filter/File/LowerCase.php deleted file mode 100644 index dc3d34444e..0000000000 --- a/libs/Zend/Filter/File/LowerCase.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LowerCase.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_StringToLower - */ -// require_once 'Zend/Filter/StringToLower.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_LowerCase extends Zend_Filter_StringToLower -{ - /** - * Adds options to the filter at initiation - * - * @param string $options - */ - public function __construct($options = null) - { - if (!empty($options)) { - $this->setEncoding($options); - } - } - - /** - * Defined by Zend_Filter_Interface - * - * Does a lowercase on the content of the given file - * - * @param string $value Full path of file to change - * @return string The given $value - * @throws Zend_Filter_Exception - */ - public function filter($value) - { - if (!file_exists($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' not found"); - } - - if (!is_writable($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' is not writable"); - } - - $content = file_get_contents($value); - if (!$content) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while reading file '$value'"); - } - - $content = parent::filter($content); - $result = file_put_contents($value, $content); - - if (!$result) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while writing file '$value'"); - } - - return $value; - } -} diff --git a/libs/Zend/Filter/File/Rename.php b/libs/Zend/Filter/File/Rename.php deleted file mode 100644 index 16aac70f7d..0000000000 --- a/libs/Zend/Filter/File/Rename.php +++ /dev/null @@ -1,304 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rename.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_Rename implements Zend_Filter_Interface -{ - /** - * Internal array of array(source, target, overwrite) - */ - protected $_files = array(); - - /** - * Class constructor - * - * Options argument may be either a string, a Zend_Config object, or an array. - * If an array or Zend_Config object, it accepts the following keys: - * 'source' => Source filename or directory which will be renamed - * 'target' => Target filename or directory, the new name of the sourcefile - * 'overwrite' => Shall existing files be overwritten ? - * - * @param string|array $options Target file or directory to be renamed - * @param string $target Source filename or directory (deprecated) - * @param bool $overwrite Should existing files be overwritten (deprecated) - * @return void - */ - public function __construct($options) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (is_string($options)) { - $options = array('target' => $options); - } elseif (!is_array($options)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Invalid options argument provided to filter'); - } - - if (1 < func_num_args()) { - $argv = func_get_args(); - array_shift($argv); - $source = array_shift($argv); - $overwrite = false; - if (!empty($argv)) { - $overwrite = array_shift($argv); - } - $options['source'] = $source; - $options['overwrite'] = $overwrite; - } - - $this->setFile($options); - } - - /** - * Returns the files to rename and their new name and location - * - * @return array - */ - public function getFile() - { - return $this->_files; - } - - /** - * Sets a new file or directory as target, deleting existing ones - * - * Array accepts the following keys: - * 'source' => Source filename or directory which will be renamed - * 'target' => Target filename or directory, the new name of the sourcefile - * 'overwrite' => Shall existing files be overwritten ? - * - * @param string|array $options Old file or directory to be rewritten - * @return Zend_Filter_File_Rename - */ - public function setFile($options) - { - $this->_files = array(); - $this->addFile($options); - - return $this; - } - - /** - * Adds a new file or directory as target to the existing ones - * - * Array accepts the following keys: - * 'source' => Source filename or directory which will be renamed - * 'target' => Target filename or directory, the new name of the sourcefile - * 'overwrite' => Shall existing files be overwritten ? - * - * @param string|array $options Old file or directory to be rewritten - * @return Zend_Filter_File_Rename - */ - public function addFile($options) - { - if (is_string($options)) { - $options = array('target' => $options); - } elseif (!is_array($options)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception ('Invalid options to rename filter provided'); - } - - $this->_convertOptions($options); - - return $this; - } - - /** - * Returns only the new filename without moving it - * But existing files will be erased when the overwrite option is true - * - * @param string $value Full path of file to change - * @param boolean $source Return internal informations - * @return string The new filename which has been set - */ - public function getNewName($value, $source = false) - { - $file = $this->_getFileName($value); - if ($file['source'] == $file['target']) { - return $value; - } - - if (!file_exists($file['source'])) { - return $value; - } - - if (($file['overwrite'] == true) && (file_exists($file['target']))) { - unlink($file['target']); - } - - if (file_exists($file['target'])) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. It already exists.", $value)); - } - - if ($source) { - return $file; - } - - return $file['target']; - } - - /** - * Defined by Zend_Filter_Interface - * - * Renames the file $value to the new name set before - * Returns the file $value, removing all but digit characters - * - * @param string $value Full path of file to change - * @throws Zend_Filter_Exception - * @return string The new filename which has been set, or false when there were errors - */ - public function filter($value) - { - $file = $this->getNewName($value, true); - if (is_string($file)) { - return $file; - } - - $result = rename($file['source'], $file['target']); - - if ($result === true) { - return $file['target']; - } - - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. An error occured while processing the file.", $value)); - } - - /** - * Internal method for creating the file array - * Supports single and nested arrays - * - * @param array $options - * @return array - */ - protected function _convertOptions($options) { - $files = array(); - foreach ($options as $key => $value) { - if (is_array($value)) { - $this->_convertOptions($value); - continue; - } - - switch ($key) { - case "source": - $files['source'] = (string) $value; - break; - - case 'target' : - $files['target'] = (string) $value; - break; - - case 'overwrite' : - $files['overwrite'] = (boolean) $value; - break; - - default: - break; - } - } - - if (empty($files)) { - return $this; - } - - if (empty($files['source'])) { - $files['source'] = '*'; - } - - if (empty($files['target'])) { - $files['target'] = '*'; - } - - if (empty($files['overwrite'])) { - $files['overwrite'] = false; - } - - $found = false; - foreach ($this->_files as $key => $value) { - if ($value['source'] == $files['source']) { - $this->_files[$key] = $files; - $found = true; - } - } - - if (!$found) { - $count = count($this->_files); - $this->_files[$count] = $files; - } - - return $this; - } - - /** - * Internal method to resolve the requested source - * and return all other related parameters - * - * @param string $file Filename to get the informations for - * @return array - */ - protected function _getFileName($file) - { - $rename = array(); - foreach ($this->_files as $value) { - if ($value['source'] == '*') { - if (!isset($rename['source'])) { - $rename = $value; - $rename['source'] = $file; - } - } - - if ($value['source'] == $file) { - $rename = $value; - } - } - - if (!isset($rename['source'])) { - return $file; - } - - if (!isset($rename['target']) or ($rename['target'] == '*')) { - $rename['target'] = $rename['source']; - } - - if (is_dir($rename['target'])) { - $name = basename($rename['source']); - $last = $rename['target'][strlen($rename['target']) - 1]; - if (($last != '/') and ($last != '\\')) { - $rename['target'] .= DIRECTORY_SEPARATOR; - } - - $rename['target'] .= $name; - } - - return $rename; - } -} diff --git a/libs/Zend/Filter/File/UpperCase.php b/libs/Zend/Filter/File/UpperCase.php deleted file mode 100644 index 636e26c8ff..0000000000 --- a/libs/Zend/Filter/File/UpperCase.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UpperCase.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_StringToUpper - */ -// require_once 'Zend/Filter/StringToUpper.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_File_UpperCase extends Zend_Filter_StringToUpper -{ - /** - * Adds options to the filter at initiation - * - * @param string $options - */ - public function __construct($options = null) - { - if (!empty($options)) { - $this->setEncoding($options); - } - } - - /** - * Defined by Zend_Filter_Interface - * - * Does a lowercase on the content of the given file - * - * @param string $value Full path of file to change - * @return string The given $value - * @throws Zend_Filter_Exception - */ - public function filter($value) - { - if (!file_exists($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' not found"); - } - - if (!is_writable($value)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("File '$value' is not writable"); - } - - $content = file_get_contents($value); - if (!$content) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while reading file '$value'"); - } - - $content = parent::filter($content); - $result = file_put_contents($value, $content); - - if (!$result) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Problem while writing file '$value'"); - } - - return $value; - } -} diff --git a/libs/Zend/Filter/HtmlEntities.php b/libs/Zend/Filter/HtmlEntities.php deleted file mode 100644 index df75999273..0000000000 --- a/libs/Zend/Filter/HtmlEntities.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: HtmlEntities.php 21061 2010-02-15 21:56:54Z thomas $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_HtmlEntities implements Zend_Filter_Interface -{ - /** - * Corresponds to the second htmlentities() argument - * - * @var integer - */ - protected $_quoteStyle; - - /** - * Corresponds to the third htmlentities() argument - * - * @var string - */ - protected $_encoding; - - /** - * Corresponds to the forth htmlentities() argument - * - * @var unknown_type - */ - protected $_doubleQuote; - - /** - * Sets filter options - * - * @param integer|array $quoteStyle - * @param string $charSet - * @return void - */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp['quotestyle'] = array_shift($options); - if (!empty($options)) { - $temp['charset'] = array_shift($options); - } - - $options = $temp; - } - - if (!isset($options['quotestyle'])) { - $options['quotestyle'] = ENT_COMPAT; - } - - if (!isset($options['encoding'])) { - $options['encoding'] = 'UTF-8'; - } - if (isset($options['charset'])) { - $options['encoding'] = $options['charset']; - } - - if (!isset($options['doublequote'])) { - $options['doublequote'] = true; - } - - $this->setQuoteStyle($options['quotestyle']); - $this->setEncoding($options['encoding']); - $this->setDoubleQuote($options['doublequote']); - } - - /** - * Returns the quoteStyle option - * - * @return integer - */ - public function getQuoteStyle() - { - return $this->_quoteStyle; - } - - /** - * Sets the quoteStyle option - * - * @param integer $quoteStyle - * @return Zend_Filter_HtmlEntities Provides a fluent interface - */ - public function setQuoteStyle($quoteStyle) - { - $this->_quoteStyle = $quoteStyle; - return $this; - } - - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string $value - * @return Zend_Filter_HtmlEntities - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } - - /** - * Returns the charSet option - * - * Proxies to {@link getEncoding()} - * - * @return string - */ - public function getCharSet() - { - return $this->getEncoding(); - } - - /** - * Sets the charSet option - * - * Proxies to {@link setEncoding()} - * - * @param string $charSet - * @return Zend_Filter_HtmlEntities Provides a fluent interface - */ - public function setCharSet($charSet) - { - return $this->setEncoding($charSet); - } - - /** - * Returns the doubleQuote option - * - * @return boolean - */ - public function getDoubleQuote() - { - return $this->_doubleQuote; - } - - /** - * Sets the doubleQuote option - * - * @param boolean $doubleQuote - * @return Zend_Filter_HtmlEntities Provides a fluent interface - */ - public function setDoubleQuote($doubleQuote) - { - $this->_doubleQuote = (boolean) $doubleQuote; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, converting characters to their corresponding HTML entity - * equivalents where they exist - * - * @param string $value - * @return string - */ - public function filter($value) - { - return htmlentities((string) $value, $this->getQuoteStyle(), $this->getEncoding(), $this->getDoubleQuote()); - } -} diff --git a/libs/Zend/Filter/Inflector.php b/libs/Zend/Filter/Inflector.php deleted file mode 100644 index 054017ec4d..0000000000 --- a/libs/Zend/Filter/Inflector.php +++ /dev/null @@ -1,527 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Inflector.php 21372 2010-03-07 19:58:08Z thomas $ - */ - -/** - * @see Zend_Filter - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter.php'; - -/** - * @see Zend_Loader_PluginLoader - */ -// require_once 'Zend/Loader/PluginLoader.php'; - -/** - * Filter chain for string inflection - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Inflector implements Zend_Filter_Interface -{ - /** - * @var Zend_Loader_PluginLoader_Interface - */ - protected $_pluginLoader = null; - - /** - * @var string - */ - protected $_target = null; - - /** - * @var bool - */ - protected $_throwTargetExceptionsOn = true; - - /** - * @var string - */ - protected $_targetReplacementIdentifier = ':'; - - /** - * @var array - */ - protected $_rules = array(); - - /** - * Constructor - * - * @param string|array $options Options to set - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - - if (!empty($options)) { - $temp['target'] = array_shift($options); - } - - if (!empty($options)) { - $temp['rules'] = array_shift($options); - } - - if (!empty($options)) { - $temp['throwTargetExceptionsOn'] = array_shift($options); - } - - if (!empty($options)) { - $temp['targetReplacementIdentifier'] = array_shift($options); - } - - $options = $temp; - } - - $this->setOptions($options); - } - - /** - * Retreive PluginLoader - * - * @return Zend_Loader_PluginLoader_Interface - */ - public function getPluginLoader() - { - if (!$this->_pluginLoader instanceof Zend_Loader_PluginLoader_Interface) { - $this->_pluginLoader = new Zend_Loader_PluginLoader(array('Zend_Filter_' => 'Zend/Filter/'), __CLASS__); - } - - return $this->_pluginLoader; - } - - /** - * Set PluginLoader - * - * @param Zend_Loader_PluginLoader_Interface $pluginLoader - * @return Zend_Filter_Inflector - */ - public function setPluginLoader(Zend_Loader_PluginLoader_Interface $pluginLoader) - { - $this->_pluginLoader = $pluginLoader; - return $this; - } - - /** - * Use Zend_Config object to set object state - * - * @deprecated Use setOptions() instead - * @param Zend_Config $config - * @return Zend_Filter_Inflector - */ - public function setConfig(Zend_Config $config) - { - return $this->setOptions($config); - } - - /** - * Set options - * - * @param array $options - * @return Zend_Filter_Inflector - */ - public function setOptions($options) { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - // Set Präfix Path - if (array_key_exists('filterPrefixPath', $options)) { - if (!is_scalar($options['filterPrefixPath'])) { - foreach ($options['filterPrefixPath'] as $prefix => $path) { - $this->addFilterPrefixPath($prefix, $path); - } - } - } - - if (array_key_exists('throwTargetExceptionsOn', $options)) { - $this->setThrowTargetExceptionsOn($options['throwTargetExceptionsOn']); - } - - if (array_key_exists('targetReplacementIdentifier', $options)) { - $this->setTargetReplacementIdentifier($options['targetReplacementIdentifier']); - } - - if (array_key_exists('target', $options)) { - $this->setTarget($options['target']); - } - - if (array_key_exists('rules', $options)) { - $this->addRules($options['rules']); - } - - return $this; - } - - /** - * Convienence method to add prefix and path to PluginLoader - * - * @param string $prefix - * @param string $path - * @return Zend_Filter_Inflector - */ - public function addFilterPrefixPath($prefix, $path) - { - $this->getPluginLoader()->addPrefixPath($prefix, $path); - return $this; - } - - /** - * Set Whether or not the inflector should throw an exception when a replacement - * identifier is still found within an inflected target. - * - * @param bool $throwTargetExceptions - * @return Zend_Filter_Inflector - */ - public function setThrowTargetExceptionsOn($throwTargetExceptionsOn) - { - $this->_throwTargetExceptionsOn = ($throwTargetExceptionsOn == true) ? true : false; - return $this; - } - - /** - * Will exceptions be thrown? - * - * @return bool - */ - public function isThrowTargetExceptionsOn() - { - return $this->_throwTargetExceptionsOn; - } - - /** - * Set the Target Replacement Identifier, by default ':' - * - * @param string $targetReplacementIdentifier - * @return Zend_Filter_Inflector - */ - public function setTargetReplacementIdentifier($targetReplacementIdentifier) - { - if ($targetReplacementIdentifier) { - $this->_targetReplacementIdentifier = (string) $targetReplacementIdentifier; - } - - return $this; - } - - /** - * Get Target Replacement Identifier - * - * @return string - */ - public function getTargetReplacementIdentifier() - { - return $this->_targetReplacementIdentifier; - } - - /** - * Set a Target - * ex: 'scripts/:controller/:action.:suffix' - * - * @param string - * @return Zend_Filter_Inflector - */ - public function setTarget($target) - { - $this->_target = (string) $target; - return $this; - } - - /** - * Retrieve target - * - * @return string - */ - public function getTarget() - { - return $this->_target; - } - - /** - * Set Target Reference - * - * @param reference $target - * @return Zend_Filter_Inflector - */ - public function setTargetReference(&$target) - { - $this->_target =& $target; - return $this; - } - - /** - * SetRules() is the same as calling addRules() with the exception that it - * clears the rules before adding them. - * - * @param array $rules - * @return Zend_Filter_Inflector - */ - public function setRules(Array $rules) - { - $this->clearRules(); - $this->addRules($rules); - return $this; - } - - /** - * AddRules(): multi-call to setting filter rules. - * - * If prefixed with a ":" (colon), a filter rule will be added. If not - * prefixed, a static replacement will be added. - * - * ex: - * array( - * ':controller' => array('CamelCaseToUnderscore','StringToLower'), - * ':action' => array('CamelCaseToUnderscore','StringToLower'), - * 'suffix' => 'phtml' - * ); - * - * @param array - * @return Zend_Filter_Inflector - */ - public function addRules(Array $rules) - { - $keys = array_keys($rules); - foreach ($keys as $spec) { - if ($spec[0] == ':') { - $this->addFilterRule($spec, $rules[$spec]); - } else { - $this->setStaticRule($spec, $rules[$spec]); - } - } - - return $this; - } - - /** - * Get rules - * - * By default, returns all rules. If a $spec is provided, will return those - * rules if found, false otherwise. - * - * @param string $spec - * @return array|false - */ - public function getRules($spec = null) - { - if (null !== $spec) { - $spec = $this->_normalizeSpec($spec); - if (isset($this->_rules[$spec])) { - return $this->_rules[$spec]; - } - return false; - } - - return $this->_rules; - } - - /** - * getRule() returns a rule set by setFilterRule(), a numeric index must be provided - * - * @param string $spec - * @param int $index - * @return Zend_Filter_Interface|false - */ - public function getRule($spec, $index) - { - $spec = $this->_normalizeSpec($spec); - if (isset($this->_rules[$spec]) && is_array($this->_rules[$spec])) { - if (isset($this->_rules[$spec][$index])) { - return $this->_rules[$spec][$index]; - } - } - return false; - } - - /** - * ClearRules() clears the rules currently in the inflector - * - * @return Zend_Filter_Inflector - */ - public function clearRules() - { - $this->_rules = array(); - return $this; - } - - /** - * Set a filtering rule for a spec. $ruleSet can be a string, Filter object - * or an array of strings or filter objects. - * - * @param string $spec - * @param array|string|Zend_Filter_Interface $ruleSet - * @return Zend_Filter_Inflector - */ - public function setFilterRule($spec, $ruleSet) - { - $spec = $this->_normalizeSpec($spec); - $this->_rules[$spec] = array(); - return $this->addFilterRule($spec, $ruleSet); - } - - /** - * Add a filter rule for a spec - * - * @param mixed $spec - * @param mixed $ruleSet - * @return void - */ - public function addFilterRule($spec, $ruleSet) - { - $spec = $this->_normalizeSpec($spec); - if (!isset($this->_rules[$spec])) { - $this->_rules[$spec] = array(); - } - - if (!is_array($ruleSet)) { - $ruleSet = array($ruleSet); - } - - if (is_string($this->_rules[$spec])) { - $temp = $this->_rules[$spec]; - $this->_rules[$spec] = array(); - $this->_rules[$spec][] = $temp; - } - - foreach ($ruleSet as $rule) { - $this->_rules[$spec][] = $this->_getRule($rule); - } - - return $this; - } - - /** - * Set a static rule for a spec. This is a single string value - * - * @param string $name - * @param string $value - * @return Zend_Filter_Inflector - */ - public function setStaticRule($name, $value) - { - $name = $this->_normalizeSpec($name); - $this->_rules[$name] = (string) $value; - return $this; - } - - /** - * Set Static Rule Reference. - * - * This allows a consuming class to pass a property or variable - * in to be referenced when its time to build the output string from the - * target. - * - * @param string $name - * @param mixed $reference - * @return Zend_Filter_Inflector - */ - public function setStaticRuleReference($name, &$reference) - { - $name = $this->_normalizeSpec($name); - $this->_rules[$name] =& $reference; - return $this; - } - - /** - * Inflect - * - * @param string|array $source - * @return string - */ - public function filter($source) - { - // clean source - foreach ( (array) $source as $sourceName => $sourceValue) { - $source[ltrim($sourceName, ':')] = $sourceValue; - } - - $pregQuotedTargetReplacementIdentifier = preg_quote($this->_targetReplacementIdentifier, '#'); - $processedParts = array(); - - foreach ($this->_rules as $ruleName => $ruleValue) { - if (isset($source[$ruleName])) { - if (is_string($ruleValue)) { - // overriding the set rule - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $source[$ruleName]); - } elseif (is_array($ruleValue)) { - $processedPart = $source[$ruleName]; - foreach ($ruleValue as $ruleFilter) { - $processedPart = $ruleFilter->filter($processedPart); - } - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $processedPart); - } - } elseif (is_string($ruleValue)) { - $processedParts['#'.$pregQuotedTargetReplacementIdentifier.$ruleName.'#'] = str_replace('\\', '\\\\', $ruleValue); - } - } - - // all of the values of processedParts would have been str_replace('\\', '\\\\', ..)'d to disable preg_replace backreferences - $inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target); - - if ($this->_throwTargetExceptionsOn && (preg_match('#(?='.$pregQuotedTargetReplacementIdentifier.'[A-Za-z]{1})#', $inflectedTarget) == true)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('A replacement identifier ' . $this->_targetReplacementIdentifier . ' was found inside the inflected target, perhaps a rule was not satisfied with a target source? Unsatisfied inflected target: ' . $inflectedTarget); - } - - return $inflectedTarget; - } - - /** - * Normalize spec string - * - * @param string $spec - * @return string - */ - protected function _normalizeSpec($spec) - { - return ltrim((string) $spec, ':&'); - } - - /** - * Resolve named filters and convert them to filter objects. - * - * @param string $rule - * @return Zend_Filter_Interface - */ - protected function _getRule($rule) - { - if ($rule instanceof Zend_Filter_Interface) { - return $rule; - } - - $rule = (string) $rule; - - $className = $this->getPluginLoader()->load($rule); - $ruleObject = new $className(); - if (!$ruleObject instanceof Zend_Filter_Interface) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('No class named ' . $rule . ' implementing Zend_Filter_Interface could be found'); - } - - return $ruleObject; - } -} diff --git a/libs/Zend/Filter/Input.php b/libs/Zend/Filter/Input.php deleted file mode 100644 index 6db594d755..0000000000 --- a/libs/Zend/Filter/Input.php +++ /dev/null @@ -1,1126 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Input.php 22473 2010-06-20 08:30:04Z thomas $ - */ - -/** - * @see Zend_Loader - */ -// require_once 'Zend/Loader.php'; - -/** - * @see Zend_Filter - */ -// require_once 'Zend/Filter.php'; - -/** - * @see Zend_Validate - */ -// require_once 'Zend/Validate.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Input -{ - - const ALLOW_EMPTY = 'allowEmpty'; - const BREAK_CHAIN = 'breakChainOnFailure'; - const DEFAULT_VALUE = 'default'; - const MESSAGES = 'messages'; - const ESCAPE_FILTER = 'escapeFilter'; - const FIELDS = 'fields'; - const FILTER = 'filter'; - const FILTER_CHAIN = 'filterChain'; - const MISSING_MESSAGE = 'missingMessage'; - const INPUT_NAMESPACE = 'inputNamespace'; - const VALIDATOR_NAMESPACE = 'validatorNamespace'; - const FILTER_NAMESPACE = 'filterNamespace'; - const NOT_EMPTY_MESSAGE = 'notEmptyMessage'; - const PRESENCE = 'presence'; - const PRESENCE_OPTIONAL = 'optional'; - const PRESENCE_REQUIRED = 'required'; - const RULE = 'rule'; - const RULE_WILDCARD = '*'; - const VALIDATE = 'validate'; - const VALIDATOR = 'validator'; - const VALIDATOR_CHAIN = 'validatorChain'; - const VALIDATOR_CHAIN_COUNT = 'validatorChainCount'; - - /** - * @var array Input data, before processing. - */ - protected $_data = array(); - - /** - * @var array Association of rules to filters. - */ - protected $_filterRules = array(); - - /** - * @var array Association of rules to validators. - */ - protected $_validatorRules = array(); - - /** - * @var array After processing data, this contains mapping of valid fields - * to field values. - */ - protected $_validFields = array(); - - /** - * @var array After processing data, this contains mapping of validation - * rules that did not pass validation to the array of messages returned - * by the validator chain. - */ - protected $_invalidMessages = array(); - - /** - * @var array After processing data, this contains mapping of validation - * rules that did not pass validation to the array of error identifiers - * returned by the validator chain. - */ - protected $_invalidErrors = array(); - - /** - * @var array After processing data, this contains mapping of validation - * rules in which some fields were missing to the array of messages - * indicating which fields were missing. - */ - protected $_missingFields = array(); - - /** - * @var array After processing, this contains a copy of $_data elements - * that were not mentioned in any validation rule. - */ - protected $_unknownFields = array(); - - /** - * @var Zend_Filter_Interface The filter object that is run on values - * returned by the getEscaped() method. - */ - protected $_defaultEscapeFilter = null; - - /** - * Plugin loaders - * @var array - */ - protected $_loaders = array(); - - /** - * @var array Default values to use when processing filters and validators. - */ - protected $_defaults = array( - self::ALLOW_EMPTY => false, - self::BREAK_CHAIN => false, - self::ESCAPE_FILTER => 'HtmlEntities', - self::MISSING_MESSAGE => "Field '%field%' is required by rule '%rule%', but the field is missing", - self::NOT_EMPTY_MESSAGE => "You must give a non-empty value for field '%field%'", - self::PRESENCE => self::PRESENCE_OPTIONAL - ); - - /** - * @var boolean Set to False initially, this is set to True after the - * input data have been processed. Reset to False in setData() method. - */ - protected $_processed = false; - - /** - * Translation object - * @var Zend_Translate - */ - protected $_translator; - - /** - * Is translation disabled? - * @var Boolean - */ - protected $_translatorDisabled = false; - - /** - * @param array $filterRules - * @param array $validatorRules - * @param array $data OPTIONAL - * @param array $options OPTIONAL - */ - public function __construct($filterRules, $validatorRules, array $data = null, array $options = null) - { - if ($options) { - $this->setOptions($options); - } - - $this->_filterRules = (array) $filterRules; - $this->_validatorRules = (array) $validatorRules; - - if ($data) { - $this->setData($data); - } - } - - /** - * @param mixed $namespaces - * @return Zend_Filter_Input - * @deprecated since 1.5.0RC1 - use addFilterPrefixPath() or addValidatorPrefixPath instead. - */ - public function addNamespace($namespaces) - { - if (!is_array($namespaces)) { - $namespaces = array($namespaces); - } - - foreach ($namespaces as $namespace) { - $prefix = $namespace; - $path = str_replace('_', DIRECTORY_SEPARATOR, $prefix); - $this->addFilterPrefixPath($prefix, $path); - $this->addValidatorPrefixPath($prefix, $path); - } - - return $this; - } - - /** - * Add prefix path for all elements - * - * @param string $prefix - * @param string $path - * @return Zend_Filter_Input - */ - public function addFilterPrefixPath($prefix, $path) - { - $this->getPluginLoader(self::FILTER)->addPrefixPath($prefix, $path); - - return $this; - } - - /** - * Add prefix path for all elements - * - * @param string $prefix - * @param string $path - * @return Zend_Filter_Input - */ - public function addValidatorPrefixPath($prefix, $path) - { - $this->getPluginLoader(self::VALIDATE)->addPrefixPath($prefix, $path); - - return $this; - } - - /** - * Set plugin loaders for use with decorators and elements - * - * @param Zend_Loader_PluginLoader_Interface $loader - * @param string $type 'filter' or 'validate' - * @return Zend_Filter_Input - * @throws Zend_Filter_Exception on invalid type - */ - public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader, $type) - { - $type = strtolower($type); - switch ($type) { - case self::FILTER: - case self::VALIDATE: - $this->_loaders[$type] = $loader; - return $this; - default: - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception(sprintf('Invalid type "%s" provided to setPluginLoader()', $type)); - } - - return $this; - } - - /** - * Retrieve plugin loader for given type - * - * $type may be one of: - * - filter - * - validator - * - * If a plugin loader does not exist for the given type, defaults are - * created. - * - * @param string $type 'filter' or 'validate' - * @return Zend_Loader_PluginLoader_Interface - * @throws Zend_Filter_Exception on invalid type - */ - public function getPluginLoader($type) - { - $type = strtolower($type); - if (!isset($this->_loaders[$type])) { - switch ($type) { - case self::FILTER: - $prefixSegment = 'Zend_Filter_'; - $pathSegment = 'Zend/Filter/'; - break; - case self::VALIDATE: - $prefixSegment = 'Zend_Validate_'; - $pathSegment = 'Zend/Validate/'; - break; - default: - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception(sprintf('Invalid type "%s" provided to getPluginLoader()', $type)); - } - - // require_once 'Zend/Loader/PluginLoader.php'; - $this->_loaders[$type] = new Zend_Loader_PluginLoader( - array($prefixSegment => $pathSegment) - ); - } - - return $this->_loaders[$type]; - } - - /** - * @return array - */ - public function getMessages() - { - $this->_process(); - return array_merge($this->_invalidMessages, $this->_missingFields); - } - - /** - * @return array - */ - public function getErrors() - { - $this->_process(); - return $this->_invalidErrors; - } - - /** - * @return array - */ - public function getInvalid() - { - $this->_process(); - return $this->_invalidMessages; - } - - /** - * @return array - */ - public function getMissing() - { - $this->_process(); - return $this->_missingFields; - } - - /** - * @return array - */ - public function getUnknown() - { - $this->_process(); - return $this->_unknownFields; - } - - /** - * @param string $fieldName OPTIONAL - * @return mixed - */ - public function getEscaped($fieldName = null) - { - $this->_process(); - $this->_getDefaultEscapeFilter(); - - if ($fieldName === null) { - return $this->_escapeRecursive($this->_validFields); - } - if (array_key_exists($fieldName, $this->_validFields)) { - return $this->_escapeRecursive($this->_validFields[$fieldName]); - } - return null; - } - - /** - * @param mixed $value - * @return mixed - */ - protected function _escapeRecursive($data) - { - if($data === null) { - return $data; - } - - if (!is_array($data)) { - return $this->_getDefaultEscapeFilter()->filter($data); - } - foreach ($data as &$element) { - $element = $this->_escapeRecursive($element); - } - return $data; - } - - /** - * @param string $fieldName OPTIONAL - * @return mixed - */ - public function getUnescaped($fieldName = null) - { - $this->_process(); - if ($fieldName === null) { - return $this->_validFields; - } - if (array_key_exists($fieldName, $this->_validFields)) { - return $this->_validFields[$fieldName]; - } - return null; - } - - /** - * @param string $fieldName - * @return mixed - */ - public function __get($fieldName) - { - return $this->getEscaped($fieldName); - } - - /** - * @return boolean - */ - public function hasInvalid() - { - $this->_process(); - return !(empty($this->_invalidMessages)); - } - - /** - * @return boolean - */ - public function hasMissing() - { - $this->_process(); - return !(empty($this->_missingFields)); - } - - /** - * @return boolean - */ - public function hasUnknown() - { - $this->_process(); - return !(empty($this->_unknownFields)); - } - - /** - * @return boolean - */ - public function hasValid() - { - $this->_process(); - return !(empty($this->_validFields)); - } - - /** - * @param string $fieldName - * @return boolean - */ - public function isValid($fieldName = null) - { - $this->_process(); - if ($fieldName === null) { - return !($this->hasMissing() || $this->hasInvalid()); - } - return array_key_exists($fieldName, $this->_validFields); - } - - /** - * @param string $fieldName - * @return boolean - */ - public function __isset($fieldName) - { - $this->_process(); - return isset($this->_validFields[$fieldName]); - } - - /** - * @return Zend_Filter_Input - * @throws Zend_Filter_Exception - */ - public function process() - { - $this->_process(); - if ($this->hasInvalid()) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Input has invalid fields"); - } - if ($this->hasMissing()) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Input has missing fields"); - } - - return $this; - } - - /** - * @param array $data - * @return Zend_Filter_Input - */ - public function setData(array $data) - { - $this->_data = $data; - - /** - * Reset to initial state - */ - $this->_validFields = array(); - $this->_invalidMessages = array(); - $this->_invalidErrors = array(); - $this->_missingFields = array(); - $this->_unknownFields = array(); - - $this->_processed = false; - - return $this; - } - - /** - * @param mixed $escapeFilter - * @return Zend_Filter_Interface - */ - public function setDefaultEscapeFilter($escapeFilter) - { - if (is_string($escapeFilter) || is_array($escapeFilter)) { - $escapeFilter = $this->_getFilter($escapeFilter); - } - if (!$escapeFilter instanceof Zend_Filter_Interface) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Escape filter specified does not implement Zend_Filter_Interface'); - } - $this->_defaultEscapeFilter = $escapeFilter; - return $escapeFilter; - } - - /** - * @param array $options - * @return Zend_Filter_Input - * @throws Zend_Filter_Exception if an unknown option is given - */ - public function setOptions(array $options) - { - foreach ($options as $option => $value) { - switch ($option) { - case self::ESCAPE_FILTER: - $this->setDefaultEscapeFilter($value); - break; - case self::INPUT_NAMESPACE: - $this->addNamespace($value); - break; - case self::VALIDATOR_NAMESPACE: - if(is_string($value)) { - $value = array($value); - } - - foreach($value AS $prefix) { - $this->addValidatorPrefixPath( - $prefix, - str_replace('_', DIRECTORY_SEPARATOR, $prefix) - ); - } - break; - case self::FILTER_NAMESPACE: - if(is_string($value)) { - $value = array($value); - } - - foreach($value AS $prefix) { - $this->addFilterPrefixPath( - $prefix, - str_replace('_', DIRECTORY_SEPARATOR, $prefix) - ); - } - break; - case self::ALLOW_EMPTY: - case self::BREAK_CHAIN: - case self::MISSING_MESSAGE: - case self::NOT_EMPTY_MESSAGE: - case self::PRESENCE: - $this->_defaults[$option] = $value; - break; - default: - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Unknown option '$option'"); - break; - } - } - - return $this; - } - - /** - * Set translation object - * - * @param Zend_Translate|Zend_Translate_Adapter|null $translator - * @return Zend_Filter_Input - */ - public function setTranslator($translator = null) - { - if ((null === $translator) || ($translator instanceof Zend_Translate_Adapter)) { - $this->_translator = $translator; - } elseif ($translator instanceof Zend_Translate) { - $this->_translator = $translator->getAdapter(); - } else { - // require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid translator specified'); - } - - return $this; - } - - /** - * Return translation object - * - * @return Zend_Translate_Adapter|null - */ - public function getTranslator() - { - if ($this->translatorIsDisabled()) { - return null; - } - - if ($this->_translator === null) { - // require_once 'Zend/Registry.php'; - if (Zend_Registry::isRegistered('Zend_Translate')) { - $translator = Zend_Registry::get('Zend_Translate'); - if ($translator instanceof Zend_Translate_Adapter) { - return $translator; - } elseif ($translator instanceof Zend_Translate) { - return $translator->getAdapter(); - } - } - } - - return $this->_translator; - } - - /** - * Indicate whether or not translation should be disabled - * - * @param bool $flag - * @return Zend_Filter_Input - */ - public function setDisableTranslator($flag) - { - $this->_translatorDisabled = (bool) $flag; - return $this; - } - - /** - * Is translation disabled? - * - * @return bool - */ - public function translatorIsDisabled() - { - return $this->_translatorDisabled; - } - - /* - * Protected methods - */ - - /** - * @return void - */ - protected function _filter() - { - foreach ($this->_filterRules as $ruleName => &$filterRule) { - /** - * Make sure we have an array representing this filter chain. - * Don't typecast to (array) because it might be a Zend_Filter object - */ - if (!is_array($filterRule)) { - $filterRule = array($filterRule); - } - - /** - * Filters are indexed by integer, metacommands are indexed by string. - * Pick out the filters. - */ - $filterList = array(); - foreach ($filterRule as $key => $value) { - if (is_int($key)) { - $filterList[] = $value; - } - } - - /** - * Use defaults for filter metacommands. - */ - $filterRule[self::RULE] = $ruleName; - if (!isset($filterRule[self::FIELDS])) { - $filterRule[self::FIELDS] = $ruleName; - } - - /** - * Load all the filter classes and add them to the chain. - */ - if (!isset($filterRule[self::FILTER_CHAIN])) { - $filterRule[self::FILTER_CHAIN] = new Zend_Filter(); - foreach ($filterList as $filter) { - if (is_string($filter) || is_array($filter)) { - $filter = $this->_getFilter($filter); - } - $filterRule[self::FILTER_CHAIN]->addFilter($filter); - } - } - - /** - * If the ruleName is the special wildcard rule, - * then apply the filter chain to all input data. - * Else just process the field named by the rule. - */ - if ($ruleName == self::RULE_WILDCARD) { - foreach (array_keys($this->_data) as $field) { - $this->_filterRule(array_merge($filterRule, array(self::FIELDS => $field))); - } - } else { - $this->_filterRule($filterRule); - } - } - } - - /** - * @param array $filterRule - * @return void - */ - protected function _filterRule(array $filterRule) - { - $field = $filterRule[self::FIELDS]; - if (!array_key_exists($field, $this->_data)) { - return; - } - if (is_array($this->_data[$field])) { - foreach ($this->_data[$field] as $key => $value) { - $this->_data[$field][$key] = $filterRule[self::FILTER_CHAIN]->filter($value); - } - } else { - $this->_data[$field] = - $filterRule[self::FILTER_CHAIN]->filter($this->_data[$field]); - } - } - - /** - * @return Zend_Filter_Interface - */ - protected function _getDefaultEscapeFilter() - { - if ($this->_defaultEscapeFilter !== null) { - return $this->_defaultEscapeFilter; - } - return $this->setDefaultEscapeFilter($this->_defaults[self::ESCAPE_FILTER]); - } - - /** - * @param string $rule - * @param string $field - * @return string - */ - protected function _getMissingMessage($rule, $field) - { - $message = $this->_defaults[self::MISSING_MESSAGE]; - - if (null !== ($translator = $this->getTranslator())) { - if ($translator->isTranslated(self::MISSING_MESSAGE)) { - $message = $translator->translate(self::MISSING_MESSAGE); - } else { - $message = $translator->translate($message); - } - } - - $message = str_replace('%rule%', $rule, $message); - $message = str_replace('%field%', $field, $message); - return $message; - } - - /** - * @return string - */ - protected function _getNotEmptyMessage($rule, $field) - { - $message = $this->_defaults[self::NOT_EMPTY_MESSAGE]; - - if (null !== ($translator = $this->getTranslator())) { - if ($translator->isTranslated(self::NOT_EMPTY_MESSAGE)) { - $message = $translator->translate(self::NOT_EMPTY_MESSAGE); - } else { - $message = $translator->translate($message); - } - } - - $message = str_replace('%rule%', $rule, $message); - $message = str_replace('%field%', $field, $message); - return $message; - } - - /** - * @return void - */ - protected function _process() - { - if ($this->_processed === false) { - $this->_filter(); - $this->_validate(); - $this->_processed = true; - } - } - - /** - * @return void - */ - protected function _validate() - { - /** - * Special case: if there are no validators, treat all fields as valid. - */ - if (!$this->_validatorRules) { - $this->_validFields = $this->_data; - $this->_data = array(); - return; - } - - foreach ($this->_validatorRules as $ruleName => &$validatorRule) { - /** - * Make sure we have an array representing this validator chain. - * Don't typecast to (array) because it might be a Zend_Validate object - */ - if (!is_array($validatorRule)) { - $validatorRule = array($validatorRule); - } - - /** - * Validators are indexed by integer, metacommands are indexed by string. - * Pick out the validators. - */ - $validatorList = array(); - foreach ($validatorRule as $key => $value) { - if (is_int($key)) { - $validatorList[$key] = $value; - } - } - - /** - * Use defaults for validation metacommands. - */ - $validatorRule[self::RULE] = $ruleName; - if (!isset($validatorRule[self::FIELDS])) { - $validatorRule[self::FIELDS] = $ruleName; - } - if (!isset($validatorRule[self::BREAK_CHAIN])) { - $validatorRule[self::BREAK_CHAIN] = $this->_defaults[self::BREAK_CHAIN]; - } - if (!isset($validatorRule[self::PRESENCE])) { - $validatorRule[self::PRESENCE] = $this->_defaults[self::PRESENCE]; - } - if (!isset($validatorRule[self::ALLOW_EMPTY])) { - $validatorRule[self::ALLOW_EMPTY] = $this->_defaults[self::ALLOW_EMPTY]; - } - - if (!isset($validatorRule[self::MESSAGES])) { - $validatorRule[self::MESSAGES] = array(); - } else if (!is_array($validatorRule[self::MESSAGES])) { - $validatorRule[self::MESSAGES] = array($validatorRule[self::MESSAGES]); - } else if (array_intersect_key($validatorList, $validatorRule[self::MESSAGES])) { - // There are now corresponding numeric keys in the validation rule messages array - // Treat it as a named messages list for all rule validators - $unifiedMessages = $validatorRule[self::MESSAGES]; - $validatorRule[self::MESSAGES] = array(); - - foreach ($validatorList as $key => $validator) { - if (array_key_exists($key, $unifiedMessages)) { - $validatorRule[self::MESSAGES][$key] = $unifiedMessages[$key]; - } - } - } - - /** - * Load all the validator classes and add them to the chain. - */ - if (!isset($validatorRule[self::VALIDATOR_CHAIN])) { - $validatorRule[self::VALIDATOR_CHAIN] = new Zend_Validate(); - - foreach ($validatorList as $key => $validator) { - if (is_string($validator) || is_array($validator)) { - $validator = $this->_getValidator($validator); - } - - if (isset($validatorRule[self::MESSAGES][$key])) { - $value = $validatorRule[self::MESSAGES][$key]; - if (is_array($value)) { - $validator->setMessages($value); - } else { - $validator->setMessage($value); - } - - if ($validator instanceof Zend_Validate_NotEmpty) { - $this->_defaults[self::NOT_EMPTY_MESSAGE] = $value; - } - } - - $validatorRule[self::VALIDATOR_CHAIN]->addValidator($validator, $validatorRule[self::BREAK_CHAIN]); - } - $validatorRule[self::VALIDATOR_CHAIN_COUNT] = count($validatorList); - } - - /** - * If the ruleName is the special wildcard rule, - * then apply the validator chain to all input data. - * Else just process the field named by the rule. - */ - if ($ruleName == self::RULE_WILDCARD) { - foreach (array_keys($this->_data) as $field) { - $this->_validateRule(array_merge($validatorRule, array(self::FIELDS => $field))); - } - } else { - $this->_validateRule($validatorRule); - } - } - - /** - * Unset fields in $_data that have been added to other arrays. - * We have to wait until all rules have been processed because - * a given field may be referenced by multiple rules. - */ - foreach (array_merge(array_keys($this->_missingFields), array_keys($this->_invalidMessages)) as $rule) { - foreach ((array) $this->_validatorRules[$rule][self::FIELDS] as $field) { - unset($this->_data[$field]); - } - } - foreach ($this->_validFields as $field => $value) { - unset($this->_data[$field]); - } - - /** - * Anything left over in $_data is an unknown field. - */ - $this->_unknownFields = $this->_data; - } - - /** - * @param array $validatorRule - * @return void - */ - protected function _validateRule(array $validatorRule) - { - /** - * Get one or more data values from input, and check for missing fields. - * Apply defaults if fields are missing. - */ - $data = array(); - foreach ((array) $validatorRule[self::FIELDS] as $key => $field) { - if (array_key_exists($field, $this->_data)) { - $data[$field] = $this->_data[$field]; - } else if (isset($validatorRule[self::DEFAULT_VALUE])) { - /** @todo according to this code default value can't be an array. It has to be reviewed */ - if (!is_array($validatorRule[self::DEFAULT_VALUE])) { - // Default value is a scalar - $data[$field] = $validatorRule[self::DEFAULT_VALUE]; - } else { - // Default value is an array. Search for corresponding key - if (isset($validatorRule[self::DEFAULT_VALUE][$key])) { - $data[$field] = $validatorRule[self::DEFAULT_VALUE][$key]; - } else if ($validatorRule[self::PRESENCE] == self::PRESENCE_REQUIRED) { - // Default value array is provided, but it doesn't have an entry for current field - // and presence is required - $this->_missingFields[$validatorRule[self::RULE]][] = - $this->_getMissingMessage($validatorRule[self::RULE], $field); - } - } - } else if ($validatorRule[self::PRESENCE] == self::PRESENCE_REQUIRED) { - $this->_missingFields[$validatorRule[self::RULE]][] = - $this->_getMissingMessage($validatorRule[self::RULE], $field); - } - } - - /** - * If any required fields are missing, break the loop. - */ - if (isset($this->_missingFields[$validatorRule[self::RULE]]) && count($this->_missingFields[$validatorRule[self::RULE]]) > 0) { - return; - } - - /** - * Evaluate the inputs against the validator chain. - */ - if (count((array) $validatorRule[self::FIELDS]) > 1) { - if (!$validatorRule[self::ALLOW_EMPTY]) { - $emptyFieldsFound = false; - $errorsList = array(); - $messages = array(); - - foreach ($data as $fieldKey => $field) { - $notEmptyValidator = $this->_getValidator('NotEmpty'); - $notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldKey)); - - if (!$notEmptyValidator->isValid($field)) { - foreach ($notEmptyValidator->getMessages() as $messageKey => $message) { - if (!isset($messages[$messageKey])) { - $messages[$messageKey] = $message; - } else { - $messages[] = $message; - } - } - $errorsList[] = $notEmptyValidator->getErrors(); - $emptyFieldsFound = true; - } - } - - if ($emptyFieldsFound) { - $this->_invalidMessages[$validatorRule[self::RULE]] = $messages; - $this->_invalidErrors[$validatorRule[self::RULE]] = array_unique(call_user_func_array('array_merge', $errorsList)); - return; - } - } - - if (!$validatorRule[self::VALIDATOR_CHAIN]->isValid($data)) { - $this->_invalidMessages[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getMessages(); - $this->_invalidErrors[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getErrors(); - return; - } - } else if (count($data) > 0) { - // $data is actually a one element array - $fieldNames = array_keys($data); - $fieldName = reset($fieldNames); - $field = reset($data); - - $failed = false; - if (!is_array($field)) { - $field = array($field); - } - - $notEmptyValidator = $this->_getValidator('NotEmpty'); - $notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldName)); - if ($validatorRule[self::ALLOW_EMPTY]) { - $validatorChain = $validatorRule[self::VALIDATOR_CHAIN]; - } else { - $validatorChain = new Zend_Validate(); - $validatorChain->addValidator($notEmptyValidator, true /* Always break on failure */); - $validatorChain->addValidator($validatorRule[self::VALIDATOR_CHAIN]); - } - - foreach ($field as $value) { - if ($validatorRule[self::ALLOW_EMPTY] && !$notEmptyValidator->isValid($value)) { - // Field is empty AND it's allowed. Do nothing. - continue; - } - - if (!$validatorChain->isValid($value)) { - if (isset($this->_invalidMessages[$validatorRule[self::RULE]])) { - $collectedMessages = $this->_invalidMessages[$validatorRule[self::RULE]]; - } else { - $collectedMessages = array(); - } - - foreach ($validatorChain->getMessages() as $messageKey => $message) { - if (!isset($collectedMessages[$messageKey])) { - $collectedMessages[$messageKey] = $message; - } else { - $collectedMessages[] = $message; - } - } - - $this->_invalidMessages[$validatorRule[self::RULE]] = $collectedMessages; - if (isset($this->_invalidErrors[$validatorRule[self::RULE]])) { - $this->_invalidErrors[$validatorRule[self::RULE]] = array_merge($this->_invalidErrors[$validatorRule[self::RULE]], - $validatorChain->getErrors()); - } else { - $this->_invalidErrors[$validatorRule[self::RULE]] = $validatorChain->getErrors(); - } - unset($this->_validFields[$fieldName]); - $failed = true; - if ($validatorRule[self::BREAK_CHAIN]) { - return; - } - } - } - if ($failed) { - return; - } - } - - /** - * If we got this far, the inputs for this rule pass validation. - */ - foreach ((array) $validatorRule[self::FIELDS] as $field) { - if (array_key_exists($field, $data)) { - $this->_validFields[$field] = $data[$field]; - } - } - } - - /** - * @param mixed $classBaseName - * @return Zend_Filter_Interface - */ - protected function _getFilter($classBaseName) - { - return $this->_getFilterOrValidator(self::FILTER, $classBaseName); - } - - /** - * @param mixed $classBaseName - * @return Zend_Validate_Interface - */ - protected function _getValidator($classBaseName) - { - return $this->_getFilterOrValidator(self::VALIDATE, $classBaseName); - } - - /** - * @param string $type - * @param mixed $classBaseName - * @return Zend_Filter_Interface|Zend_Validate_Interface - * @throws Zend_Filter_Exception - */ - protected function _getFilterOrValidator($type, $classBaseName) - { - $args = array(); - - if (is_array($classBaseName)) { - $args = $classBaseName; - $classBaseName = array_shift($args); - } - - $interfaceName = 'Zend_' . ucfirst($type) . '_Interface'; - $className = $this->getPluginLoader($type)->load(ucfirst($classBaseName)); - - $class = new ReflectionClass($className); - - if (!$class->implementsInterface($interfaceName)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("Class '$className' based on basename '$classBaseName' must implement the '$interfaceName' interface"); - } - - if ($class->hasMethod('__construct')) { - $object = $class->newInstanceArgs($args); - } else { - $object = $class->newInstance(); - } - - return $object; - } - -} diff --git a/libs/Zend/Filter/Int.php b/libs/Zend/Filter/Int.php deleted file mode 100644 index b4060ec0de..0000000000 --- a/libs/Zend/Filter/Int.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Int.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Int implements Zend_Filter_Interface -{ - /** - * Defined by Zend_Filter_Interface - * - * Returns (int) $value - * - * @param string $value - * @return integer - */ - public function filter($value) - { - return (int) ((string) $value); - } -} diff --git a/libs/Zend/Filter/Interface.php b/libs/Zend/Filter/Interface.php deleted file mode 100644 index c059967f77..0000000000 --- a/libs/Zend/Filter/Interface.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -interface Zend_Filter_Interface -{ - /** - * Returns the result of filtering $value - * - * @param mixed $value - * @throws Zend_Filter_Exception If filtering $value is impossible - * @return mixed - */ - public function filter($value); -} diff --git a/libs/Zend/Filter/LocalizedToNormalized.php b/libs/Zend/Filter/LocalizedToNormalized.php deleted file mode 100644 index 1d93997576..0000000000 --- a/libs/Zend/Filter/LocalizedToNormalized.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: LocalizedToNormalized.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @see Zend_Loader - */ -// require_once 'Zend/Locale/Format.php'; - -/** - * Normalizes given localized input - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_LocalizedToNormalized implements Zend_Filter_Interface -{ - /** - * Set options - * @var array - */ - protected $_options = array( - 'locale' => null, - 'date_format' => null, - 'precision' => null - ); - - /** - * Class constructor - * - * @param string|Zend_Locale $locale (Optional) Locale to set - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - if (null !== $options) { - $this->setOptions($options); - } - } - - /** - * Returns the set options - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets options to use - * - * @param array $options (Optional) Options to use - * @return Zend_Filter_LocalizedToNormalized - */ - public function setOptions(array $options = null) - { - $this->_options = $options + $this->_options; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Normalizes the given input - * - * @param string $value Value to normalized - * @return string|array The normalized value - */ - public function filter($value) - { - if (Zend_Locale_Format::isNumber($value, $this->_options)) { - return Zend_Locale_Format::getNumber($value, $this->_options); - } else if (($this->_options['date_format'] === null) && (strpos($value, ':') !== false)) { - // Special case, no date format specified, detect time input - return Zend_Locale_Format::getTime($value, $this->_options); - } else if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) { - // Detect date or time input - return Zend_Locale_Format::getDate($value, $this->_options); - } - - return $value; - } -} diff --git a/libs/Zend/Filter/NormalizedToLocalized.php b/libs/Zend/Filter/NormalizedToLocalized.php deleted file mode 100644 index d623c3e00b..0000000000 --- a/libs/Zend/Filter/NormalizedToLocalized.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NormalizedToLocalized.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @see Zend_Loader - */ -// require_once 'Zend/Locale/Format.php'; - -/** - * Localizes given normalized input - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_NormalizedToLocalized implements Zend_Filter_Interface -{ - /** - * Set options - */ - protected $_options = array( - 'locale' => null, - 'date_format' => null, - 'precision' => null - ); - - /** - * Class constructor - * - * @param string|Zend_Locale $locale (Optional) Locale to set - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } - - if (null !== $options) { - $this->setOptions($options); - } - } - - /** - * Returns the set options - * - * @return array - */ - public function getOptions() - { - return $this->_options; - } - - /** - * Sets options to use - * - * @param array $options (Optional) Options to use - * @return Zend_Filter_LocalizedToNormalized - */ - public function setOptions(array $options = null) - { - $this->_options = $options + $this->_options; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Normalizes the given input - * - * @param string $value Value to normalized - * @return string|array The normalized value - */ - public function filter($value) - { - if (is_array($value)) { - // require_once 'Zend/Date.php'; - $date = new Zend_Date($value, $this->_options['locale']); - return $date->toString($this->_options['date_format']); - } else if ($this->_options['precision'] === 0) { - return Zend_Locale_Format::toInteger($value, $this->_options); - } else if ($this->_options['precision'] === null) { - return Zend_Locale_Format::toFloat($value, $this->_options); - } - - return Zend_Locale_Format::toNumber($value, $this->_options); - } -} diff --git a/libs/Zend/Filter/Null.php b/libs/Zend/Filter/Null.php deleted file mode 100644 index 6839dc45e1..0000000000 --- a/libs/Zend/Filter/Null.php +++ /dev/null @@ -1,183 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Null.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Null implements Zend_Filter_Interface -{ - const BOOLEAN = 1; - const INTEGER = 2; - const EMPTY_ARRAY = 4; - const STRING = 8; - const ZERO = 16; - const ALL = 31; - - protected $_constants = array( - self::BOOLEAN => 'boolean', - self::INTEGER => 'integer', - self::EMPTY_ARRAY => 'array', - self::STRING => 'string', - self::ZERO => 'zero', - self::ALL => 'all' - ); - - /** - * Internal type to detect - * - * @var integer - */ - protected $_type = self::ALL; - - /** - * Constructor - * - * @param string|array|Zend_Config $options OPTIONAL - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - if (!empty($options)) { - $temp = array_shift($options); - } - $options = $temp; - } else if (is_array($options) && array_key_exists('type', $options)) { - $options = $options['type']; - } - - if (!empty($options)) { - $this->setType($options); - } - } - - /** - * Returns the set null types - * - * @return array - */ - public function getType() - { - return $this->_type; - } - - /** - * Set the null types - * - * @param integer|array $type - * @throws Zend_Filter_Exception - * @return Zend_Filter_Null - */ - public function setType($type = null) - { - if (is_array($type)) { - $detected = 0; - foreach($type as $value) { - if (is_int($value)) { - $detected += $value; - } else if (in_array($value, $this->_constants)) { - $detected += array_search($value, $this->_constants); - } - } - - $type = $detected; - } else if (is_string($type)) { - if (in_array($type, $this->_constants)) { - $type = array_search($type, $this->_constants); - } - } - - if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('Unknown type'); - } - - $this->_type = $type; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns null representation of $value, if value is empty and matches - * types that should be considered null. - * - * @param string $value - * @return string - */ - public function filter($value) - { - $type = $this->getType(); - - // STRING ZERO ('0') - if ($type >= self::ZERO) { - $type -= self::ZERO; - if (is_string($value) && ($value == '0')) { - return null; - } - } - - // STRING ('') - if ($type >= self::STRING) { - $type -= self::STRING; - if (is_string($value) && ($value == '')) { - return null; - } - } - - // EMPTY_ARRAY (array()) - if ($type >= self::EMPTY_ARRAY) { - $type -= self::EMPTY_ARRAY; - if (is_array($value) && ($value == array())) { - return null; - } - } - - // INTEGER (0) - if ($type >= self::INTEGER) { - $type -= self::INTEGER; - if (is_int($value) && ($value == 0)) { - return null; - } - } - - // BOOLEAN (false) - if ($type >= self::BOOLEAN) { - $type -= self::BOOLEAN; - if (is_bool($value) && ($value == false)) { - return null; - } - } - - return $value; - } -} diff --git a/libs/Zend/Filter/PregReplace.php b/libs/Zend/Filter/PregReplace.php deleted file mode 100644 index fcde06fbac..0000000000 --- a/libs/Zend/Filter/PregReplace.php +++ /dev/null @@ -1,174 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PregReplace.php 21086 2010-02-18 21:10:39Z thomas $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_PregReplace implements Zend_Filter_Interface -{ - /** - * Pattern to match - * @var mixed - */ - protected $_matchPattern = null; - - /** - * Replacement pattern - * @var mixed - */ - protected $_replacement = ''; - - /** - * Is unicode enabled? - * - * @var bool - */ - static protected $_unicodeSupportEnabled = null; - - /** - * Is Unicode Support Enabled Utility function - * - * @return bool - */ - static public function isUnicodeSupportEnabled() - { - if (self::$_unicodeSupportEnabled === null) { - self::_determineUnicodeSupport(); - } - - return self::$_unicodeSupportEnabled; - } - - /** - * Method to cache the regex needed to determine if unicode support is available - * - * @return bool - */ - static protected function _determineUnicodeSupport() - { - self::$_unicodeSupportEnabled = (@preg_match('/\pL/u', 'a')) ? true : false; - } - - /** - * Constructor - * Supported options are - * 'match' => matching pattern - * 'replace' => replace with this - * - * @param string|array $options - * @return void - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - if (!empty($options)) { - $temp['match'] = array_shift($options); - } - - if (!empty($options)) { - $temp['replace'] = array_shift($options); - } - - $options = $temp; - } - - if (array_key_exists('match', $options)) { - $this->setMatchPattern($options['match']); - } - - if (array_key_exists('replace', $options)) { - $this->setReplacement($options['replace']); - } - } - - /** - * Set the match pattern for the regex being called within filter() - * - * @param mixed $match - same as the first argument of preg_replace - * @return Zend_Filter_PregReplace - */ - public function setMatchPattern($match) - { - $this->_matchPattern = $match; - return $this; - } - - /** - * Get currently set match pattern - * - * @return string - */ - public function getMatchPattern() - { - return $this->_matchPattern; - } - - /** - * Set the Replacement pattern/string for the preg_replace called in filter - * - * @param mixed $replacement - same as the second argument of preg_replace - * @return Zend_Filter_PregReplace - */ - public function setReplacement($replacement) - { - $this->_replacement = $replacement; - return $this; - } - - /** - * Get currently set replacement value - * - * @return string - */ - public function getReplacement() - { - return $this->_replacement; - } - - /** - * Perform regexp replacement as filter - * - * @param string $value - * @return string - */ - public function filter($value) - { - if ($this->_matchPattern == null) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception(get_class($this) . ' does not have a valid MatchPattern set.'); - } - - return preg_replace($this->_matchPattern, $this->_replacement, $value); - } - -} diff --git a/libs/Zend/Filter/RealPath.php b/libs/Zend/Filter/RealPath.php deleted file mode 100644 index 829535421d..0000000000 --- a/libs/Zend/Filter/RealPath.php +++ /dev/null @@ -1,134 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: RealPath.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_RealPath implements Zend_Filter_Interface -{ - /** - * @var boolean $_pathExists - */ - protected $_exists = true; - - /** - * Class constructor - * - * @param boolean|Zend_Config $options Options to set - */ - public function __construct($options = true) - { - $this->setExists($options); - } - - /** - * Returns true if the filtered path must exist - * - * @return boolean - */ - public function getExists() - { - return $this->_exists; - } - - /** - * Sets if the path has to exist - * TRUE when the path must exist - * FALSE when not existing paths can be given - * - * @param boolean|Zend_Config $exists Path must exist - * @return Zend_Filter_RealPath - */ - public function setExists($exists) - { - if ($exists instanceof Zend_Config) { - $exists = $exists->toArray(); - } - - if (is_array($exists)) { - if (isset($exists['exists'])) { - $exists = (boolean) $exists['exists']; - } - } - - $this->_exists = (boolean) $exists; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns realpath($value) - * - * @param string $value - * @return string - */ - public function filter($value) - { - $path = (string) $value; - if ($this->_exists) { - return realpath($path); - } - - $realpath = @realpath($path); - if ($realpath) { - return $realpath; - } - - $drive = ''; - if (substr(PHP_OS, 0, 3) == 'WIN') { - $path = preg_replace('/[\\\\\/]/', DIRECTORY_SEPARATOR, $path); - if (preg_match('/([a-zA-Z]\:)(.*)/', $path, $matches)) { - list($fullMatch, $drive, $path) = $matches; - } else { - $cwd = getcwd(); - $drive = substr($cwd, 0, 2); - if (substr($path, 0, 1) != DIRECTORY_SEPARATOR) { - $path = substr($cwd, 3) . DIRECTORY_SEPARATOR . $path; - } - } - } elseif (substr($path, 0, 1) != DIRECTORY_SEPARATOR) { - $path = getcwd() . DIRECTORY_SEPARATOR . $path; - } - - $stack = array(); - $parts = explode(DIRECTORY_SEPARATOR, $path); - foreach ($parts as $dir) { - if (strlen($dir) && $dir !== '.') { - if ($dir == '..') { - array_pop($stack); - } else { - array_push($stack, $dir); - } - } - } - - return $drive . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $stack); - } -} diff --git a/libs/Zend/Filter/StringToLower.php b/libs/Zend/Filter/StringToLower.php deleted file mode 100644 index a780305d65..0000000000 --- a/libs/Zend/Filter/StringToLower.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringToLower.php 20912 2010-02-04 19:44:42Z thomas $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringToLower implements Zend_Filter_Interface -{ - /** - * Encoding for the input string - * - * @var string - */ - protected $_encoding = null; - - /** - * Constructor - * - * @param string|array|Zend_Config $options OPTIONAL - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - if (!empty($options)) { - $temp['encoding'] = array_shift($options); - } - $options = $temp; - } - - if (array_key_exists('encoding', $options)) { - $this->setEncoding($options['encoding']); - } - } - - /** - * Returns the set encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set the input encoding for the given string - * - * @param string $encoding - * @return Zend_Filter_StringToLower Provides a fluent interface - * @throws Zend_Filter_Exception - */ - public function setEncoding($encoding = null) - { - if ($encoding !== null) { - if (!function_exists('mb_strtolower')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('mbstring is required for this feature'); - } - - $encoding = (string) $encoding; - if (!in_array(strtolower($encoding), array_map('strtolower', mb_list_encodings()))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The given encoding '$encoding' is not supported by mbstring"); - } - } - - $this->_encoding = $encoding; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, converting characters to lowercase as necessary - * - * @param string $value - * @return string - */ - public function filter($value) - { - if ($this->_encoding !== null) { - return mb_strtolower((string) $value, $this->_encoding); - } - - return strtolower((string) $value); - } -} diff --git a/libs/Zend/Filter/StringToUpper.php b/libs/Zend/Filter/StringToUpper.php deleted file mode 100644 index f733dfc7df..0000000000 --- a/libs/Zend/Filter/StringToUpper.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringToUpper.php 20912 2010-02-04 19:44:42Z thomas $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringToUpper implements Zend_Filter_Interface -{ - /** - * Encoding for the input string - * - * @var string - */ - protected $_encoding = null; - - /** - * Constructor - * - * @param string|array $options OPTIONAL - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (!is_array($options)) { - $options = func_get_args(); - $temp = array(); - if (!empty($options)) { - $temp['encoding'] = array_shift($options); - } - $options = $temp; - } - - if (array_key_exists('encoding', $options)) { - $this->setEncoding($options['encoding']); - } - } - - /** - * Returns the set encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set the input encoding for the given string - * - * @param string $encoding - * @return Zend_Filter_StringToUpper Provides a fluent interface - * @throws Zend_Filter_Exception - */ - public function setEncoding($encoding = null) - { - if ($encoding !== null) { - if (!function_exists('mb_strtoupper')) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('mbstring is required for this feature'); - } - - $encoding = (string) $encoding; - if (!in_array(strtolower($encoding), array_map('strtolower', mb_list_encodings()))) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception("The given encoding '$encoding' is not supported by mbstring"); - } - } - - $this->_encoding = $encoding; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, converting characters to uppercase as necessary - * - * @param string $value - * @return string - */ - public function filter($value) - { - if ($this->_encoding) { - return mb_strtoupper((string) $value, $this->_encoding); - } - - return strtoupper((string) $value); - } -} diff --git a/libs/Zend/Filter/StringTrim.php b/libs/Zend/Filter/StringTrim.php deleted file mode 100644 index cfbc7ba41a..0000000000 --- a/libs/Zend/Filter/StringTrim.php +++ /dev/null @@ -1,124 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StringTrim.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StringTrim implements Zend_Filter_Interface -{ - /** - * List of characters provided to the trim() function - * - * If this is null, then trim() is called with no specific character list, - * and its default behavior will be invoked, trimming whitespace. - * - * @var string|null - */ - protected $_charList; - - /** - * Sets filter options - * - * @param string|array|Zend_Config $charList - * @return void - */ - public function __construct($charList = null) - { - if ($charList instanceof Zend_Config) { - $charList = $charList->toArray(); - } else if (!is_array($charList)) { - $options = func_get_args(); - $temp['charlist'] = array_shift($options); - $options = $temp; - } - - if (array_key_exists('charlist', $options)) { - $this->setCharList($options['charlist']); - } - } - - /** - * Returns the charList option - * - * @return string|null - */ - public function getCharList() - { - return $this->_charList; - } - - /** - * Sets the charList option - * - * @param string|null $charList - * @return Zend_Filter_StringTrim Provides a fluent interface - */ - public function setCharList($charList) - { - $this->_charList = $charList; - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value with characters stripped from the beginning and end - * - * @param string $value - * @return string - */ - public function filter($value) - { - if (null === $this->_charList) { - return $this->_unicodeTrim((string) $value); - } else { - return $this->_unicodeTrim((string) $value, $this->_charList); - } - } - - /** - * Unicode aware trim method - * Fixes a PHP problem - * - * @param string $value - * @param string $charlist - * @return string - */ - protected function _unicodeTrim($value, $charlist = '\\\\s') - { - $chars = preg_replace( - array( '/[\^\-\]\\\]/S', '/\\\{4}/S', '/\//'), - array( '\\\\\\0', '\\', '\/' ), - $charlist - ); - - $pattern = '^[' . $chars . ']*|[' . $chars . ']*$'; - return preg_replace("/$pattern/sSD", '', $value); - } -} diff --git a/libs/Zend/Filter/StripNewlines.php b/libs/Zend/Filter/StripNewlines.php deleted file mode 100644 index 840669240d..0000000000 --- a/libs/Zend/Filter/StripNewlines.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StripNewlines.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StripNewlines implements Zend_Filter_Interface -{ - - /** - * Defined by Zend_Filter_Interface - * - * Returns $value without newline control characters - * - * @param string $value - * @return string - */ - public function filter ($value) - { - return str_replace(array("\n", "\r"), '', $value); - } -} diff --git a/libs/Zend/Filter/StripTags.php b/libs/Zend/Filter/StripTags.php deleted file mode 100644 index ebc213e60f..0000000000 --- a/libs/Zend/Filter/StripTags.php +++ /dev/null @@ -1,345 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: StripTags.php 22174 2010-05-14 22:12:50Z thomas $ - */ - - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Interface.php'; - - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_StripTags implements Zend_Filter_Interface -{ - /** - * Unique ID prefix used for allowing comments - */ - const UNIQUE_ID_PREFIX = '__Zend_Filter_StripTags__'; - - /** - * Whether comments are allowed - * - * If false (the default), then comments are removed from the input string. - * - * This setting is now deprecated, and ignored internally. - * - * @deprecated - * @var boolean - */ - public $commentsAllowed = false; - - /** - * Array of allowed tags and allowed attributes for each allowed tag - * - * Tags are stored in the array keys, and the array values are themselves - * arrays of the attributes allowed for the corresponding tag. - * - * @var array - */ - protected $_tagsAllowed = array(); - - /** - * Array of allowed attributes for all allowed tags - * - * Attributes stored here are allowed for all of the allowed tags. - * - * @var array - */ - protected $_attributesAllowed = array(); - - /** - * Sets the filter options - * Allowed options are - * 'allowTags' => Tags which are allowed - * 'allowAttribs' => Attributes which are allowed - * 'allowComments' => Are comments allowed ? - * - * @param string|array|Zend_Config $options - * @return void - */ - public function __construct($options = null) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if ((!is_array($options)) || (is_array($options) && !array_key_exists('allowTags', $options) && - !array_key_exists('allowAttribs', $options) && !array_key_exists('allowComments', $options))) { - $options = func_get_args(); - $temp['allowTags'] = array_shift($options); - if (!empty($options)) { - $temp['allowAttribs'] = array_shift($options); - } - - if (!empty($options)) { - $temp['allowComments'] = array_shift($options); - } - - $options = $temp; - } - - if (array_key_exists('allowTags', $options)) { - $this->setTagsAllowed($options['allowTags']); - } - - if (array_key_exists('allowAttribs', $options)) { - $this->setAttributesAllowed($options['allowAttribs']); - } - - if (array_key_exists('allowComments', $options)) { - $this->setCommentsAllowed($options['allowComments']); - } - } - - /** - * Returns the commentsAllowed option - * - * This setting is now deprecated and ignored internally. - * - * @deprecated - * @return bool - */ - public function getCommentsAllowed() - { - return $this->commentsAllowed; - } - - /** - * Sets the commentsAllowed option - * - * This setting is now deprecated and ignored internally. - * - * @deprecated - * @param boolean $commentsAllowed - * @return Zend_Filter_StripTags Provides a fluent interface - */ - public function setCommentsAllowed($commentsAllowed) - { - $this->commentsAllowed = (boolean) $commentsAllowed; - return $this; - } - - /** - * Returns the tagsAllowed option - * - * @return array - */ - public function getTagsAllowed() - { - return $this->_tagsAllowed; - } - - /** - * Sets the tagsAllowed option - * - * @param array|string $tagsAllowed - * @return Zend_Filter_StripTags Provides a fluent interface - */ - public function setTagsAllowed($tagsAllowed) - { - if (!is_array($tagsAllowed)) { - $tagsAllowed = array($tagsAllowed); - } - - foreach ($tagsAllowed as $index => $element) { - // If the tag was provided without attributes - if (is_int($index) && is_string($element)) { - // Canonicalize the tag name - $tagName = strtolower($element); - // Store the tag as allowed with no attributes - $this->_tagsAllowed[$tagName] = array(); - } - // Otherwise, if a tag was provided with attributes - else if (is_string($index) && (is_array($element) || is_string($element))) { - // Canonicalize the tag name - $tagName = strtolower($index); - // Canonicalize the attributes - if (is_string($element)) { - $element = array($element); - } - // Store the tag as allowed with the provided attributes - $this->_tagsAllowed[$tagName] = array(); - foreach ($element as $attribute) { - if (is_string($attribute)) { - // Canonicalize the attribute name - $attributeName = strtolower($attribute); - $this->_tagsAllowed[$tagName][$attributeName] = null; - } - } - } - } - - return $this; - } - - /** - * Returns the attributesAllowed option - * - * @return array - */ - public function getAttributesAllowed() - { - return $this->_attributesAllowed; - } - - /** - * Sets the attributesAllowed option - * - * @param array|string $attributesAllowed - * @return Zend_Filter_StripTags Provides a fluent interface - */ - public function setAttributesAllowed($attributesAllowed) - { - if (!is_array($attributesAllowed)) { - $attributesAllowed = array($attributesAllowed); - } - - // Store each attribute as allowed - foreach ($attributesAllowed as $attribute) { - if (is_string($attribute)) { - // Canonicalize the attribute name - $attributeName = strtolower($attribute); - $this->_attributesAllowed[$attributeName] = null; - } - } - - return $this; - } - - /** - * Defined by Zend_Filter_Interface - * - * @todo improve docblock descriptions - * - * @param string $value - * @return string - */ - public function filter($value) - { - $value = (string) $value; - - // Strip HTML comments first - while (strpos($value, '<!--') !== false) { - $pos = strrpos($value, '<!--'); - $start = substr($value, 0, $pos); - $value = substr($value, $pos); - $value = preg_replace('/<(?:!(?:--[\s\S]*?--\s*)?(>))/us', '', $value); - $value = $start . $value; - } - - // Initialize accumulator for filtered data - $dataFiltered = ''; - // Parse the input data iteratively as regular pre-tag text followed by a - // tag; either may be empty strings - preg_match_all('/([^<]*)(<?[^>]*>?)/', (string) $value, $matches); - - // Iterate over each set of matches - foreach ($matches[1] as $index => $preTag) { - // If the pre-tag text is non-empty, strip any ">" characters from it - if (strlen($preTag)) { - $preTag = str_replace('>', '', $preTag); - } - // If a tag exists in this match, then filter the tag - $tag = $matches[2][$index]; - if (strlen($tag)) { - $tagFiltered = $this->_filterTag($tag); - } else { - $tagFiltered = ''; - } - // Add the filtered pre-tag text and filtered tag to the data buffer - $dataFiltered .= $preTag . $tagFiltered; - } - - // Return the filtered data - return $dataFiltered; - } - - /** - * Filters a single tag against the current option settings - * - * @param string $tag - * @return string - */ - protected function _filterTag($tag) - { - // Parse the tag into: - // 1. a starting delimiter (mandatory) - // 2. a tag name (if available) - // 3. a string of attributes (if available) - // 4. an ending delimiter (if available) - $isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~', $tag, $matches); - - // If the tag does not match, then strip the tag entirely - if (!$isMatch) { - return ''; - } - - // Save the matches to more meaningfully named variables - $tagStart = $matches[1]; - $tagName = strtolower($matches[2]); - $tagAttributes = $matches[3]; - $tagEnd = $matches[5]; - - // If the tag is not an allowed tag, then remove the tag entirely - if (!isset($this->_tagsAllowed[$tagName])) { - return ''; - } - - // Trim the attribute string of whitespace at the ends - $tagAttributes = trim($tagAttributes); - - // If there are non-whitespace characters in the attribute string - if (strlen($tagAttributes)) { - // Parse iteratively for well-formed attributes - preg_match_all('/(\w+)\s*=\s*(?:(")(.*?)"|(\')(.*?)\')/s', $tagAttributes, $matches); - - // Initialize valid attribute accumulator - $tagAttributes = ''; - - // Iterate over each matched attribute - foreach ($matches[1] as $index => $attributeName) { - $attributeName = strtolower($attributeName); - $attributeDelimiter = empty($matches[2][$index]) ? $matches[4][$index] : $matches[2][$index]; - $attributeValue = empty($matches[3][$index]) ? $matches[5][$index] : $matches[3][$index]; - - // If the attribute is not allowed, then remove it entirely - if (!array_key_exists($attributeName, $this->_tagsAllowed[$tagName]) - && !array_key_exists($attributeName, $this->_attributesAllowed)) { - continue; - } - // Add the attribute to the accumulator - $tagAttributes .= " $attributeName=" . $attributeDelimiter - . $attributeValue . $attributeDelimiter; - } - } - - // Reconstruct tags ending with "/>" as backwards-compatible XHTML tag - if (strpos($tagEnd, '/') !== false) { - $tagEnd = " $tagEnd"; - } - - // Return the filtered tag - return $tagStart . $tagName . $tagAttributes . $tagEnd; - } -} diff --git a/libs/Zend/Filter/Word/CamelCaseToDash.php b/libs/Zend/Filter/Word/CamelCaseToDash.php deleted file mode 100644 index 838c372f42..0000000000 --- a/libs/Zend/Filter/Word/CamelCaseToDash.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CamelCaseToDash.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Word/CamelCaseToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_CamelCaseToDash extends Zend_Filter_Word_CamelCaseToSeparator -{ - /** - * Constructor - * - * @return void - */ - public function __construct() - { - parent::__construct('-'); - } -} diff --git a/libs/Zend/Filter/Word/CamelCaseToSeparator.php b/libs/Zend/Filter/Word/CamelCaseToSeparator.php deleted file mode 100644 index 5097460bb8..0000000000 --- a/libs/Zend/Filter/Word/CamelCaseToSeparator.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CamelCaseToSeparator.php 21089 2010-02-19 06:49:15Z thomas $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/Separator/Abstract.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_CamelCaseToSeparator extends Zend_Filter_Word_Separator_Abstract -{ - - public function filter($value) - { - if (self::isUnicodeSupportEnabled()) { - parent::setMatchPattern(array('#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#','#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#')); - parent::setReplacement(array($this->_separator . '\1', $this->_separator . '\1')); - } else { - parent::setMatchPattern(array('#(?<=(?:[A-Z]))([A-Z]+)([A-Z][A-z])#', '#(?<=(?:[a-z0-9]))([A-Z])#')); - parent::setReplacement(array('\1' . $this->_separator . '\2', $this->_separator . '\1')); - } - - return parent::filter($value); - } - -} diff --git a/libs/Zend/Filter/Word/CamelCaseToUnderscore.php b/libs/Zend/Filter/Word/CamelCaseToUnderscore.php deleted file mode 100644 index 5fbba3b44f..0000000000 --- a/libs/Zend/Filter/Word/CamelCaseToUnderscore.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: CamelCaseToUnderscore.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_CamelCaseToSeparator - */ -// require_once 'Zend/Filter/Word/CamelCaseToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_CamelCaseToUnderscore extends Zend_Filter_Word_CamelCaseToSeparator -{ - /** - * Constructor - * - * @return void - */ - public function __construct() - { - parent::__construct('_'); - } -} diff --git a/libs/Zend/Filter/Word/DashToCamelCase.php b/libs/Zend/Filter/Word/DashToCamelCase.php deleted file mode 100644 index 63d1bd6cff..0000000000 --- a/libs/Zend/Filter/Word/DashToCamelCase.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DashToCamelCase.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Word/SeparatorToCamelCase.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_DashToCamelCase extends Zend_Filter_Word_SeparatorToCamelCase -{ - /** - * Constructor - * - * @return void - */ - public function __construct() - { - parent::__construct('-'); - } -} diff --git a/libs/Zend/Filter/Word/DashToSeparator.php b/libs/Zend/Filter/Word/DashToSeparator.php deleted file mode 100644 index e9fd2814bc..0000000000 --- a/libs/Zend/Filter/Word/DashToSeparator.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DashToSeparator.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/Separator/Abstract.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_DashToSeparator extends Zend_Filter_Word_Separator_Abstract -{ - - public function filter($value) - { - $this->setMatchPattern('#-#'); - $this->setReplacement($this->_separator); - return parent::filter($value); - } -} diff --git a/libs/Zend/Filter/Word/DashToUnderscore.php b/libs/Zend/Filter/Word/DashToUnderscore.php deleted file mode 100644 index b5c583048c..0000000000 --- a/libs/Zend/Filter/Word/DashToUnderscore.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: DashToUnderscore.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/SeparatorToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_DashToUnderscore extends Zend_Filter_Word_SeparatorToSeparator -{ - /** - * Constructor - * - * @param string $separator Space by default - * @return void - */ - public function __construct() - { - parent::__construct('-', '_'); - } -} \ No newline at end of file diff --git a/libs/Zend/Filter/Word/Separator/Abstract.php b/libs/Zend/Filter/Word/Separator/Abstract.php deleted file mode 100644 index e3b7d4f8b7..0000000000 --- a/libs/Zend/Filter/Word/Separator/Abstract.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/PregReplace.php'; - -/** - * @category Zend - * @package Zend_Filter - * @uses Zend_Filter_PregReplace - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Filter_Word_Separator_Abstract extends Zend_Filter_PregReplace -{ - - protected $_separator = null; - - /** - * Constructor - * - * @param string $separator Space by default - * @return void - */ - public function __construct($separator = ' ') - { - $this->setSeparator($separator); - } - - /** - * Sets a new seperator - * - * @param string $separator Seperator - * @return $this - */ - public function setSeparator($separator) - { - if ($separator == null) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('"' . $separator . '" is not a valid separator.'); - } - $this->_separator = $separator; - return $this; - } - - /** - * Returns the actual set seperator - * - * @return string - */ - public function getSeparator() - { - return $this->_separator; - } - -} \ No newline at end of file diff --git a/libs/Zend/Filter/Word/SeparatorToCamelCase.php b/libs/Zend/Filter/Word/SeparatorToCamelCase.php deleted file mode 100644 index d407656663..0000000000 --- a/libs/Zend/Filter/Word/SeparatorToCamelCase.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SeparatorToCamelCase.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/Separator/Abstract.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_SeparatorToCamelCase extends Zend_Filter_Word_Separator_Abstract -{ - - public function filter($value) - { - // a unicode safe way of converting characters to \x00\x00 notation - $pregQuotedSeparator = preg_quote($this->_separator, '#'); - - if (self::isUnicodeSupportEnabled()) { - parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#e','#(^\p{Ll}{1})#e')); - parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')")); - } else { - parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([A-Za-z]{1})#e','#(^[A-Za-z]{1})#e')); - parent::setReplacement(array("strtoupper('\\2')","strtoupper('\\1')")); - } - - return parent::filter($value); - } - -} diff --git a/libs/Zend/Filter/Word/SeparatorToDash.php b/libs/Zend/Filter/Word/SeparatorToDash.php deleted file mode 100644 index 852b9c33c3..0000000000 --- a/libs/Zend/Filter/Word/SeparatorToDash.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SeparatorToDash.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_SeperatorToSeparator - */ -// require_once 'Zend/Filter/Word/SeparatorToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_SeparatorToDash extends Zend_Filter_Word_SeparatorToSeparator -{ - /** - * Constructor - * - * @param string $searchSeparator Seperator to search for change - * @return void - */ - public function __construct($searchSeparator = ' ') - { - parent::__construct($searchSeparator, '-'); - } - -} \ No newline at end of file diff --git a/libs/Zend/Filter/Word/SeparatorToSeparator.php b/libs/Zend/Filter/Word/SeparatorToSeparator.php deleted file mode 100644 index 66b2df0b49..0000000000 --- a/libs/Zend/Filter/Word/SeparatorToSeparator.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: SeparatorToSeparator.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/PregReplace.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_SeparatorToSeparator extends Zend_Filter_PregReplace -{ - - protected $_searchSeparator = null; - protected $_replacementSeparator = null; - - /** - * Constructor - * - * @param string $searchSeparator Seperator to search for - * @param string $replacementSeperator Seperator to replace with - * @return void - */ - public function __construct($searchSeparator = ' ', $replacementSeparator = '-') - { - $this->setSearchSeparator($searchSeparator); - $this->setReplacementSeparator($replacementSeparator); - } - - /** - * Sets a new seperator to search for - * - * @param string $separator Seperator to search for - * @return $this - */ - public function setSearchSeparator($separator) - { - $this->_searchSeparator = $separator; - return $this; - } - - /** - * Returns the actual set seperator to search for - * - * @return string - */ - public function getSearchSeparator() - { - return $this->_searchSeparator; - } - - /** - * Sets a new seperator which replaces the searched one - * - * @param string $separator Seperator which replaces the searched one - * @return $this - */ - public function setReplacementSeparator($separator) - { - $this->_replacementSeparator = $separator; - return $this; - } - - /** - * Returns the actual set seperator which replaces the searched one - * - * @return string - */ - public function getReplacementSeparator() - { - return $this->_replacementSeparator; - } - - /** - * Defined by Zend_Filter_Interface - * - * Returns the string $value, replacing the searched seperators with the defined ones - * - * @param string $value - * @return string - */ - public function filter($value) - { - return $this->_separatorToSeparatorFilter($value); - } - - /** - * Do the real work, replaces the seperator to search for with the replacement seperator - * - * Returns the replaced string - * - * @param string $value - * @return string - */ - protected function _separatorToSeparatorFilter($value) - { - if ($this->_searchSeparator == null) { - // require_once 'Zend/Filter/Exception.php'; - throw new Zend_Filter_Exception('You must provide a search separator for this filter to work.'); - } - - $this->setMatchPattern('#' . preg_quote($this->_searchSeparator, '#') . '#'); - $this->setReplacement($this->_replacementSeparator); - return parent::filter($value); - } - -} \ No newline at end of file diff --git a/libs/Zend/Filter/Word/UnderscoreToCamelCase.php b/libs/Zend/Filter/Word/UnderscoreToCamelCase.php deleted file mode 100644 index d5bae5088b..0000000000 --- a/libs/Zend/Filter/Word/UnderscoreToCamelCase.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UnderscoreToCamelCase.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_Interface - */ -// require_once 'Zend/Filter/Word/SeparatorToCamelCase.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_UnderscoreToCamelCase extends Zend_Filter_Word_SeparatorToCamelCase -{ - /** - * Constructor - * - * @return void - */ - public function __construct() - { - parent::__construct('_'); - } -} diff --git a/libs/Zend/Filter/Word/UnderscoreToDash.php b/libs/Zend/Filter/Word/UnderscoreToDash.php deleted file mode 100644 index 52a2f7e3fb..0000000000 --- a/libs/Zend/Filter/Word/UnderscoreToDash.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UnderscoreToDash.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/SeparatorToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_UnderscoreToDash extends Zend_Filter_Word_SeparatorToSeparator -{ - /** - * Constructor - * - * @param string $separator Space by default - * @return void - */ - public function __construct() - { - parent::__construct('_', '-'); - } -} \ No newline at end of file diff --git a/libs/Zend/Filter/Word/UnderscoreToSeparator.php b/libs/Zend/Filter/Word/UnderscoreToSeparator.php deleted file mode 100644 index c8fee7d100..0000000000 --- a/libs/Zend/Filter/Word/UnderscoreToSeparator.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@zend.com so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: UnderscoreToSeparator.php 20096 2010-01-06 02:05:09Z bkarwin $ - */ - -/** - * @see Zend_Filter_PregReplace - */ -// require_once 'Zend/Filter/Word/SeparatorToSeparator.php'; - -/** - * @category Zend - * @package Zend_Filter - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -class Zend_Filter_Word_UnderscoreToSeparator extends Zend_Filter_Word_SeparatorToSeparator -{ - /** - * Constructor - * - * @param string $separator Space by default - * @return void - */ - public function __construct($replacementSeparator = ' ') - { - parent::__construct('_', $replacementSeparator); - } -} -- GitLab