Validator which checks if the file already exists in the directory

category Zend
package Zend_Validate
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Validate_File_MimeType

 Methods

Sets validator options

__construct(string|array|\Zend_Config $mimetype = array()

Mimetype to accept

inherited_from \Zend_Validate_File_MimeType::__construct()

Parameters

$mimetype

stringarray\Zend_Config

Sets validator options

__construct(string|array $mimetype) 
Inherited

Mimetype to accept

Parameters

$mimetype

stringarray

MimeType

Exceptions

\Zend_Validate_Exception

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

__get(string $property) : mixed
Inherited

Parameters

$property

string

Exceptions

\Zend_Validate_Exception

Returns

mixed

Adds the mimetypes

addMimeType(string|array $mimetype) : \Zend_Validate_File_Extension
Inherited

Parameters

$mimetype

stringarray

The mimetypes to add for validation

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_File_ExtensionProvides a fluent interface

Defines if the http header should be used Note that this is unsave and therefor the default value is false

enableHeaderCheck(boolean $headerCheck = true) : \Zend_Validate_File_MimeType
Inherited

Parameters

$headerCheck

boolean

Returns

\Zend_Validate_File_MimeTypeProvides a fluent interface

Get default translation object for all validate objects

getDefaultTranslator() : \Zend_Translate_Adapter | null
InheritedStatic

Returns

\Zend_Translate_Adapternull

Returns array of validation failure message codes

getErrors() : array
Inherited
deprecated Since 1.5.0

Returns

array

Returns the Header Check option

getHeaderCheck() : boolean
Inherited

Returns

boolean

Returns the actual set magicfile

getMagicFile() : string
Inherited

Note that for PHP 5.3.0 or higher, we don't use $_ENV['MAGIC'] or try to find a magic file in a common location as PHP now has a built-in internal magic file.

Returns

string

Returns the maximum allowed message length

getMessageLength() : integer
InheritedStatic

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

Returns

array

Returns an array of the names of variables that are used in constructing validation failure messages

getMessageVariables() : array
Inherited

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

inherited_from \Zend_Validate_Interface::getMessages()

Returns

array

Returns the set mimetypes

getMimeType(boolean $asArray = false) : string | array
Inherited

Parameters

$asArray

boolean

Returns the values as array, when false an concated string is returned

Returns

stringarray

Retrieve flag indicating whether or not value should be obfuscated in messages

getObscureValue() : boolean
Inherited

Returns

boolean

Return translation object

getTranslator() : \Zend_Translate_Adapter | null
Inherited

Returns

\Zend_Translate_Adapternull

Is there a default translation object set?

hasDefaultTranslator() : boolean
InheritedStatic

Returns

boolean

Does this validator have its own specific translator?

hasTranslator() : boolean
Inherited

Returns

boolean

Defined by Zend_Validate_Interface

isValid(string $value, array $file = null) : boolean
Inherited

Returns true if the mimetype of the file matches the given ones. Also parts of mimetypes can be checked. If you give for example "image" all image mime types will be accepted like "image/gif", "image/jpeg" and so on.

Parameters

$value

string

Real file to check for mimetype

$file

array

File data from Zend_File_Transfer

Returns

boolean

Set default translation object for all validate objects

setDefaultTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null
InheritedStatic

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Indicate whether or not translation should be disabled

setDisableTranslator(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Sets the magicfile to use if null, the MAGIC constant from php is used if the MAGIC file is errorous, no file will be set

setMagicFile(string $file) : \Zend_Validate_File_MimeType
Inherited

Parameters

$file

string

Exceptions

\Zend_Validate_Exception When finfo can not read the magicfile

Returns

\Zend_Validate_File_MimeTypeProvides a fluent interface

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey = null) : \Zend_Validate_Abstract
Inherited

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_AbstractProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length = -1
InheritedStatic

Parameters

$length

integer

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

setMessages(array $messages) : \Zend_Validate_Abstract
Inherited

Parameters

$messages

array

Returns

\Zend_Validate_Abstract

Sets the mimetypes

setMimeType(string|array $mimetype) : \Zend_Validate_File_Extension
Inherited

Parameters

$mimetype

stringarray

The mimetypes to validate

Returns

\Zend_Validate_File_ExtensionProvides a fluent interface

Set flag indicating whether or not value should be obfuscated in messages

setObscureValue(boolean $flag) : \Zend_Validate_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Validate_Abstract

Set translation object

setTranslator(\Zend_Translate|\Zend_Translate_Adapter|null $translator = null) : \Zend_Validate_Abstract
Inherited

Parameters

$translator

\Zend_Translate\Zend_Translate_Adapternull

Exceptions

\Zend_Validate_Exception

Returns

\Zend_Validate_Abstract

Enables or disables attempts to try the common magic file locations specified by Zend_Validate_File_MimeType::_magicFiles

setTryCommonMagicFilesFlag(boolean $flag = true) : \Zend_Validate_File_MimeType
Inherited
see

Parameters

$flag

boolean

Returns

\Zend_Validate_File_MimeTypeProvides fluent interface

Accessor for Zend_Validate_File_MimeType::_magicFiles

shouldTryCommonMagicFiles() : boolean
Inherited
see

Returns

boolean

Is translation disabled?

translatorIsDisabled() : boolean
Inherited

Returns

boolean

Constructs and returns a validation failure message with the given message key and value.

_createMessage(string $messageKey, string $value) : string
Inherited

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters

$messageKey

string

$value

string

Returns

string

Try to detect mime type of given file.

_detectMimeType(string $file) : string
Inherited

Parameters

$file

string

File which mime type should be detected

Returns

stringFile mime type or null if not detected

_error()

_error(string $messageKey, string $value = null) : void
Inherited

Parameters

$messageKey

string

$value

string

OPTIONAL

Saves the provided error information by finfo_open to this instance

_errorHandler(integer $errno, string $errstr, string $errfile, integer $errline) 
Inherited

Parameters

$errno

integer

$errstr

string

$errfile

string

$errline

integer

Joins elements of a multidimensional array

_implodeRecursive(array $pieces) : string
Inherited

Parameters

$pieces

array

Returns

string

Sets the value to be validated and clears the messages and errors arrays

_setValue(mixed $value) : void
Inherited

Parameters

$value

mixed

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

_throw(string $file, string $errorType) : false
inherited_from \Zend_Validate_File_MimeType::_throw()

Parameters

$file

string

$errorType

string

Returns

false

Throws an error of the given type

_throw(string $file, string $errorType) : false
Inherited

Parameters

$file

string

$errorType

string

Returns

false

 Properties

 

Default translation object for all validate objects

$_defaultTranslator : \Zend_Translate

Default

Static
 

Array of validation failure message codes

$_errors : array

Default

array()
deprecated Since 1.5.0
 

Finfo object to use

$_finfo : resource

Default

 

Holds error information returned by finfo_open

$_finfoError : array

Default

 

Option to allow header check

$_headerCheck : boolean

Default

false
 

If no $_ENV['MAGIC'] is set, try and autodiscover it based on common locations

$_magicFiles : array

Default

array('/usr/share/misc/magic', '/usr/share/misc/magic.mime', '/usr/share/misc/magic.mgc', '/usr/share/mime/magic', '/usr/share/mime/magic.mime', '/usr/share/mime/magic.mgc', '/usr/share/file/magic', '/usr/share/file/magic.mime', '/usr/share/file/magic.mgc')
 

Magicfile to use

$_magicfile : string | null

Default

 

Limits the maximum returned length of a error message

$_messageLength : Integer

Default

-1
Static
 

Validation failure message template definitions

$_messageTemplates : array

Default

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")
inherited_from \Zend_Validate_File_MimeType::_messageTemplates
 

Validation failure message template definitions

$_messageTemplates : array

Default

array()
 

Additional variables available for validation failure messages

$_messageVariables : array

Default

array()
 

Array of validation failure messages

$_messages : array

Default

array()
 

Mimetypes

$_mimetype : string | null

Default

If null, there is no mimetype

 

Flag indidcating whether or not value should be obfuscated in error messages

$_obscureValue : boolean

Default

false
 

Translation object

$_translator : \Zend_Translate

Default

 

Is translation disabled?

$_translatorDisabled : Boolean

Default

false
 

Indicates whether use of $_magicFiles should be attempted.

$_tryCommonMagicFiles : boolean

Default

true
 

$_type

$_type : string

Default

 

The value to be validated

$_value : mixed

Default

 Constants

 

FALSE_TYPE

FALSE_TYPE = 'fileIsImageFalseType' 
const string Error constants
inherited_from \Zend_Validate_File_MimeType::FALSE_TYPE
 

FALSE_TYPE

FALSE_TYPE = 'fileMimeTypeFalse' 
const Error type constants
 

NOT_DETECTED

NOT_DETECTED = 'fileIsImageNotDetected' 
inherited_from \Zend_Validate_File_MimeType::NOT_DETECTED
 

NOT_DETECTED

NOT_DETECTED = 'fileMimeTypeNotDetected' 
 

NOT_READABLE

NOT_READABLE = 'fileIsImageNotReadable' 
inherited_from \Zend_Validate_File_MimeType::NOT_READABLE
 

NOT_READABLE

NOT_READABLE = 'fileMimeTypeNotReadable'