Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Zend_Validate_File_IsImage Class Reference
Inheritance diagram for Zend_Validate_File_IsImage:
Zend_Validate_File_MimeType Zend_Validate_Abstract Zend_Validate_Interface IsImage

Public Member Functions

 __construct ($mimetype=array())
 
- Public Member Functions inherited from Zend_Validate_File_MimeType
 __construct ($mimetype)
 
 getMagicFile ()
 
 setMagicFile ($file)
 
 setTryCommonMagicFilesFlag ($flag=true)
 
 shouldTryCommonMagicFiles ()
 
 getHeaderCheck ()
 
 enableHeaderCheck ($headerCheck=true)
 
 getMimeType ($asArray=false)
 
 setMimeType ($mimetype)
 
 addMimeType ($mimetype)
 
 isValid ($value, $file=null)
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 
 getMessageVariables ()
 
 getMessageTemplates ()
 
 setMessage ($messageString, $messageKey=null)
 
 setMessages (array $messages)
 
 __get ($property)
 
 getErrors ()
 
 setObscureValue ($flag)
 
 getObscureValue ()
 
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 setDisableTranslator ($flag)
 
 translatorIsDisabled ()
 
- Public Member Functions inherited from Zend_Validate_Interface
 isValid ($value)
 

Data Fields

const FALSE_TYPE = 'fileIsImageFalseType'
 
const NOT_DETECTED = 'fileIsImageNotDetected'
 
const NOT_READABLE = 'fileIsImageNotReadable'
 
- Data Fields inherited from Zend_Validate_File_MimeType
const FALSE_TYPE = 'fileMimeTypeFalse'
 
const NOT_DETECTED = 'fileMimeTypeNotDetected'
 
const NOT_READABLE = 'fileMimeTypeNotReadable'
 

Protected Member Functions

 _throw ($file, $errorType)
 
- Protected Member Functions inherited from Zend_Validate_File_MimeType
 _throw ($file, $errorType)
 
 _detectMimeType ($file)
 
 _errorHandler ($errno, $errstr, $errfile, $errline)
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 
 _implodeRecursive (array $pieces)
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 

Protected Attributes

 $_messageTemplates
 
- Protected Attributes inherited from Zend_Validate_File_MimeType
 $_messageTemplates
 
 $_messageVariables
 
 $_type
 
 $_mimetype
 
 $_magicfile
 
 $_finfo
 
 $_magicFiles
 
 $_tryCommonMagicFiles = true
 
 $_headerCheck = false
 
 $_finfoError
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 
static getDefaultTranslator ()
 
static hasDefaultTranslator ()
 
static getMessageLength ()
 
static setMessageLength ($length=-1)
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Detailed Description

Definition at line 35 of file IsImage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $mimetype = array())

Sets validator options

Parameters
string | array | Zend_Config$mimetype

Definition at line 58 of file IsImage.php.

59  {
60  if ($mimetype instanceof Zend_Config) {
61  $mimetype = $mimetype->toArray();
62  }
63 
64  $temp = array();
65  // http://de.wikipedia.org/wiki/Liste_von_Dateiendungen
66  // http://www.iana.org/assignments/media-types/image/
67  $default = array(
68  'application/cdf',
69  'application/dicom',
70  'application/fractals',
71  'application/postscript',
72  'application/vnd.hp-hpgl',
73  'application/vnd.oasis.opendocument.graphics',
74  'application/x-cdf',
75  'application/x-cmu-raster',
76  'application/x-ima',
77  'application/x-inventor',
78  'application/x-koan',
79  'application/x-portable-anymap',
80  'application/x-world-x-3dmf',
81  'image/bmp',
82  'image/c',
83  'image/cgm',
84  'image/fif',
85  'image/gif',
86  'image/jpeg',
87  'image/jpm',
88  'image/jpx',
89  'image/jp2',
90  'image/naplps',
91  'image/pjpeg',
92  'image/png',
93  'image/svg',
94  'image/svg+xml',
95  'image/tiff',
96  'image/vnd.adobe.photoshop',
97  'image/vnd.djvu',
98  'image/vnd.fpx',
99  'image/vnd.net-fpx',
100  'image/x-cmu-raster',
101  'image/x-cmx',
102  'image/x-coreldraw',
103  'image/x-cpi',
104  'image/x-emf',
105  'image/x-ico',
106  'image/x-icon',
107  'image/x-jg',
108  'image/x-ms-bmp',
109  'image/x-niff',
110  'image/x-pict',
111  'image/x-pcx',
112  'image/x-portable-anymap',
113  'image/x-portable-bitmap',
114  'image/x-portable-greymap',
115  'image/x-portable-pixmap',
116  'image/x-quicktime',
117  'image/x-rgb',
118  'image/x-tiff',
119  'image/x-unknown',
120  'image/x-windows-bmp',
121  'image/x-xpmi',
122  );
123 
124  if (is_array($mimetype)) {
125  $temp = $mimetype;
126  if (array_key_exists('magicfile', $temp)) {
127  unset($temp['magicfile']);
128  }
129 
130  if (array_key_exists('headerCheck', $temp)) {
131  unset($temp['headerCheck']);
132  }
133 
134  if (empty($temp)) {
135  $mimetype += $default;
136  }
137  }
138 
139  if (empty($mimetype)) {
140  $mimetype = $default;
141  }
142 
143  parent::__construct($mimetype);
144  }

Member Function Documentation

◆ _throw()

_throw (   $file,
  $errorType 
)
protected

Throws an error of the given type Duplicates parent method due to OOP Problem with late static binding in PHP 5.2

Parameters
string$file
string$errorType
Returns
false

Definition at line 154 of file IsImage.php.

155  {
156  $this->_value = $file['name'];
157  switch($errorType) {
159  $errorType = self::FALSE_TYPE;
160  break;
162  $errorType = self::NOT_DETECTED;
163  break;
165  $errorType = self::NOT_READABLE;
166  break;
167  }
168 
169  $this->_error($errorType);
170  return false;
171  }
_error($messageKey, $value=null)
Definition: Abstract.php:284

Field Documentation

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
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%' is not readable or does not exist",
)

Definition at line 47 of file IsImage.php.

◆ FALSE_TYPE

const FALSE_TYPE = 'fileIsImageFalseType'

@const string Error constants

Definition at line 40 of file IsImage.php.

◆ NOT_DETECTED

const NOT_DETECTED = 'fileIsImageNotDetected'

Definition at line 41 of file IsImage.php.

◆ NOT_READABLE

const NOT_READABLE = 'fileIsImageNotReadable'

Definition at line 42 of file IsImage.php.


The documentation for this class was generated from the following file: