NAME
Solstice::ContentTypeService - Provides mappings between content-types and icons, MIMEExtensions, etc.
SYNOPSIS
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
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
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
Private Functions
- _sanitize($str)
- _getClassName()
-
Return the class name. Overridden to avoid a ref() in the superclass.
Modules Used
AUTHOR
Catalyst Group, <catalyst@u.washington.edu>
VERSION
$Revision: 2257 $
COPYRIGHT
Copyright 1998-2007 Office of Learning Technologies, University of Washington
Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.