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

Class: MIME_Type

Source Location: /MIME_Type-1.3.3/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 30]
Class for working with MIME types


[ Top ]


Class Variables

$magicFile =  null

[line 104]

Path to the "magic" file database.

If NULL, the default one is used


Type:   string


[ Top ]

$media =  ''

[line 37]

The MIME media type

Type:   string


[ Top ]

$parameters = array()

[line 51]

Optional MIME parameters

Type:   array


[ Top ]

$subType =  ''

[line 44]

The MIME media sub-type

Type:   string


[ Top ]

$useExtension =  true

[line 96]

If the in-built file extension detection shall be used

Type:   boolean


[ Top ]

$useFileCmd =  true

[line 89]

If the file command shall be used when available

Type:   boolean


[ Top ]

$useFinfo =  true

[line 75]

If the finfo functions shall be used when they are available

Type:   boolean


[ Top ]

$useMimeContentType =  true

[line 82]

If mime_content_type shall be used when available

Type:   boolean


[ Top ]

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

[line 60]

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


Type:   array


[ Top ]



Method Detail

MIME_Type (Constructor)   [line 118]

void MIME_Type( [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.


Parameters:

string   $type     MIME type

[ Top ]

addParameter   [line 417]

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

Add a parameter to this type

Parameters:

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

[ Top ]

autoDetect   [line 454]

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

Autodetect a file's MIME-type

This function may be called staticly.

  • Return: MIME-type on success, PEAR_Error otherwise
  • Since: 1.0.0beta1

Parameters:

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

[ Top ]

get   [line 308]

string get( )

Create a textual MIME type from object values

This function performs the opposite function of parse().

  • Return: MIME type string

[ Top ]

getMedia   [line 275]

string getMedia( string $type)

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

Parameters:

string   $type     MIME type to get media of

[ Top ]

getParameters   [line 179]

array getParameters( string $type)

Get a MIME type's parameters
  • Return: parameters

Parameters:

string   $type     MIME type to get parameters of

[ Top ]

getSubType   [line 290]

string getSubType( string $type)

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

Parameters:

string   $type     MIME type to get subtype of

[ Top ]

hasParameters   [line 162]

boolean hasParameters( string $type)

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

Parameters:

string   $type     MIME type to check

[ Top ]

isExperimental   [line 331]

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

Parameters:

string   $type     MIME type to check

[ Top ]

isVendor   [line 352]

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

Parameters:

string   $type     MIME type to check

[ Top ]

isWildcard   [line 369]

boolean isWildcard( string $type)

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

Parameters:

string   $type     MIME type to check

[ Top ]

parse   [line 133]

boolean parse( string $type)

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

Parameters:

string   $type     MIME type to parse

[ Top ]

removeParameter   [line 435]

void removeParameter( string $name)

Remove a parameter from this type

Parameters:

string   $name     Parameter name

[ Top ]

stripComments   [line 217]

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

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

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.

[ Top ]

stripParameters   [line 198]

string stripParameters( string $type)

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

Parameters:

string   $type     MIME type string

[ Top ]

wildcardMatch   [line 390]

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

Parameters:

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

[ Top ]


Documentation generated on Thu, 03 Oct 2013 09:00:02 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.