FileTypeHelper View code

A class to provide utilities for manipulating files by their type.

package

CMS

license

GPL

author

Robert Campbell calguy1000@cmsmadesimple.org

since 2.2

Methods

__construct(\CMSMS\cms_config $config) 

Constructor

Arguments

\CMSMS\cms_config $config

update_config_extensions(string $member, string $str) 

A utility method to allow overriding the extensions used to identify files of a specific type

Arguments

string $member

One of (_archive_extensions, _audio_extensions, _video_extensions, _xml_extensions, _document_extensions)

string $str

A comma separated string of extensions for that file type

is_readable(string $filename) : boolean

Test if the file specified is readable

Arguments

string $filename

Response

boolean

get_extension(string $filename) : string

Get the extension of a filename

Arguments

string $filename

Response

string

get_mime_type(string $filename) : string

Get the mime type of a filename.

requires the finfo_open function.

Arguments

string $filename

Response

string

is_image(string $filename) : boolean

Test if the file specified is an image.

This method will use the mime type if possible, otherwise an extension is used to determine if the file is an image.

Arguments

string $filename

Response

boolean

is_thumb(string $filename) : boolean

Test if the file specified is a thumbnail This method first tests if the file is an image, and then if it is also a thumbnail.

Arguments

string $filename

Response

boolean

is_archive(string $filename) : boolean

Using the file extension, test if the filename provided is a known archive.

Arguments

string $filename

Response

boolean

is_audio(string $filename) : boolean

Using mime types if possible, or extensions, test if the filename provided is a known audio file.

Arguments

string $filename

Response

boolean

is_video(string $filename) : boolean

Using mime types if possible, or extensions, test if the filename provided is a known audio file.

Arguments

string $filename

Response

boolean

is_media(string $filename) : boolean

Test if the file name specified is a known media (image, audio, video) file.

Arguments

string $filename

Response

boolean

is_xml(string $filename) : boolean

Test if the file name specified is a known XML file.

Arguments

string $filename

Response

boolean

is_document(string $filename) : boolean

Using the file extension, test if the file name specified is a known document file.

Arguments

string $filename

Response

boolean

get_file_type(string $filename) : string

Atempt to find a file type for the given filename.

Arguments

string $filename

Response

string

A FileType type constant describing the file type, if found.