From: Rob H. <for...@us...> - 2001-12-20 23:38:03
|
Update of /cvsroot/sandweb/sandweb/lib/SandWeb In directory usw-pr-cvs1:/tmp/cvs-serv5039/lib/SandWeb Modified Files: File.pm Log Message: non-text files now give the download option when you click on them. it essentially pulls up the view_file template with no content. Index: File.pm =================================================================== RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -U2 -r1.24 -r1.25 --- File.pm 2001/12/20 23:26:19 1.24 +++ File.pm 2001/12/20 23:31:37 1.25 @@ -82,25 +82,14 @@ } -sub _get_mime_type { - my %args = @_; - my $location = $args{'location'}; - my $filename = $args{'filename'}; +sub get_mime_type { + my $self = shift; + my $location = $self->{'location'}; + my $filename = $self->{'filename'}; - my @file_split = split(/\./, $filename); - my $file_extension = $file_split[$#file_split]; - my $mime_type; - open FILE,"< /usr/local/apache/conf/mime.types"; - my @mimes = <FILE>; - close FILE; - foreach my $entry (@mimes) { - unless ( $entry =~ /^#/) { - my @mime_string = split(/\s+/, $entry); - if ($mime_string[1]) { - if ( $file_extension eq $mime_string[1] ){ - $mime_type = $mime_string[0]; - } - } - } - } + my $mime_type = _get_mime_type( + 'location' => "$location", + 'filename' => "$filename", + ); + return $mime_type; } @@ -293,4 +282,28 @@ 'download', ); +} + +sub _get_mime_type { + my %args = @_; + my $location = $args{'location'}; + my $filename = $args{'filename'}; + + my @file_split = split(/\./, $filename); + my $file_extension = $file_split[$#file_split]; + my $mime_type; + open FILE,"< /usr/local/apache/conf/mime.types"; + my @mimes = <FILE>; + close FILE; + foreach my $entry (@mimes) { + unless ( $entry =~ /^#/) { + my @mime_string = split(/\s+/, $entry); + if ($mime_string[1]) { + if ( $file_extension eq $mime_string[1] ){ + $mime_type = $mime_string[0]; + } + } + } + } + return $mime_type; } |