MIME_Type
[ class tree: MIME_Type ] [ index: MIME_Type ] [ all elements ]

Class: MIME_Type

Source Location: /MIME_Type-1.4.1/MIME/Type.php

Class Overview


Class for working with MIME types


Author(s):

Version:

  • Release: @version@

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 32]
Class for working with MIME types


[ Top ]


Class Variables

$magicFile =  null

[line 106]

Path to the "magic" file database.

If NULL, the default one is used

  • Access: public

Type:   string


[ Top ]

$media =  ''

[line 39]

The MIME media type
  • Access: public

Type:   string


[ Top ]

$parameters = array()

[line 53]

Optional MIME parameters
  • Access: public

Type:   array


[ Top ]

$subType =  ''

[line 46]

The MIME media sub-type
  • Access: public

Type:   string


[ Top ]

$useExtension =  true

[line 98]

If the in-built file extension detection shall be used
  • Access: public

Type:   boolean


[ Top ]

$useFileCmd =  true

[line 91]

If the file command shall be used when available
  • Access: public

Type:   boolean


[ Top ]

$useFinfo =  true

[line 77]

If the finfo functions shall be used when they are available
  • Access: public

Type:   boolean


[ Top ]

$useMimeContentType =  true

[line 84]

If mime_content_type shall be used when available
  • Access: public

Type:   boolean


[ Top ]

$validMediaTypes = array(
        'text',
        'image',
        'audio',
        'video',
        'application',
        'multipart',
        'message'
    )

[line 62]

List of valid media types.

A media type is the string in front of the slash. The media type of "text/xml" would be "text".

  • Access: public

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 118]

MIME_Type __construct( [string $type = false])

Constructor.

If $type is set, if will be parsed and the appropriate class vars set. If not, you get an empty class. This is useful, but not quite as useful as parsing a type.

  • Access: public

Parameters:

string   $type   —  MIME type

[ Top ]

addParameter   [line 448]

void addParameter( string $name, string $value, [string $comment = false])

Add a parameter to this type
  • Access: public

Parameters:

string   $name   —  Attribute name
string   $value   —  Attribute value
string   $comment   —  Comment for this parameter

[ Top ]

get   [line 343]

string get( )

Create a textual MIME type from object values

This function performs the opposite function of parse().

  • Return: MIME type string
  • Access: public

[ Top ]

getMedia   [line 311]

string getMedia( string $type)

Get a MIME type's media Note: 'media' refers to the portion before the first slash
  • Return: media
  • Access: public

Parameters:

string   $type   —  MIME type to get media of

[ Top ]

getParameters   [line 218]

array getParameters( string $type)

Get a MIME type's parameters
  • Return: parameters
  • Access: public

Parameters:

string   $type   —  MIME type to get parameters of

[ Top ]

getSubType   [line 325]

string getSubType( string $type)

Get a MIME type's subtype
  • Return: subtype, null if invalid mime type
  • Access: public

Parameters:

string   $type   —  MIME type to get subtype of

[ Top ]

hasParameters   [line 202]

boolean hasParameters( string $type)

Does this type have any parameters?
  • Return: true if $type has parameters, false otherwise
  • Access: public

Parameters:

string   $type   —  MIME type to check

[ Top ]

isExperimental   [line 365]

boolean isExperimental( string $type)

Is this type experimental?

Note: Experimental types are denoted by a leading 'x-' in the media or subtype, e.g. text/x-vcard or x-world/x-vrml.

  • Return: true if $type is experimental, false otherwise
  • Access: public

Parameters:

string   $type   —  MIME type to check

[ Top ]

isVendor   [line 385]

boolean isVendor( string $type)

Is this a vendor MIME type?

Note: Vendor types are denoted with a leading 'vnd. in the subtype.

  • Return: true if $type is a vendor type, false otherwise
  • Access: public

Parameters:

string   $type   —  MIME type to check

[ Top ]

isWildcard   [line 401]

boolean isWildcard( string $type)

Is this a wildcard type?
  • Return: true if $type is a wildcard, false otherwise
  • Access: public

Parameters:

string   $type   —  MIME type to check

[ Top ]

parse   [line 174]

boolean parse( string $type)

Parse a mime-type and set the class variables.
  • Return: True if the type has been parsed, false if not
  • Access: public

Parameters:

string   $type   —  MIME type to parse

[ Top ]

removeParameter   [line 466]

void removeParameter( string $name)

Remove a parameter from this type
  • Access: public

Parameters:

string   $name   —  Parameter name

[ Top ]

stripComments   [line 254]

string stripComments( string $string, &$comment, string $comment)

Removes comments from a media type, subtype or parameter.
  • Return: String without comments
  • Access: public

Parameters:

string   $string   —  String to strip comments from
string   $comment   —  Comment is stored in there. Do not set it to NULL if you want the comment.
   &$comment   — 

[ Top ]

stripParameters   [line 236]

string stripParameters( string $type)

Strip parameters from a MIME type string.
  • Return: MIME type with parameters removed
  • Access: public

Parameters:

string   $type   —  MIME type string

[ Top ]

wildcardMatch   [line 421]

boolean wildcardMatch( string $card, string $type)

Perform a wildcard match on a MIME type

Example: MIME_Type::wildcardMatch('image/*', 'image/png')

  • Return: true if there was a match, false otherwise
  • Access: public

Parameters:

string   $card   —  Wildcard to check against
string   $type   —  MIME type to check

[ Top ]

_autoDetect   [line 487]

string _autoDetect( string $file, [bool $params = false])

Autodetect a file's MIME-type
  • Return: MIME-type on success, PEAR_Error otherwise
  • Since: 1.3.0
  • Access: protected

Parameters:

string   $file   —  Path to the file to get the type of
bool   $params   —  Append MIME parameters if true

[ Top ]

_fileAutoDetect   [line 574]

string _fileAutoDetect( string $file)

Autodetect a file's MIME-type with 'file' and System_Command
  • Return: MIME-type
  • Since: 1.0.0beta1
  • Access: protected

Parameters:

string   $file   —  Path to the file to get the type of

[ Top ]

_handleDetection   [line 544]

string _handleDetection( string $type, bool $params)

Handles a detected MIME type and modifies it if necessary.
  • Return: MIME-type on success, PEAR_Error otherwise
  • Access: protected

Parameters:

string   $type   —  MIME Type of a file
bool   $params   —  Append MIME parameters if true

[ Top ]

__call   [line 133]

string __call( string $method, array $arguments)

Make "autoDetect" method available.
  • Return: MIME type
  • Access: public

Parameters:

string   $method   —  Method to call. Only "autoDetect" supported.
array   $arguments   —  Function parameters.

[ Top ]

__callStatic   [line 154]

string __callStatic( string $method, array $arguments)

Make "autoDetect" method available statically.
  • Return: MIME type
  • Access: public

Parameters:

string   $method   —  Method to call. Only "autoDetect" supported.
array   $arguments   —  Function parameters.

[ Top ]


Documentation generated on Wed, 09 Dec 2015 23:16:04 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.