eZPublish  4.7
eZMimeType Class Reference

Detection and management of MIME types. More...

Public Member Functions

 eZMimeType ()
 

Static Public Member Functions

static changeBasename (&$mimeInfo, $basename)
 
static changeDirectoryPath (&$mimeInfo, $dirpath)
 
static changeFileData (&$mimeInfo, $dirpath=false, $basename=false, $suffix=false, $filename=false)
 
static changeMIMEType (&$mimeInfo, $mimetype)
 
static defaultMimeType ()
 
static defaultValue ($url, $returnDefault)
 
static findByBuffer ($buffer, $length=false, $offset=false, $url=false, $returnDefault=true)
 
static findByFileContents ($url, $returnDefault=true)
 
static findByName ($mimeName, $returnDefault=true)
 
static findByURL ($url, $returnDefault=true)
 
static instance ()
 Returns a shared instance of the eZMimeType class. More...
 
static mimeTypeFor ($path, $file)
 

Public 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 = array()
 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...
 

Static Private Member Functions

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

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

static eZMimeType::changeBasename ( $mimeInfo,
  $basename 
)
static

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

Referenced by eZImageManager\createImageAlias().

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

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().

static eZMimeType::changeMIMEType ( $mimeInfo,
  $mimetype 
)
static

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

Referenced by eZImageManager\convert(), and eZImageManager\imageAliasInfo().

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

Referenced by defaultValue().

static 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().

static 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()
static eZMimeType::findByName (   $mimeName,
  $returnDefault = true 
)
static
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(), eZWebDAVContentBackend\fetchNodeInfo(), eZImageAliasHandler\initializeFromHTTPFile(), and eZImageHandler\outputMIMEType().

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

Returns a shared instance of the eZMimeType class.

Returns
eZMimeType

Referenced by findByName(), and findByURL().

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

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

Referenced by eZMimeType().

static eZMimeType::prepareSuffixList ( $suffixList,
  $mimeList 
)
staticprivate

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

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

eZMimeType::$PrefixList

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

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

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

eZMimeType::$SuffixList

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


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