Solstice::ContentTypeService - Provides mappings between content-types and icons, MIMEExtensions, etc.


Solstice documentation  | view source Contained in the Solstice distribution.

Index


NAME

Top

Solstice::ContentTypeService - Provides mappings between content-types and icons, MIMEExtensions, etc.

SYNOPSIS

Top

    use Solstice::ContentTypeService;

    my $filename = 'filename.txt';

    my $service = Solstice::ContentTypeService->new();

    my $content_type = $service->getContentTypeByFilename($filename);
    # returns 'text/plain';

    my $description = $service->getContentDescriptionByContentType($content_type);
    # returns 'Plain text file'

    my $extension = $service->getExtensionByContentType($content_type);
    # returns 'txt'

DESCRIPTION

Top

    Solstice::ContentTypeService is a service for identifying and
    depicting a file's content-type in various ways.

    How is this service useful? Let's say that you have identified a 
    file's content type as 'text/plain'. A view might wish to display an 
    appropriate icon for this content type (see Solstice::IconService), 
    as well as a 'human-readable' description, both of which can be 
    returned by this service.

Superclass

Solstice::Service::Memory

Export

No symbols exported.

Methods

new()

Creates a new Solstice::ContentTypeService object.

getContentTypeByFilehandle($handle)

Returns a content-type for the passed filehandle, based on magic numbers.

getContentTypeByFilename($str)

Returns a content-type for the passed filename, or undef if a file extension cannot be discerned.

getContentDescriptionByContentType($str)
getExtensionByContentType($str)
getIconByContentType($str)
getSynonymsForContentType($str)

Returns an array ref of content-type synonyms for the passed type. The list includes the passed type.

getDownloadContentType($str)

Returns a content-type suitable for placing into a download header. If the passed $type is a synonym, its parent type is returned.

isKnownType($str)
isVagueType($str)

Returns TRUE if the passed $type is a vague content type as returned by File::MMagic::checktype_contents().

isTextType($str)

Returns TRUE if the passed $type is a web-viewable text type or synonym, FALSE otherwise.

includesCharset($str)

checks if the type passed includes a charset declaration

isImageType($str)

Returns TRUE if the passed $type is a web-viewable image type or synonym, FALSE otherwise.

Private Methods

_initialize()
_getDataForType($str)
_validateXML($doc)
_readXML($doc)
_parseXMLFile($path)

Private Functions

_sanitize($str)
_getClassName()

Return the class name. Overridden to avoid a ref() in the superclass.

Modules Used

Solstice::Service::Memory.

AUTHOR

Top

Catalyst Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 2257 $

COPYRIGHT

Top


Solstice documentation  | view source Contained in the Solstice distribution.