From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Validate/File/IsImage.php | 171 ++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 library/vendor/Zend/Validate/File/IsImage.php (limited to 'library/vendor/Zend/Validate/File/IsImage.php') diff --git a/library/vendor/Zend/Validate/File/IsImage.php b/library/vendor/Zend/Validate/File/IsImage.php new file mode 100644 index 0000000..a87f1a6 --- /dev/null +++ b/library/vendor/Zend/Validate/File/IsImage.php @@ -0,0 +1,171 @@ + "File '%value%' is no image, '%type%' detected", + self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected", + self::NOT_READABLE => "File '%value%' is not readable or does not exist", + ); + + /** + * Sets validator options + * + * @param string|array|Zend_Config $mimetype + */ + public function __construct($mimetype = array()) + { + if ($mimetype instanceof Zend_Config) { + $mimetype = $mimetype->toArray(); + } + + $temp = array(); + // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen + // http://www.iana.org/assignments/media-types/image/ + $default = array( + 'application/cdf', + 'application/dicom', + 'application/fractals', + 'application/postscript', + 'application/vnd.hp-hpgl', + 'application/vnd.oasis.opendocument.graphics', + 'application/x-cdf', + 'application/x-cmu-raster', + 'application/x-ima', + 'application/x-inventor', + 'application/x-koan', + 'application/x-portable-anymap', + 'application/x-world-x-3dmf', + 'image/bmp', + 'image/c', + 'image/cgm', + 'image/fif', + 'image/gif', + 'image/jpeg', + 'image/jpm', + 'image/jpx', + 'image/jp2', + 'image/naplps', + 'image/pjpeg', + 'image/png', + 'image/svg', + 'image/svg+xml', + 'image/tiff', + 'image/vnd.adobe.photoshop', + 'image/vnd.djvu', + 'image/vnd.fpx', + 'image/vnd.net-fpx', + 'image/x-cmu-raster', + 'image/x-cmx', + 'image/x-coreldraw', + 'image/x-cpi', + 'image/x-emf', + 'image/x-ico', + 'image/x-icon', + 'image/x-jg', + 'image/x-ms-bmp', + 'image/x-niff', + 'image/x-pict', + 'image/x-pcx', + 'image/x-portable-anymap', + 'image/x-portable-bitmap', + 'image/x-portable-greymap', + 'image/x-portable-pixmap', + 'image/x-quicktime', + 'image/x-rgb', + 'image/x-tiff', + 'image/x-unknown', + 'image/x-windows-bmp', + 'image/x-xpmi', + ); + + if (is_array($mimetype)) { + $temp = $mimetype; + if (array_key_exists('magicfile', $temp)) { + unset($temp['magicfile']); + } + + if (array_key_exists('headerCheck', $temp)) { + unset($temp['headerCheck']); + } + + if (empty($temp)) { + $mimetype += $default; + } + } + + if (empty($mimetype)) { + $mimetype = $default; + } + + parent::__construct($mimetype); + } + + /** + * Throws an error of the given type + * Duplicates parent method due to OOP Problem with late static binding in PHP 5.2 + * + * @param string $file + * @param string $errorType + * @return false + */ + protected function _throw($file, $errorType) + { + $this->_value = $file['name']; + switch($errorType) { + case Zend_Validate_File_MimeType::FALSE_TYPE : + $errorType = self::FALSE_TYPE; + break; + case Zend_Validate_File_MimeType::NOT_DETECTED : + $errorType = self::NOT_DETECTED; + break; + case Zend_Validate_File_MimeType::NOT_READABLE : + $errorType = self::NOT_READABLE; + break; + } + + $this->_error($errorType); + return false; + } +} -- cgit v1.2.3