|
From: Chris W. <la...@us...> - 2001-10-26 21:09:07
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv7096/OpenInteract
Added Files:
ContentType.pm
Log Message:
added data structure, startup data, lookup table action, object
definition and simple class method for keeping track of content types
--- NEW FILE: ContentType.pm ---
package OpenInteract::ContentType;
# $Id: ContentType.pm,v 1.1 2001/10/26 21:09:05 lachoy Exp $
use strict;
use constant DEFAULT_MIME_TYPE => 'text/plain';
# Class method so that you can lookup a MIME type by an extension. If
# the extension isn't found, we return DEFAULT_MIME_TYPE
sub mime_type_by_extension {
my ( $class, $extension ) = @_;
$extension = lc $extension;
my $type_list = $class->db_select({ from => $class->table_name,
select => 'mime_type',
where => 'extensions LIKE ?',
value => [ "% $extension %" ],
return => 'list-single',
db => $class->global_datasource_handle });
return $type_list->[0]->{mime_type} if ( $type_list->[0] );
return DEFAULT_MIME_TYPE;
}
1;
|