diff options
author | robocoder <anthon.pang@gmail.com> | 2009-09-23 08:37:04 +0400 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2009-09-23 08:37:04 +0400 |
commit | a0d6f1cd6f548cac513442dcb69669e9107188bd (patch) | |
tree | deab55167e5d3d841b3b3d3f164059f829e6ea55 /libs/Zend/Validate | |
parent | f99e1ebf35eb2de8ea536aed146bdc076f08c07c (diff) |
refs #497 - update to ZF 1.9.3PL1 (patchlevel 1)
git-svn-id: http://dev.piwik.org/svn/trunk@1481 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend/Validate')
-rw-r--r-- | libs/Zend/Validate/Abstract.php | 13 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Count.php | 8 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Crc32.php | 4 | ||||
-rw-r--r-- | libs/Zend/Validate/File/ExcludeMimeType.php | 32 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Exists.php | 4 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Extension.php | 8 | ||||
-rw-r--r-- | libs/Zend/Validate/File/FilesSize.php | 26 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Hash.php | 5 | ||||
-rw-r--r-- | libs/Zend/Validate/File/ImageSize.php | 10 | ||||
-rw-r--r-- | libs/Zend/Validate/File/IsCompressed.php | 57 | ||||
-rw-r--r-- | libs/Zend/Validate/File/IsImage.php | 57 | ||||
-rw-r--r-- | libs/Zend/Validate/File/MimeType.php | 89 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Size.php | 5 | ||||
-rw-r--r-- | libs/Zend/Validate/File/Upload.php | 8 | ||||
-rw-r--r-- | libs/Zend/Validate/NotEmpty.php | 8 |
15 files changed, 151 insertions, 183 deletions
diff --git a/libs/Zend/Validate/Abstract.php b/libs/Zend/Validate/Abstract.php index 0d0abbd8ab..68acf2e67b 100644 --- a/libs/Zend/Validate/Abstract.php +++ b/libs/Zend/Validate/Abstract.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 16223 2009-06-21 20:04:53Z thomas $ + * @version $Id: Abstract.php 17846 2009-08-27 17:38:13Z thomas $ */ /** @@ -142,12 +142,17 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface { if ($messageKey === null) { $keys = array_keys($this->_messageTemplates); - $messageKey = current($keys); + foreach($keys as $key) { + $this->setMessage($messageString, $key); + } + return $this; } + if (!isset($this->_messageTemplates[$messageKey])) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("No message template exists for key '$messageKey'"); } + $this->_messageTemplates[$messageKey] = $messageString; return $this; } @@ -246,11 +251,11 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface } /** - * @param string $messageKey OPTIONAL + * @param string $messageKey * @param string $value OPTIONAL * @return void */ - protected function _error($messageKey = null, $value = null) + protected function _error($messageKey, $value = null) { if ($messageKey === null) { $keys = array_keys($this->_messageTemplates); diff --git a/libs/Zend/Validate/File/Count.php b/libs/Zend/Validate/File/Count.php index d49801b070..f2dfac7413 100644 --- a/libs/Zend/Validate/File/Count.php +++ b/libs/Zend/Validate/File/Count.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Count.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Count.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -100,8 +100,7 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract * 'min': Minimum filecount * 'max': Maximum filecount * - * @param integer|array $options Options for the adapter - * @param integer $max (Deprecated) Maximum value (implies $options is the minimum) + * @param integer|array|Zend_Config $options Options for the adapter * @return void */ public function __construct($options) @@ -116,7 +115,8 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract } if (1 < func_num_args()) { - trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE); +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE); $options['min'] = func_get_arg(0); $options['max'] = func_get_arg(1); } diff --git a/libs/Zend/Validate/File/Crc32.php b/libs/Zend/Validate/File/Crc32.php index 2bcfe6e90c..fd46d81b6b 100644 --- a/libs/Zend/Validate/File/Crc32.php +++ b/libs/Zend/Validate/File/Crc32.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Crc32.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Crc32.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -60,7 +60,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash /** * Sets validator options * - * @param string|array $options + * @param string|array|Zend_Config $options * @return void */ public function __construct($options) diff --git a/libs/Zend/Validate/File/ExcludeMimeType.php b/libs/Zend/Validate/File/ExcludeMimeType.php index 4c71a69ace..4984b79cfb 100644 --- a/libs/Zend/Validate/File/ExcludeMimeType.php +++ b/libs/Zend/Validate/File/ExcludeMimeType.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ExcludeMimeType.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: ExcludeMimeType.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -51,20 +51,38 @@ class Zend_Validate_File_ExcludeMimeType extends Zend_Validate_File_MimeType */ public function isValid($value, $file = null) { + if ($file === null) { + $file = array( + 'type' => null, + 'name' => $value + ); + } + // Is file readable ? require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } - if ($file !== null) { - if (class_exists('finfo', false) && defined('MAGIC')) { - $mime = new finfo(FILEINFO_MIME); + $mimefile = $this->getMagicFile(); + if (class_exists('finfo', false)) { + $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; + if (!empty($mimefile)) { + $mime = new finfo($const, $mimefile); + } else { + $mime = new finfo($const); + } + + if ($mime !== false) { $this->_type = $mime->file($value); - unset($mime); - } elseif (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { + } + unset($mime); + } + + if (empty($this->_type)) { + if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { $this->_type = mime_content_type($value); - } else { + } elseif ($this->_headerCheck) { $this->_type = $file['type']; } } diff --git a/libs/Zend/Validate/File/Exists.php b/libs/Zend/Validate/File/Exists.php index f58cd23c1e..835b4c2c70 100644 --- a/libs/Zend/Validate/File/Exists.php +++ b/libs/Zend/Validate/File/Exists.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Exists.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Exists.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -62,7 +62,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract /** * Sets validator options * - * @param string|array $directory + * @param string|array|Zend_Config $directory * @return void */ public function __construct($directory = array()) diff --git a/libs/Zend/Validate/File/Extension.php b/libs/Zend/Validate/File/Extension.php index f200559565..58ab0b21af 100644 --- a/libs/Zend/Validate/File/Extension.php +++ b/libs/Zend/Validate/File/Extension.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Extension.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Extension.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -71,8 +71,7 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract /** * Sets validator options * - * @param string|array $extension - * @param boolean $case If true validation is done case sensitive + * @param string|array|Zend_Config $options * @return void */ public function __construct($options) @@ -82,7 +81,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract } if (1 < func_num_args()) { - trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE); +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE); $case = func_get_arg(1); $this->setCase($case); } diff --git a/libs/Zend/Validate/File/FilesSize.php b/libs/Zend/Validate/File/FilesSize.php index 3dbb28ff4e..167304b771 100644 --- a/libs/Zend/Validate/File/FilesSize.php +++ b/libs/Zend/Validate/File/FilesSize.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FilesSize.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: FilesSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -63,9 +63,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size * Min limits the used diskspace for all files, when used with max=null it is the maximum filesize * It also accepts an array with the keys 'min' and 'max' * - * @param integer|array $min Minimum diskspace for all files - * @param integer $max Maximum diskspace for all files (deprecated) - * @param boolean $bytestring Use bytestring or real size ? (deprecated) + * @param integer|array|Zend_Config $options Options for this validator * @return void */ public function __construct($options) @@ -73,16 +71,18 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size $this->_files = array(); $this->_setSize(0); + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } elseif (is_scalar($options)) { + $options = array('max' => $options); + } elseif (!is_array($options)) { + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception('Invalid options to validator provided'); + } + if (1 < func_num_args()) { - trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } elseif (is_scalar($options)) { - $options = array('min' => $options); - } elseif (!is_array($options)) { - require_once 'Zend/Validate/Exception.php'; - throw new Zend_Validate_Exception('Invalid options to validator provided'); - } +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $argv = func_get_args(); array_shift($argv); diff --git a/libs/Zend/Validate/File/Hash.php b/libs/Zend/Validate/File/Hash.php index c8767772ee..d2e8c2c645 100644 --- a/libs/Zend/Validate/File/Hash.php +++ b/libs/Zend/Validate/File/Hash.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Hash.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Hash.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -75,7 +75,8 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract } if (1 < func_num_args()) { - trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $options['algorithm'] = func_get_arg(1); } diff --git a/libs/Zend/Validate/File/ImageSize.php b/libs/Zend/Validate/File/ImageSize.php index 70d845348e..c01ec97341 100644 --- a/libs/Zend/Validate/File/ImageSize.php +++ b/libs/Zend/Validate/File/ImageSize.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ImageSize.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: ImageSize.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -124,15 +124,11 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract */ public function __construct($options) { - $minwidth = 0; - $minheight = 0; - $maxwidth = null; - $maxheight = null; - if ($options instanceof Zend_Config) { $options = $options->toArray(); } elseif (1 < func_num_args()) { - trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); if (!is_array($options)) { $options = array('minwidth' => $options); } diff --git a/libs/Zend/Validate/File/IsCompressed.php b/libs/Zend/Validate/File/IsCompressed.php index be1e529b13..3254d57341 100644 --- a/libs/Zend/Validate/File/IsCompressed.php +++ b/libs/Zend/Validate/File/IsCompressed.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsCompressed.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: IsCompressed.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -53,12 +53,14 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType /** * Sets validator options * - * @param string|array $compression + * @param string|array|Zend_Config $compression * @return void */ public function __construct($mimetype = array()) { - if (empty($mimetype)) { + if ($mimetype instanceof Zend_Config) { + $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { $mimetype = array( 'application/x-tar', 'application/x-cpio', @@ -81,53 +83,4 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType $this->setMimeType($mimetype); } - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if the file is compression with the set compression types - * - * @param string $value Real file to check for compression - * @param array $file File data from Zend_File_Transfer - * @return boolean - */ - public function isValid($value, $file = null) - { - // Is file readable ? - require_once 'Zend/Loader.php'; - if (!Zend_Loader::isReadable($value)) { - return $this->_throw($file, self::NOT_READABLE); - } - - if ($file !== null) { - if (class_exists('finfo', false) && defined('MAGIC')) { - $mime = new finfo(FILEINFO_MIME); - $this->_type = $mime->file($value); - unset($mime); - } elseif (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { - $this->_type = mime_content_type($value); - } else { - $this->_type = $file['type']; - } - } - - if (empty($this->_type)) { - return $this->_throw($file, self::NOT_DETECTED); - } - - $compressions = $this->getMimeType(true); - if (in_array($this->_type, $compressions)) { - return true; - } - - $types = explode('/', $this->_type); - $types = array_merge($types, explode('-', $this->_type)); - foreach ($compressions as $mime) { - if (in_array($mime, $types)) { - return true; - } - } - - return $this->_throw($file, self::FALSE_TYPE); - } } diff --git a/libs/Zend/Validate/File/IsImage.php b/libs/Zend/Validate/File/IsImage.php index acbe2f124a..3904af1f90 100644 --- a/libs/Zend/Validate/File/IsImage.php +++ b/libs/Zend/Validate/File/IsImage.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: IsImage.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: IsImage.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -53,12 +53,14 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType /** * Sets validator options * - * @param string|array $mimetype + * @param string|array|Zend_Config $mimetype * @return void */ public function __construct($mimetype = array()) { - if (empty($mimetype)) { + if ($mimetype instanceof Zend_Config) { + $mimetype = $mimetype->toArray(); + } else if (empty($mimetype)) { $mimetype = array( 'image/x-quicktime', 'image/jp2', @@ -85,53 +87,4 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType $this->setMimeType($mimetype); } - - /** - * Defined by Zend_Validate_Interface - * - * Returns true if and only if the file is compression with the set compression types - * - * @param string $value Real file to check for compression - * @param array $file File data from Zend_File_Transfer - * @return boolean - */ - public function isValid($value, $file = null) - { - // Is file readable ? - require_once 'Zend/Loader.php'; - if (!Zend_Loader::isReadable($value)) { - return $this->_throw($file, self::NOT_READABLE); - } - - if ($file !== null) { - if (class_exists('finfo', false) && defined('MAGIC')) { - $mime = new finfo(FILEINFO_MIME); - $this->_type = $mime->file($value); - unset($mime); - } elseif (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { - $this->_type = mime_content_type($value); - } else { - $this->_type = $file['type']; - } - } - - if (empty($this->_type)) { - return $this->_throw($file, self::NOT_DETECTED); - } - - $compressions = $this->getMimeType(true); - if (in_array($this->_type, $compressions)) { - return true; - } - - $types = explode('/', $this->_type); - $types = array_merge($types, explode('-', $this->_type)); - foreach($compressions as $mime) { - if (in_array($mime, $types)) { - return true; - } - } - - return $this->_throw($file, self::FALSE_TYPE); - } } diff --git a/libs/Zend/Validate/File/MimeType.php b/libs/Zend/Validate/File/MimeType.php index 5086de0e2c..5b9cba2b77 100644 --- a/libs/Zend/Validate/File/MimeType.php +++ b/libs/Zend/Validate/File/MimeType.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: MimeType.php 17203 2009-07-27 19:37:18Z thomas $ + * @version $Id: MimeType.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -80,6 +80,13 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract protected $_magicfile; /** + * Option to allow header check + * + * @var boolean + */ + protected $_headerCheck = false; + + /** * Sets validator options * * Mimetype to accept @@ -102,11 +109,15 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract $this->setMagicFile($mimetype['magicfile']); } + if (isset($mimetype['headerCheck'])) { + $this->enableHeaderCheck(true); + } + $this->setMimeType($mimetype); } /** - * Returna the actual set magicfile + * Returns the actual set magicfile * * @return string */ @@ -137,6 +148,29 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract } /** + * Returns the Header Check option + * + * @return boolean + */ + public function getHeaderCheck() + { + return $this->_headerCheck; + } + + /** + * Defines if the http header should be used + * Note that this is unsave and therefor the default value is false + * + * @param boolean $checkHeader + * @return Zend_Validate_File_MimeType Provides fluid interface + */ + public function enableHeaderCheck($headerCheck = true) + { + $this->_headerCheck = (boolean) $headerCheck; + return $this; + } + + /** * Returns the set mimetypes * * @param boolean $asArray Returns the values as array, when false an concated string is returned @@ -220,35 +254,39 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract */ public function isValid($value, $file = null) { + if ($file === null) { + $file = array( + 'type' => null, + 'name' => $value + ); + } + // Is file readable ? require_once 'Zend/Loader.php'; if (!Zend_Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } - if ($file !== null) { - $mimefile = $this->getMagicFile(); - if (class_exists('finfo', false)) { - $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; - if (!empty($mimefile)) { - $mime = new finfo($const, $mimefile); - } else { - $mime = new finfo($const); - } - - if ($mime !== false) { - $this->_type = $mime->file($value); - } - - unset($mime); + $mimefile = $this->getMagicFile(); + if (class_exists('finfo', false)) { + $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; + if (!empty($mimefile)) { + $mime = new finfo($const, $mimefile); + } else { + $mime = new finfo($const); } - if (empty($this->_type)) { - if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { - $this->_type = mime_content_type($value); - } else { - $this->_type = $file['type']; - } + if ($mime !== false) { + $this->_type = $mime->file($value); + } + unset($mime); + } + + if (empty($this->_type)) { + if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { + $this->_type = mime_content_type($value); + } elseif ($this->_headerCheck) { + $this->_type = $file['type']; } } @@ -281,10 +319,7 @@ class Zend_Validate_File_MimeType extends Zend_Validate_Abstract */ protected function _throw($file, $errorType) { - if ($file !== null) { - $this->_value = $file['name']; - } - + $this->_value = $file['name']; $this->_error($errorType); return false; } diff --git a/libs/Zend/Validate/File/Size.php b/libs/Zend/Validate/File/Size.php index 44cc246588..4c41178966 100644 --- a/libs/Zend/Validate/File/Size.php +++ b/libs/Zend/Validate/File/Size.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Size.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Size.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -112,7 +112,8 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract } if (1 < func_num_args()) { - trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); +// @todo: Preperation for 2.0... needs to be cleared with the dev-team +// trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE); $argv = func_get_args(); array_shift($argv); $options['max'] = array_shift($argv); diff --git a/libs/Zend/Validate/File/Upload.php b/libs/Zend/Validate/File/Upload.php index 8c6825251e..fd1bdfe754 100644 --- a/libs/Zend/Validate/File/Upload.php +++ b/libs/Zend/Validate/File/Upload.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Upload.php 16971 2009-07-22 18:05:45Z mikaelkael $ + * @version $Id: Upload.php 18148 2009-09-16 19:27:43Z thomas $ */ /** @@ -78,11 +78,15 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract * If no files are given the $_FILES array will be used automatically. * NOTE: This validator will only work with HTTP POST uploads! * - * @param array $files Array of files in syntax of Zend_File_Transfer + * @param array|Zend_Config $files Array of files in syntax of Zend_File_Transfer * @return void */ public function __construct($files = array()) { + if ($files instanceof Zend_Config) { + $files = $files->toArray(); + } + $this->setFiles($files); } diff --git a/libs/Zend/Validate/NotEmpty.php b/libs/Zend/Validate/NotEmpty.php index 2d09913e37..304cf4fe70 100644 --- a/libs/Zend/Validate/NotEmpty.php +++ b/libs/Zend/Validate/NotEmpty.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: NotEmpty.php 17680 2009-08-19 20:02:26Z thomas $ + * @version $Id: NotEmpty.php 18186 2009-09-17 18:57:00Z matthew $ */ /** @@ -53,8 +53,8 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract */ public function isValid($value) { - if (!is_string($value) && !is_int($value) && !is_float($value) && !is_bool($value) && - !is_array($value)) { + if (!is_null($value) && !is_string($value) && !is_int($value) && !is_float($value) && + !is_bool($value) && !is_array($value)) { $this->_error(self::INVALID); return false; } @@ -66,6 +66,8 @@ class Zend_Validate_NotEmpty extends Zend_Validate_Abstract ) { $this->_error(self::IS_EMPTY); return false; + } elseif (is_int($value) && (0 === $value)) { + return true; } elseif (!is_string($value) && empty($value)) { $this->_error(self::IS_EMPTY); return false; |