--- loncom/publisher/lonpubdir.pm 2016/06/19 04:27:58 1.169
+++ 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.169 2016/06/19 04:27:58 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;
}
@@ -67,9 +67,7 @@ sub handler {
$r->send_http_header;
&Apache::lonhtmlcommon::clear_breadcrumbs();
- my $js = '';
- $r->print(&Apache::loncommon::start_page('Authoring Space', $js).
+ $r->print(&Apache::loncommon::start_page('Authoring Space').
'
'.
'
'.
&mt('Your Authoring Space is currently in the location used by LON-CAPA version 2.10 and older, but your domain is using a newer LON-CAPA version ([_1]).',$version).'
'.
@@ -106,9 +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
-
# Put out the start of page.
- &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor);
+
+ &startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor);
if (!-d $fn) {
if (-e $fn) {
@@ -130,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.').'
');
@@ -194,7 +192,7 @@ sub handler {
order => 'ascending',
text => &mt('Size').' (kB)',
},
- );
+ );
# Print column headers
my $output = '';
@@ -239,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()));
+ .&Apache::loncommon::CSTR_pageheader('','',$headertext)));
my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn);
my $doctitle = 'LON-CAPA '.&mt($title);
@@ -412,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) {
@@ -514,19 +505,16 @@ 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',
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',
+ uplo => 'Upload file',
dele => 'Delete',
- edit => 'Edit Metadata',
sela => 'Select Action',
nfil => 'New file',
nhtm => 'New HTML file',
@@ -543,58 +531,80 @@ 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',
- qs => 'Quick Search',
+ crea => 'Create a new subdirectory or document',
+ qs => 'Quick name search',
cs => 'Case Sensitive',
re => 'Regular Expression',
- acti => 'Actions for current directory',
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->printf(<
-
END
}
@@ -682,26 +678,26 @@ END
sub resourceactions {
my ($r,$uname,$udom,$thisdisfn) = @_;
$r->print(<
+
-
+
-
+
-
+
-
+
-
+
END
@@ -752,9 +748,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 '.')) {
@@ -777,9 +773,9 @@ sub putdirectory {
$actionitem = &mt('Go to ...');
$disfilename = ''.&mt('Parent Directory').' ';
} else {
- $actionitem =
+ $actionitem =
''.
+ '" action="/adm/publish">'.
''.
''.&mt('Select action').' '.
''.&mt('Open').' '.
@@ -798,7 +794,7 @@ sub putdirectory {
' '.
''.$actionitem.' '.
- ''.
+ ' '.
$disfilename.' '.
''.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
@@ -831,7 +827,7 @@ sub getTitle {
&Apache::loncommon::modal_link(
'/adm/retrieve?filename='.$linkfilename.'.meta&inhibitmenu=yes&add_modal=yes',
&mt('Retrieve Metadata'),600,500);
- }
+ }
}
# Allow editing metadata of published and unpublished resources
$title .= "\n".' ' if ($title);
@@ -850,14 +846,13 @@ sub isMetaSame {
my $meta_cmtime = (stat($cstr_dir.'/'.$filename.'.meta'))[9];
my $meta_rmtime = (stat($resdir.'/'.$filename.'.meta'))[9];
return (&Apache::londiff::are_different_files($resdir.'/'.$filename.'.meta',
- $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime)
+ $cstr_dir.'/'.$filename.'.meta') && $meta_rmtime < $meta_cmtime)
? 0 : 1;
}
-
-sub getStatus {
- my ($resdir, $targetdir, $cstr_dir, $filename,
- $linkfilename, $cmtime, $meta_same) = @_;
+sub getStatus {
+ my ($resdir, $targetdir, $cstr_dir, $filename,
+ $linkfilename, $crsauthor, $cmtime, $meta_same) = @_;
my $pubstatus = 'unpublished';
my $status = &mt('Unpublished');
@@ -883,7 +878,9 @@ sub getStatus {
);
$rights_status .=
$lt_SourceRight{&getSourceRightString($targetdir.'/'.$filename)};
-
+ if (($crsauthor) && ($filename =~ /\.rights$/)) {
+ $rights_status =~ s/,\s+$//;
+ }
if ($same) {
if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) {
$pubstatus = 'obsolete';
@@ -901,17 +898,21 @@ sub getStatus {
$pubstatus = 'modified';
$status=&mt('Modified').
' '. $rights_status;
- if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
- $status.=' '.
- &Apache::loncommon::modal_link(
- '/adm/diff?filename='.$linkfilename.'&versiontwo=priv',
- &mt('Diffs'),600,500);
+ unless (($crsauthor) && ($filename =~ /\.rights$/)) {
+ if (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
+ $status.=' '.
+ &Apache::loncommon::modal_link(
+ '/adm/diff?filename='.$linkfilename.'&versiontwo=priv',
+ &mt('Diffs'),600,500);
+ }
}
- }
+ }
- $status.="\n".' '.
- &Apache::loncommon::modal_link(
- '/adm/retrieve?filename='.$linkfilename.'&inhibitmenu=yes&add_modal=yes',&mt('Retrieve'),600,500);
+ unless (($crsauthor) && ($filename =~ /\.rights$/)) {
+ $status.="\n".' '.
+ &Apache::loncommon::modal_link(
+ '/adm/retrieve?filename='.$linkfilename.'&inhibitmenu=yes&add_modal=yes',&mt('Retrieve'),600,500);
+ }
}
return ($status, $pubstatus);
@@ -922,9 +923,10 @@ sub getStatus {
# Put a table row for a file resource.
#
sub putresource {
- my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir,
- $linkdir, $cmtime, $size, $numres, $linkfilename, $title,
- $status, $pubstatus) = @_;
+ my ($r, $udom, $uname, $filename, $thisdisfn, $resdir,
+ $targetdir, $linkdir, $crsauthor, $cmtime, $size,
+ $numres, $linkfilename, $title, $status, $pubstatus,
+ $editors) = @_;
&Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename);
my $editlink='';
@@ -933,30 +935,37 @@ 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 ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) {
+ if (($editors->{'daxe'}) &&
+ ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) {
my $daxeurl = '/daxepage'.$linkdir.'/'.$filename;
- $editlink .= ' (Daxe )';
+ $editlink .= ' (Daxe )';
}
}
if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
- $editlink.=' ('.&mt('Clean Up').') ';
+ $editlink.=' ('.&mt('Clean Up').') ';
}
if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
- $editlink=' ('.&mt('Decompress').' )';
+ $editlink=' ('.&mt('Decompress').' )';
}
my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
my $pub_select = '';
- &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
+ unless (($crsauthor) && ($filename=~ /\.rights$/)) {
+ &create_pubselect($r,\$pub_select,$udom,$uname,$thisdisfn,$filename,$resdir,$pubstatus,$publish_button,$numres);
+ }
$r->print(&Apache::loncommon::start_data_table_row().
' '.($filename=~/[\#\~]$/?' ':
' ').' '.
''.$pub_select.' '.
''.
- ''.
+ ' '.
$filename.' '.$editlink2.$editlink.
' '.
''.$title.' '.
@@ -977,7 +986,7 @@ sub create_pubselect {
'.&mt('Select action').' '.
''.&mt('Copy').' ';
if ($pubstatus eq 'obsolete' || $pubstatus eq 'unpublished') {
- $$pub_select .=
+ $$pub_select .=
''.&mt('Rename').' '.
''.&mt('Move').' '.
''.&mt('Delete').' ';
@@ -1016,7 +1025,7 @@ sub check_for_versions {
opendir(DIR,$resdir);
while (my $filename=readdir(DIR)) {
if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
- $versions ++;
+ $versions ++;
}
}
closedir(DIR);
@@ -1024,7 +1033,7 @@ sub check_for_versions {
}
sub prepareJsonTranslations {
- my $json =
+ my $json =
'{"translations":{'.
'"edit":"'.&mt('Edit').'",'.
'"editxml":"'.&mt('EditXML').'",'.
@@ -1095,7 +1104,7 @@ sub prepareJsonData_rec {
closedir(DIR);
# nothing to do here if both lists are empty
return unless ( @dirs || @resources );
-
+
# Phase 2: Working
$$firstfile = 1;
@@ -1217,9 +1226,9 @@ run through list of files and attempt to
=item startpage($r, $uame, $udom, $thisdisfn)
Output the header of the page. This includes:
- - The HTML header
+ - The HTML header
- The H1/H3 stuff which includes the directory.
-
+
startpage($r, $uame, $udom, $thisdisfn);
$r - The apache request object.
$uname - User name.
@@ -1232,7 +1241,7 @@ Output the header of the page. This inc
Without the latter substitution, it's impossible to examine metadata for
untitled resources. Resources may be legitimately untitled, to prevent
searches from locating them.
-
+
$str = getTitleString($fullname);
$fullname - Fully qualified filename to check.
@@ -1240,7 +1249,7 @@ Output the header of the page. This inc
$numdir)
Put out a directory table row:
-
+
$r - Apache request object.
$reqfile - File in request.
$here - Where we are in directory tree.