--- loncom/publisher/loncfile.pm 2023/07/14 23:20:15 1.127 +++ loncom/publisher/loncfile.pm 2024/05/13 13:55:50 1.128 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.127 2023/07/14 23:20:15 raeburn Exp $ +# $Id: loncfile.pm,v 1.128 2024/05/13 13:55:50 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -70,10 +70,10 @@ use HTML::Entities(); use Apache::Constants qw(:common :http :methods); use Apache::lonnet; use Apache::loncommon(); +use Apache::lonhtmlcommon; use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); - my $DEBUG=0; my $r; # Needs to be global for some stuff RF. @@ -819,6 +819,130 @@ sub Decompress1 { } } +sub Archive1 { + my ($request,$fn) = @_; + my @posstypes = qw(problem library sty sequence page task rights meta xml html xhtml htm xhtm css js tex txt gif jpg jpeg png svg other); + my (%location_of,%default,$compstyle); + foreach my $program ('tar','gzip','bzip2','xz','zip') { + foreach my $dir ('/bin/','/usr/bin/','/usr/local/bin/','/sbin/', + '/usr/sbin/') { + if (-x $dir.$program) { + $location_of{$program} = $dir.$program; + last; + } + } + } + my (%defaults,$cancompress,$canarchive); + if (exists($location_of{'tar'})) { + $default{'tar'} = ' checked="checked"'; + $canarchive = 1; + $compstyle = 'block'; + } elsif (exists($location_of{'zip'})) { + $default{'zip'} = ' checked="checked"'; + $canarchive = 1; + $compstyle = 'none'; + } + foreach my $compress ('gzip','bzip2','xz') { + if (exists($location_of{$compress})) { + $default{$compress} = ' checked="checked"'; + $cancompress = 1; + last; + } + } + if (!$canarchive) { + $request->print('
'. + &mt('This LON-CAPA instance does not seem to have either tar or zip installed.').'
'. + ''. + &mt('At least one of the two is needed in order to be able to create an archive file for: [_1].', + &display($fn)). + ''); + } elsif (-e $fn) { + $request->print(&Apache::lonhtmlcommon::start_pick_box(). + &Apache::lonhtmlcommon::row_title(&mt('Directory')). + &display($fn). + &Apache::lonhtmlcommon::row_closure(). + &Apache::lonhtmlcommon::row_title(&mt('Options'). + &Apache::loncommon::help_open_topic('Archiving_Directory_Options')). + ''. + ''. + ''."\n". + ''. + &Apache::lonhtmlcommon::row_closure(1). + &Apache::lonhtmlcommon::end_pick_box() + ); + &CloseForm1($request, $fn); + } else { + $request->print('' + .&mt('No such directory: [_1]', + &display($fn)) + .'
' + ); + } +} + =pod =item NewFile1 @@ -994,7 +1118,7 @@ sub phaseone { ''); return; } - $r->print('