Class Zend_Validate_File_MimeType

Description

Validator for the mime type of a file

  • copyright: Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Validate/File/MimeType.php (line 35)

Zend_Validate_Abstract
   |
   --Zend_Validate_File_MimeType
Direct descendents
Class Description
 class Zend_Validate_File_IsCompressed Validator which checks if the file already exists in the directory
 class Zend_Validate_File_IsImage Validator which checks if the file already exists in the directory
 class Zend_Validate_File_ExcludeMimeType Validator for the mime type of a file
Class Constant Summary
 FALSE_TYPE = 'fileMimeTypeFalse'
 NOT_DETECTED = 'fileMimeTypeNotDetected'
 NOT_READABLE = 'fileMimeTypeNotReadable'
Variable Summary
 resource $_finfo
 boolean $_headerCheck
 string|null $_magicfile
 array $_magicFiles
 string|null $_mimetype
 string $_type
Method Summary
 void __construct (string|array $mimetype)
 Zend_Validate_File_Extension addMimeType (string|array $mimetype)
 Zend_Validate_File_MimeType enableHeaderCheck ([ $headerCheck = true], boolean $checkHeader)
 boolean getHeaderCheck ()
 string getMagicFile ()
 string|array getMimeType ([boolean $asArray = false])
 boolean isValid (string $value, [array $file = null])
 Zend_Validate_File_Extension setMimeType (string|array $mimetype)
 false _throw (string $file, string $errorType)
Variables
resource $_finfo (line 87)

Finfo object to use

  • access: protected
boolean $_headerCheck = false (line 110)

Option to allow header check

  • access: protected
string|null $_magicfile (line 80)

Magicfile to use

  • access: protected
array $_magicFiles = 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',
)
(line 93)

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

  • access: protected
array $_messageTemplates = array(
self::FALSE_TYPE => "File '%value%' has a false mimetype of '%type%'",
self::NOT_DETECTED => "The mimetype of file '%value%' could not be detected",
self::NOT_READABLE => "File '%value%' can not be read",
)
(line 48)
  • var: Error message templates
  • access: protected

Redefinition of:
Zend_Validate_Abstract::$_messageTemplates
Validation failure message template definitions

Redefined in descendants as:
array $_messageVariables = array(
'type' => '_type'
)
(line 57)
  • access: protected

Redefinition of:
Zend_Validate_Abstract::$_messageVariables
Additional variables available for validation failure messages
string|null $_mimetype (line 73)

Mimetypes

If null, there is no mimetype

  • access: protected
string $_type (line 64)
  • access: protected

Inherited Variables

Inherited from Zend_Validate_Abstract

Zend_Validate_Abstract::$_defaultTranslator
Zend_Validate_Abstract::$_errors
Zend_Validate_Abstract::$_messageLength
Zend_Validate_Abstract::$_messages
Zend_Validate_Abstract::$_obscureValue
Zend_Validate_Abstract::$_translator
Zend_Validate_Abstract::$_translatorDisabled
Zend_Validate_Abstract::$_value
Methods
Constructor __construct (line 120)

Sets validator options

Mimetype to accept

  • access: public
void __construct (string|array $mimetype)
  • string|array $mimetype: MimeType

Redefined in descendants as:
addMimeType (line 271)

Adds the mimetypes

  • return: Provides a fluent interface
  • access: public
Zend_Validate_File_Extension addMimeType (string|array $mimetype)
  • string|array $mimetype: The mimetypes to add for validation
enableHeaderCheck (line 229)

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

  • return: Provides fluid interface
  • access: public
Zend_Validate_File_MimeType enableHeaderCheck ([ $headerCheck = true], boolean $checkHeader)
  • boolean $checkHeader
  • $headerCheck
getHeaderCheck (line 217)

Returns the Header Check option

  • access: public
boolean getHeaderCheck ()
getMagicFile (line 149)

Returns the actual set magicfile

  • access: public
string getMagicFile ()
getMimeType (line 241)

Returns the set mimetypes

  • access: public
string|array getMimeType ([boolean $asArray = false])
  • boolean $asArray: Returns the values as array, when false an concated string is returned
isValid (line 317)

Defined by Zend_Validate_Interface

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.

  • access: public
boolean isValid (string $value, [array $file = null])
  • string $value: Real file to check for mimetype
  • array $file: File data from Zend_File_Transfer

Redefined in descendants as:
setMagicFile (line 186)

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

  • return: Provides fluid interface
  • throws: Zend_Validate_Exception When finfo can not read the magicfile
  • access: public
Zend_Validate_File_MimeType setMagicFile (string $file)
  • string $file
setMimeType (line 258)

Sets the mimetypes

  • return: Provides a fluent interface
  • access: public
Zend_Validate_File_Extension setMimeType (string|array $mimetype)
  • string|array $mimetype: The mimetypes to validate
_throw (line 386)

Throws an error of the given type

  • access: protected
false _throw (string $file, string $errorType)
  • string $file
  • string $errorType

Redefined in descendants as:

Inherited Methods

Inherited From Zend_Validate_Abstract

 Zend_Validate_Abstract::getDefaultTranslator()
 Zend_Validate_Abstract::getErrors()
 Zend_Validate_Abstract::getMessageLength()
 Zend_Validate_Abstract::getMessages()
 Zend_Validate_Abstract::getMessageTemplates()
 Zend_Validate_Abstract::getMessageVariables()
 Zend_Validate_Abstract::getObscureValue()
 Zend_Validate_Abstract::getTranslator()
 Zend_Validate_Abstract::hasDefaultTranslator()
 Zend_Validate_Abstract::hasTranslator()
 Zend_Validate_Abstract::setDefaultTranslator()
 Zend_Validate_Abstract::setDisableTranslator()
 Zend_Validate_Abstract::setMessage()
 Zend_Validate_Abstract::setMessageLength()
 Zend_Validate_Abstract::setMessages()
 Zend_Validate_Abstract::setObscureValue()
 Zend_Validate_Abstract::setTranslator()
 Zend_Validate_Abstract::translatorIsDisabled()
 Zend_Validate_Abstract::_createMessage()
 Zend_Validate_Abstract::_error()
 Zend_Validate_Abstract::_setValue()
 Zend_Validate_Abstract::__get()
Class Constants
FALSE_TYPE = 'fileMimeTypeFalse' (line 40)
NOT_DETECTED = 'fileMimeTypeNotDetected' (line 41)
NOT_READABLE = 'fileMimeTypeNotReadable' (line 42)

Documentation generated on Mon, 21 Jun 2010 15:34:00 -0400 by phpDocumentor 1.4.3