Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | List of all members
eZMimeType Class Reference
Utility classes

Detection and management of MIME types. More...

## Public Member Functions
| __construct ()

## Static Public Member Functions
static | defaultMimeType ()
static | defaultValue ( $url, $returnDefault)
static | changeMIMEType (&$mimeInfo, $mimetype)
static | changeBasename (&$mimeInfo, $basename)
static | changeDirectoryPath (&$mimeInfo, $dirpath)
static | changeFileData (&$mimeInfo, $dirpath=false, $basename=false, $suffix=false, $filename=false)
static | findByName ( $mimeName, $returnDefault=true)
static | findByURL ( $url, $returnDefault=true)
static | findByFileContents ( $url, $returnDefault=true)
static | findByBuffer ( $buffer, $length=false, $offset=false, $url=false, $returnDefault=true)
static | instance ()

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

## Static Private Member Functions
static | prepareSuffixList (&$suffixList, $mimeList)
static | preparePrefixList (&$prefixList, $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

Definition at line 33 of file ezmimetype.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZMimeType::__construct | ( |  | ) |

Definition at line 35 of file ezmimetype.php.

References preparePrefixList(), and prepareSuffixList().

## Member Function Documentation

## ◆ changeBasename()

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

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

Definition at line 141 of file ezmimetype.php.

Referenced by eZImageManager\createImageAlias().

## ◆ changeDirectoryPath()

static eZMimeType::changeDirectoryPath | ( | & | $mimeInfo,
|  |  | $dirpath
| ) |  |
| static

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

Definition at line 155 of file ezmimetype.php.

Referenced by eZStylePackageCreator\commitCSSFile(), eZImageManager\convert(), eZImageAliasHandler\initializeFromFile(), eZImageAliasHandler\initializeFromHTTPFile(), eZStylePackageCreator\validateImageFiles(), and eZPackageCreationHandler\validatePackageThumbnail().

## ◆ changeFileData()

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.

Definition at line 168 of file ezmimetype.php.

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

## ◆ changeMIMEType()

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.

Definition at line 117 of file ezmimetype.php.

References findByName().

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

## ◆ defaultMimeType()

static eZMimeType::defaultMimeType | ( |  | ) |
| static

Returns
  the default MIME-Type, this is used for all files that are not recognized.

Definition at line 68 of file ezmimetype.php.

Referenced by defaultValue().

## ◆ defaultValue()

static eZMimeType::defaultValue | ( |  | $url,
|  |  | $returnDefault
| ) |  |
| static

Returns
  the defaultMimeType if $returnDefault is `true`, otherwise returns `false`.

Definition at line 86 of file ezmimetype.php.

References defaultMimeType().

Referenced by findByName(), and findByURL().

## ◆ findByBuffer()

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

  $length | If specified it will limit how far the $buffer is examined
  $offset | If specified it will set the starting point for the $buffer examination
  $url | If specified the url will be used for MIME determination if buffer examination gives no results.

Note
  Currently it only calls findByURL()

Definition at line 323 of file ezmimetype.php.

References findByURL().

## ◆ findByFileContents()

static eZMimeType::findByFileContents | ( |  | $url,
|  |  | $returnDefault = `true`
| ) |  |
| static

Finds the MIME type for the url $url by examining the contents of the url 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.

Note
  Currently it only calls findByURL()

Definition at line 308 of file ezmimetype.php.

References findByURL().

Referenced by eZPDFTable\callImage(), eZStylePackageCreator\commitCSSFile(), eZImageManager\convert(), eZImageManager\createImageAlias(), eZContentUpload\fetchHTTPFile(), eZBinaryFileType\fetchObjectAttributeHTTPInput(), eZMediaType\fetchObjectAttributeHTTPInput(), eZImageAliasHandler\generateXMLData(), eZContentUpload\handleLocalFile(), eZImageManager\imageAliasInfo(), eZImageAliasHandler\initializeFromFile(), eZImageAliasHandler\initializeFromHTTPFile(), eZBinaryFileType\insertRegularFile(), eZMediaType\insertRegularFile(), eZImageAliasHandler\recreateDOMTree(), eZStylePackageCreator\validateImageFiles(), and eZPackageCreationHandler\validatePackageThumbnail().

## ◆ findByName()

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.

Definition at line 197 of file ezmimetype.php.

References defaultValue(), and instance().

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

## ◆ findByURL()

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

Definition at line 227 of file ezmimetype.php.

References defaultValue(), and instance().

Referenced by eZPDFTable\callImage(), eZFile\downloadHeaders(), eZHTTPFile\fetch(), findByBuffer(), findByFileContents(), eZPackageCreationHandler\httpFileIsImage(), eZImageAliasHandler\initializeFromHTTPFile(), eZImageAliasHandler\recreateDOMTree(), eZTemplateImageOperator\storeImage(), and eZImageType\validateImageFileExtension().

## ◆ instance()

static eZMimeType::instance | ( |  | ) |
| static

Returns a shared instance of the eZMimeType class.

Returns
  eZMimeType

Definition at line 333 of file ezmimetype.php.

Referenced by findByName(), and findByURL().

## ◆ preparePrefixList()

static eZMimeType::preparePrefixList | ( | & | $prefixList,
|  |  | $mimeList
| ) |  |
| static private

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

Definition at line 366 of file ezmimetype.php.

Referenced by __construct().

## ◆ prepareSuffixList()

static eZMimeType::prepareSuffixList | ( | & | $suffixList,
|  |  | $mimeList
| ) |  |
| static private

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

Definition at line 347 of file ezmimetype.php.

Referenced by __construct().

## Member Data Documentation

## ◆ $MIMEList

eZMimeType::$MIMEList

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

Definition at line 388 of file ezmimetype.php.

## ◆ $PrefixList

eZMimeType::$PrefixList

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

Definition at line 386 of file ezmimetype.php.

## ◆ $QuickContentMatch

eZMimeType::$QuickContentMatch

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

Definition at line 390 of file ezmimetype.php.

## ◆ $QuickMIMETypes

eZMimeType::$QuickMIMETypes = array()

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

Definition at line 396 of file ezmimetype.php.

## ◆ $SuffixList

eZMimeType::$SuffixList

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

Definition at line 384 of file ezmimetype.php.

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

- ezmimetype.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.