--- loncom/publisher/lonpubdir.pm 2023/06/11 20:45:40 1.178 +++ loncom/publisher/lonpubdir.pm 2023/07/14 18:01:23 1.180 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Authoring Space Directory Lister # -# $Id: lonpubdir.pm,v 1.178 2023/06/11 20:45:40 raeburn Exp $ +# $Id: lonpubdir.pm,v 1.180 2023/07/14 18:01:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,7 +48,7 @@ sub handler { # Validate access to the construction space and get username:domain. - my ($uname,$udom)=&Apache::lonnet::constructaccess($r->uri); + my ($uname,$udom)=&Apache::lonnet::constructaccess($r->uri); unless (($uname) && ($udom)) { return HTTP_NOT_ACCEPTABLE; } @@ -105,7 +105,7 @@ sub handler { my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom, $cstr,$crstype); # expressed in MB # Put out the start of page. - + &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor); if (!-d $fn) { @@ -128,12 +128,12 @@ sub handler { } # Put out actions for directory, browse/upload + new file page. - &dircontrols($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota); + &dircontrols($r,$uname,$udom,$thisdisfn,$current_disk_usage,$disk_quota,$crsauthor); &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc. my $numdir = 0; my $numres = 0; - + if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) { if ($thisdisfn =~ m{^/$match_domain/$match_username$}) { $r->print('

'.&mt('This Authoring Space is currently empty.').'

'); @@ -192,7 +192,7 @@ sub handler { order => 'ascending', text => &mt('Size').' (kB)', }, - ); + ); # Print column headers my $output = ''; @@ -237,18 +237,23 @@ my $result = "'; $r->print(&Apache::loncommon::start_page($title, $js)); $disk_quota = 1024 * $disk_quota; # convert from MB to kB + my $headertext = &mt('Directory'); + if ($crsauthor) { + $headertext = &mt('Course Authoring Directory'); + } $r->print(&Apache::loncommon::head_subbox( '
' .&Apache::lonhtmlcommon::display_usage($current_disk_usage, $disk_quota,'authoring') .'
' - .&Apache::loncommon::CSTR_pageheader('','',&mt('Directory')))); + .&Apache::loncommon::CSTR_pageheader('','',$headertext))); my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); my $doctitle = 'LON-CAPA '.&mt($title); @@ -413,9 +423,9 @@ parent.lastknownpriv='/priv$esc_thisdisf function checkUpload(theform) { if (theform.file == '') { alert("Please use 'Browse..' to choose a file first, before uploading") - return + return } - theform.submit() + theform.submit() } function SetPubDir(theform,printForm) { @@ -493,7 +503,7 @@ ENDPUBDIRSCRIPT } sub dircontrols { - my ($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota) = @_; + my ($r,$uname,$udom,$thisdisfn,$current_disk_usage,$disk_quota,$crsauthor) = @_; my %lt=&Apache::lonlocal::texthash( cnpd => 'Cannot publish directory', cnrd => 'Cannot retrieve directory', @@ -501,7 +511,7 @@ sub dircontrols { pubr => 'Publish this Resource', rtrv => 'Retrieve Old Version', list => 'List Directory', - uplo => 'Upload file', + uplo => 'Upload file', dele => 'Delete', sela => 'Select Action', nfil => 'New file', @@ -531,7 +541,7 @@ sub dircontrols { nanf => 'Name of New File', nans => 'Name of New Subdirectory', psfn => 'Please specify file name', - ); + ); &js_escape(\%js_lt); my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript # Calculate free space in bytes. @@ -552,6 +562,32 @@ sub dircontrols { END + my %fileoptions = ( + none => "$lt{'sela'}:", + newfile => "$lt{'nfil'}:", + newhtmlfile => "$lt{'nhtm'}:", + newproblemfile => "$lt{'nprb'}:", + newdir => "$lt{'nsub'}:", + ); + $fileoptions{'select_form_order'} = ['none','newfile','newhtmlfile','newproblemfile']; + if ($crsauthor) { + push(@{$fileoptions{'select_form_order'}},'newdir'); + } else { + my %extraoptions = ( + newpagefile => "$lt{'npag'}:", + newsequencefile => "$lt{'nseq'}:", + newrightsfile => "$lt{'ncrf'}:", + newstyfile => "$lt{'nsty'}:", + newtaskfile => "$lt{'nbt'}:", + newlibraryfile => "$lt{'nlib'}:", + ); + %fileoptions = (%fileoptions,%extraoptions); + push(@{$fileoptions{'select_form_order'}},('newpagefile','newsequencefile', + 'newrightsfile','newstyfile', + 'newtaskfile','newlibraryfile', + 'newdir')); + } + my $selectbox = &Apache::loncommon::select_form('none','action',\%fileoptions); $r->print(<
@@ -581,19 +617,7 @@ END } } -    + $selectbox  
$lt{'shcu'}: @@ -722,9 +746,9 @@ sub putdirectory { my ($r, $reqfile, $here, $dirname, $modtime, $targetdir, $bombs, $numdir) = @_; # construct the display filename: the directory name unless ..: - + my $actionitem; - + my $disfilename = $dirname; # Don't display directory itself, and there is no way up from root directory unless ((($dirname eq '..') && ($reqfile=~/^\/[^\/]+\/[^\/]+$/)) || ($dirname eq '.')) { @@ -747,7 +771,7 @@ sub putdirectory { $actionitem = &mt('Go to ...'); $disfilename = ''.&mt('Parent Directory').''; } else { - $actionitem = + $actionitem = ''. '