--- loncom/interface/loncommon.pm 2012/01/09 19:56:28 1.1052 +++ loncom/interface/loncommon.pm 2012/01/16 18:00:24 1.1053 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1052 2012/01/09 19:56:28 www Exp $ +# $Id: loncommon.pm,v 1.1053 2012/01/16 18:00:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -9708,6 +9708,75 @@ sub check_for_traversal { return $cleanpath; } +sub is_archive_file { + my ($mimetype) = @_; + if (($mimetype eq 'application/octet-stream') || + ($mimetype eq 'application/x-stuffit') || + ($mimetype =~ m{^application/(x\-)?(compressed|tar|zip|tgz|gz|gtar|gzip|gunzip|bz|bz2|bzip2)})) { + return 1; + } + return; +} + +sub decompress_form { + my ($mimetype,$archiveurl,$action,$noextract,$hiddenelements) = @_; + my %lt = &Apache::lonlocal::texthash ( + this => 'This file is an archive file.', + youm => 'You may wish to extract its contents.', + camt => 'Extraction of contents is recommended for Camtasia zip files.', + perm => 'Permanently remove archive file after extraction of contents?', + extr => 'Extract contents', + yes => 'Yes', + no => 'No', + ); + my $output = '
'.$lt{'this'}.' '.$lt{'youm'}.'
';
+ if ($mimetype =~ m{^application/(x\-)?(compressed|zip)}) {
+ $output .= $lt{'camt'};
+ }
+ $output .= '