3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Validator\File
;
13 use Zend\Stdlib\ArrayUtils
;
16 * Validator which checks if the file already exists in the directory
18 class IsImage
extends MimeType
21 * @const string Error constants
23 const FALSE_TYPE
= 'fileIsImageFalseType';
24 const NOT_DETECTED
= 'fileIsImageNotDetected';
25 const NOT_READABLE
= 'fileIsImageNotReadable';
28 * @var array Error message templates
30 protected $messageTemplates = array(
31 self
::FALSE_TYPE
=> "File is no image, '%type%' detected",
32 self
::NOT_DETECTED
=> "The mimetype could not be detected from the file",
33 self
::NOT_READABLE
=> "File is not readable or does not exist",
37 * Sets validator options
39 * @param array|Traversable|string $options
41 public function __construct($options = array())
43 // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen
44 // http://www.iana.org/assignments/media-types/image/
48 'application/fractals',
49 'application/postscript',
50 'application/vnd.hp-hpgl',
51 'application/vnd.oasis.opendocument.graphics',
53 'application/x-cmu-raster',
55 'application/x-inventor',
57 'application/x-portable-anymap',
58 'application/x-world-x-3dmf',
74 'image/vnd.adobe.photoshop',
91 'image/x-portable-anymap',
92 'image/x-portable-bitmap',
93 'image/x-portable-greymap',
94 'image/x-portable-pixmap',
99 'image/x-windows-bmp',
103 if ($options instanceof Traversable
) {
104 $options = ArrayUtils
::iteratorToArray($options);
107 if ($options === null) {
111 parent
::__construct($options);
113 if (!$this->getMimeType()) {
114 $this->setMimeType($default);