Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Validate/File/IsImage.php')
-rw-r--r--libs/Zend/Validate/File/IsImage.php145
1 files changed, 114 insertions, 31 deletions
diff --git a/libs/Zend/Validate/File/IsImage.php b/libs/Zend/Validate/File/IsImage.php
index 3904af1f90..d602ebe763 100644
--- a/libs/Zend/Validate/File/IsImage.php
+++ b/libs/Zend/Validate/File/IsImage.php
@@ -14,22 +14,22 @@
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @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: IsImage.php 18148 2009-09-16 19:27:43Z thomas $
+ * @version $Id: IsImage.php 21138 2010-02-22 22:37:11Z thomas $
*/
/**
* @see Zend_Validate_File_MimeType
*/
-require_once 'Zend/Validate/File/MimeType.php';
+// require_once 'Zend/Validate/File/MimeType.php';
/**
* Validator which checks if the file already exists in the directory
*
* @category Zend
* @package Zend_Validate
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @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_Validate_File_IsImage extends Zend_Validate_File_MimeType
@@ -45,9 +45,9 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType
* @var array Error message templates
*/
protected $_messageTemplates = array(
- self::FALSE_TYPE => "The file '%value%' is no image, '%type%' detected",
- self::NOT_DETECTED => "The mimetype of file '%value%' has not been detected",
- self::NOT_READABLE => "The file '%value%' can not be read"
+ self::FALSE_TYPE => "File '%value%' is no image, '%type%' detected",
+ self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected",
+ self::NOT_READABLE => "File '%value%' can not be read",
);
/**
@@ -60,31 +60,114 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType
{
if ($mimetype instanceof Zend_Config) {
$mimetype = $mimetype->toArray();
- } else if (empty($mimetype)) {
- $mimetype = array(
- 'image/x-quicktime',
- 'image/jp2',
- 'image/x-xpmi',
- 'image/x-portable-bitmap',
- 'image/x-portable-greymap',
- 'image/x-portable-pixmap',
- 'image/x-niff',
- 'image/tiff',
- 'image/png',
- 'image/x-unknown',
- 'image/gif',
- 'image/x-ms-bmp',
- 'application/dicom',
- 'image/vnd.adobe.photoshop',
- 'image/vnd.djvu',
- 'image/x-cpi',
- 'image/jpeg',
- 'image/x-ico',
- 'image/x-coreldraw',
- 'image/svg+xml'
- );
}
- $this->setMimeType($mimetype);
+ $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;
}
}