eZPublish  3.8
eZMimeType Class Reference

Detection and management of MIME types. More...

Public Member Functions

 changeBasename (&$mimeInfo, $basename)
 
 changeDirectoryPath (&$mimeInfo, $dirpath)
 
 changeFileData (&$mimeInfo, $dirpath=false, $basename=false, $suffix=false, $filename=false)
 
 changeMIMEType (&$mimeInfo, $mimetype)
 
 eZMimeType ()
 
 findByName ($mimeName, $returnDefault=true)
 

Static Public Member Functions

 defaultMimeType ()
 
 defaultValue ($url, $returnDefault)
 
 findByBuffer ($buffer, $length=false, $offset=false, $url=false, $returnDefault=true)
 
 findByFileContents ($url, $returnDefault=true)
 
 findByURL ($url, $returnDefault=true)
 
 instance ()
 
 mimeTypeFor ($path, $file)
 

Private Member Functions

 preparePrefixList (&$prefixList, $mimeList)
 
 prepareSuffixList (&$suffixList, $mimeList)
 

Private Attributes

 $MIMEList
 An associative array which maps MIME type name to MIME structure. More...
 
 $PrefixList
 An associative array which maps from prefix name to MIME type name. More...
 
 $QuickContentMatch
 
 $QuickMIMETypes
 A list of suffixes and their MIME types, this is used to quickly initialize the system. More...
 
 $SuffixList
 An associative array which maps from suffix name to MIME type name. More...
 

Detailed Description

Detection and management of MIME types.

The MIME type structure is an array with the following items:

  • name - The name of MIME type, eg. image/jpeg
  • suffixes - An array with possible suffixes for the filename, the first entry can be used as when creating filenames of the type. If no known suffixes exists this value is false
  • prefixes - An array with possible prefixes for the filename, the first entry can be used as when creating filenames of the type. If no known prefixes exists this value is false
  • is_valid - Boolean which tells whether this MIME type is valid or not, usually this is set to false if no match for the file was found in which case the name will also be application/octet-stream
  • url - The original url or file supplied to the matching system, can be false if buffer matching was used.
  • filename - Just the filename part of the url
  • dirpath - The directory path part of the url
  • basename - The basename of the filename without suffix or prefix
  • suffix - The suffix of the file or false if none
  • prefix - The prefix of the file or false if none

Member Function Documentation

eZMimeType::changeBasename ( $mimeInfo,
  $basename 
)

Changes the basename attribute for the MIME info structure $mimeInfo to $basename, and recreates all the affected fields.

Referenced by eZImageManager\createImageAlias().

eZMimeType::changeDirectoryPath ( $mimeInfo,
  $dirpath 
)
eZMimeType::changeFileData ( $mimeInfo,
  $dirpath = false,
  $basename = false,
  $suffix = false,
  $filename = false 
)

Changes the basename attribute for the MIME info structure $mimeInfo to $basename, and recreates all the affected fields.

Referenced by eZImageManager\convert(), and eZImageAliasHandler\updateAliasPath().

eZMimeType::changeMIMEType ( $mimeInfo,
  $mimetype 
)

Changes the MIME type attribute for the MIME info structure $mimeInfo to $mimetype, and recreates all the affected fields.

Referenced by eZImageManager\convert().

eZMimeType::defaultMimeType ( )
static
Returns
the default MIME-Type, this is used for all files that are not recognized.

Referenced by defaultValue().

eZMimeType::defaultValue (   $url,
  $returnDefault 
)
static
Returns
the defaultMimeType if $returnDefault is true, otherwise returns false.

Referenced by findByName(), and findByURL().

eZMimeType::eZMimeType ( )

Constructor

Referenced by instance().

eZMimeType::findByBuffer (   $buffer,
  $length = false,
  $offset = false,
  $url = false,
  $returnDefault = true 
)
static

Finds the MIME type for the buffer $buffer by examining the contents and returns it. If $returnDefault is set to true then it will always return a MIME structure, if not it will return false if none were found.

Parameters
$lengthIf specified it will limit how far the $buffer is examined
$offsetIf specified it will set the starting point for the $buffer examination
$urlIf specified the url will be used for MIME determination if buffer examination gives no results.
Note
Currently it only calls findByURL()
eZMimeType::findByName (   $mimeName,
  $returnDefault = true 
)
Returns
the MIME structure for the MIME type $mimeName. If $returnDefault is set to true then it will always return a MIME structure, if not it will return false if none were found.

Referenced by changeMIMEType(), eZWebDAVContentServer\fetchNodeInfo(), eZImageAliasHandler\initializeFromHTTPFile(), and eZImageHandler\outputMIMEType().

eZMimeType::findByURL (   $url,
  $returnDefault = true 
)
static

Finds the MIME type for the url $url by examining the url itself (not the content) and returns it. If $returnDefault is set to true then it will always return a MIME structure, if not it will return false if none were found.

Referenced by eZPDFTable\callImage(), eZFile\download(), eZHTTPFile\fetch(), eZWebDAVContentServer\fetchNodeInfo(), findByBuffer(), findByFileContents(), getFileInfo(), eZImageAliasHandler\initializeFromHTTPFile(), mimeTypeFor(), eZWebDAVServer\outputSendDataToClient(), eZWebDAVContentServer\putContentData(), eZImageAliasHandler\recreateDOMTree(), and eZImageType\validateObjectAttributeHTTPInput().

eZMimeType::instance ( )
static
Returns
the unique instance of the eZMimeType class.

Referenced by findByName(), and findByURL().

eZMimeType::mimeTypeFor (   $path,
  $file 
)
static
Deprecated:
Returns
the MIME-Type name for the file $file.
eZMimeType::preparePrefixList ( $prefixList,
  $mimeList 
)
private

Goes trough the mime list and creates a reference to the mime entry using the primary prefix.

Referenced by eZMimeType().

eZMimeType::prepareSuffixList ( $suffixList,
  $mimeList 
)
private

Goes trough the mime list and creates a reference to the mime entry using the primary suffix.

Referenced by eZMimeType().

Member Data Documentation

eZMimeType::$MIMEList
private

An associative array which maps MIME type name to MIME structure.

eZMimeType::$PrefixList
private

An associative array which maps from prefix name to MIME type name.

eZMimeType::$QuickContentMatch
private
Initial value:
= array(
array( array( 0, 'string', 'GIF87a', 'image/gif' ),
array( 0, 'string', 'GIF89a', 'image/gif' ) )
)
eZMimeType::$QuickMIMETypes
private

A list of suffixes and their MIME types, this is used to quickly initialize the system.

Should be removed to a .ini file or other external file

eZMimeType::$SuffixList
private

An associative array which maps from suffix name to MIME type name.


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