--- loncom/publisher/lonpubdir.pm 2023/12/29 21:36:23 1.160.2.5.2.2
+++ loncom/publisher/lonpubdir.pm 2024/08/22 18:32:56 1.160.2.5.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Authoring Space Directory Lister
#
-# $Id: lonpubdir.pm,v 1.160.2.5.2.2 2023/12/29 21:36:23 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.160.2.5.2.5 2024/08/22 18:32:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -290,6 +290,7 @@ sub handler {
}
# Print the sorted resources
+ my %editors = &Apache::loncommon::permitted_editors();
foreach my $filename (@sorted_files) {
if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories
&putdirectory($r, $thisdisfn, $linkdir, $filename,
@@ -302,7 +303,8 @@ sub handler {
$filehash->{$filename}->{"linkfilename"},
$filehash->{$filename}->{"fulltitle"},
$filehash->{$filename}->{"status"},
- $filehash->{$filename}->{"pubstatus"});
+ $filehash->{$filename}->{"pubstatus"},
+ \%editors);
}
}
@@ -352,12 +354,14 @@ sub startpage {
my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in MB
$disk_quota = 1024 * $disk_quota; # convert from MB to kB
+ my $headertext = &mt('Directory');
+
$r->print(&Apache::loncommon::head_subbox(
'
'
.&Apache::lonhtmlcommon::display_usage($current_disk_usage,
$disk_quota,'authoring')
.'
'
- .&Apache::loncommon::CSTR_pageheader()));
+ .&Apache::loncommon::CSTR_pageheader('','',$headertext)));
my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
my $doctitle = 'LON-CAPA '.&mt('Authoring Space');
@@ -371,25 +375,6 @@ 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")
@@ -473,19 +458,16 @@ ENDPUBDIRSCRIPT
}
sub dircontrols {
- my ($r,$uname,$udom,$thisdisfn, $current_disk_usage, $disk_quota) = @_;
+ my ($r,$uname,$udom,$thisdisfn,$current_disk_usage,$disk_quota) = @_;
my %lt=&Apache::lonlocal::texthash(
cnpd => 'Cannot publish directory',
cnrd => 'Cannot retrieve directory',
mcdi => 'Must create new subdirectory inside a directory',
pubr => 'Publish this Resource',
- pubd => 'Publish this Directory',
- dedr => 'Delete Directory',
rtrv => 'Retrieve Old Version',
list => 'List Directory',
uplo => 'Upload file',
dele => 'Delete',
- edit => 'Edit Metadata',
sela => 'Select Action',
nfil => 'New file',
nhtm => 'New HTML file',
@@ -502,47 +484,46 @@ sub dircontrols {
copy => 'Copy current file to',
type => 'Type Name Here',
go => 'Go',
- prnt => 'Print contents of directory',
- crea => 'Create a new directory or LON-CAPA document',
- acti => 'Actions for current directory',
+ crea => 'Create a new subdirectory or document',
updc => 'Upload a new document',
pick => 'Please select an action to perform using the new filename',
+ shcu => 'Shortcuts',
);
+ my %js_lt = &Apache::lonlocal::texthash(
+ 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.
# $disk_quota is in MB and $current_disk_usage is in kB
my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
+ $r->print("\n".''."\n");
+ my %fileoptions = (
+ none => "$lt{'sela'}:",
+ newfile => "$lt{'nfil'}:",
+ newhtmlfile => "$lt{'nhtm'}:",
+ newproblemfile => "$lt{'nprb'}:",
+ newdir => "$lt{'nsub'}:",
+ newpagefile => "$lt{'npag'}:",
+ newsequencefile => "$lt{'nseq'}:",
+ newrightsfile => "$lt{'ncrf'}:",
+ newstyfile => "$lt{'nsty'}:",
+ newtaskfile => "$lt{'nbt'}:",
+ newlibraryfile => "$lt{'nlib'}:",
+ );
+ $fileoptions{'select_form_order'} = ['none','newfile','newhtmlfile','newproblemfile',
+ 'newpagefile','newsequencefile','newrightsfile',
+ 'newstyfile','newtaskfile','newlibraryfile','newdir'];
+ my $selectbox = &Apache::loncommon::select_form('none','action',\%fileoptions);
$r->print(<
-
-
-
-
-
-
+
END
}
@@ -868,7 +847,7 @@ sub getStatus {
sub putresource {
my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir,
$linkdir, $cmtime, $size, $numres, $linkfilename, $title,
- $status, $pubstatus) = @_;
+ $status, $pubstatus, $editors) = @_;
&Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
my $editlink='';
@@ -877,8 +856,19 @@ sub putresource {
$editlink='
('.&mt('Edit').')';
}
if ($filename=~/$LONCAPA::assess_re/) {
- $editlink=' ('.&mt('EditXML').')';
- $editlink2='
('.&mt('Edit').')';
+ if ($editors->{'xml'}) {
+ $editlink=' ('.&mt('EditXML').')';
+ }
+ if ($editors->{'edit'}) {
+ $editlink2='
('.&mt('Edit').')';
+ }
+ }
+ if ($filename=~/\.(xml|html|htm|xhtml|xhtm)$/ || $filename=~/$LONCAPA::assess_re/) {
+ if (($editors->{'daxe'}) &&
+ ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) {
+ my $daxeurl = '/daxepage'.$linkdir.'/'.$filename;
+ $editlink .= ' (Daxe)';
+ }
}
if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
$editlink.=' ('.&mt('Clean Up').')';