--- loncom/publisher/lonpubdir.pm 2023/06/11 19:46:01 1.177
+++ loncom/publisher/lonpubdir.pm 2023/11/17 17:02:22 1.181
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Authoring Space Directory Lister
#
-# $Id: lonpubdir.pm,v 1.177 2023/06/11 19:46:01 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.181 2023/11/17 17:02:22 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;
}
@@ -104,14 +104,9 @@ sub handler {
"$londocroot/priv/$udom/$uname"); # expressed in kB
my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,
$cstr,$crstype); # expressed in MB
- my $diraction;
- if (-d $fn) {
- $diraction = &diractions($thisdisfn);
- }
-
# Put out the start of page.
-
- &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor, $diraction);
+
+ &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor);
if (!-d $fn) {
if (-e $fn) {
@@ -133,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.').'
');
@@ -197,7 +192,7 @@ sub handler {
order => 'ascending',
text => &mt('Size').' (kB)',
},
- );
+ );
# Print column headers
my $output = '';
@@ -242,18 +237,23 @@ my $result = "';
$r->print(&Apache::loncommon::start_page($title, $js));
$disk_quota = 1024 * $disk_quota; # convert from MB to kB
- my $heading = &mt('Directory');
+ 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('','',$heading,$diraction)));
+ .&Apache::loncommon::CSTR_pageheader('','',$headertext)));
my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
my $doctitle = 'LON-CAPA '.&mt($title);
@@ -416,31 +422,12 @@ parent.lastknownpriv='/priv$esc_thisdisf
// Confirmation dialogues
- function currdiract(theform) {
- if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'publish') {
- document.publishdir.filename.value = theform.filename.value;
- document.publishdir.submit();
- }
- if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'editmeta') {
- top.location=theform.filename.value+'default.meta'
- }
- if (theform.dirtask.options[theform.dirtask.selectedIndex].value == 'printdir' ) {
- document.printdir.postdata.value=theform.filename.value
- document.printdir.submit();
- }
- if (theform.dirtask.options[theform.dirtask.selectedIndex].value == "delete") {
- var delform = document.delresource
- delform.filename.value = theform.filename.value
- delform.submit()
- }
- }
-
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) {
@@ -517,43 +504,8 @@ ENDPUBDIRSCRIPT
$r->print($pubdirscript);
}
-sub diractions {
- my ($thisdisfn) = @_;
- my %lt=&Apache::lonlocal::texthash(
- acti => 'Actions for current directory',
- sela => 'Select Action',
- pubd => 'Publish this Directory',
- prnt => 'Print contents of directory',
- edit => 'Edit Metadata',
- dedr => 'Delete Directory',
- );
- return <
-$lt{'acti'}
-
-
-
-
-END
-
-}
-
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',
@@ -561,7 +513,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',
@@ -591,7 +543,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.
@@ -612,6 +564,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(<