--- loncom/publisher/loncfile.pm 2013/07/03 05:03:19 1.120 +++ loncom/publisher/loncfile.pm 2019/03/06 02:31:16 1.125 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.120 2013/07/03 05:03:19 raeburn Exp $ +# $Id: loncfile.pm,v 1.125 2019/03/06 02:31:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -109,13 +109,13 @@ sub Debug { } sub done { - my ($url) = @_; + my ($destfn) = @_; return '
'
.&Apache::lonhtmlcommon::confirm_success(&mt("Done"))
- .'
'.&mt("Continue").''
+ .'
'.&mt("Continue").''
.''
.'
'.&mt('Error: destination for operation is an existing directory.').'
'); + return ('error',''.&mt('Error: destination for operation is an existing directory.').'
'); } if ( -e $published) { if ( -e $construct ) { $type = 'warning'; - $result.=''.&mt('Warning: target file exists, and has been published!').'
'; + $result.=''.&mt('Warning: target file exists, and has been published!').'
'; } else { my $published_type = (-d $published) ? 'directory' : 'file'; if ($published_type eq $creating) { $type = 'warning'; - $result.=''.&mt("Warning: a published $published_type of this name exists.").'
'; + $result.=''.&mt("Warning: a published $published_type of this name exists.").'
'; } else { $type = 'error'; - $result.=''.&mt("Error: a published $published_type of this name exists.").'
'; + $result.=''.&mt("Error: a published $published_type of this name exists.").'
'; } } } elsif ( -e $construct) { $type = 'warning'; - $result.=''.&mt('Warning: target file exists!').'
'; + $result.=''.&mt('Warning: target file exists!').'
'; } return ($type,$result); @@ -344,15 +348,16 @@ sub checksuffix { if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; } if (lc($oldsuffix) ne lc($newsuffix)) { $result.= - ''.&mt('Warning: change of MIME type!').'
'; + ''.&mt('Warning: change of MIME type!').'>
'; } return $result; } sub cleanDest { - my ($request,$dest,$subdir,$fn,$uname,$udom)=@_; + my ($dest,$subdir,$fn,$uname,$udom)=@_; #remove bad characters my $foundbad=0; + my $warnings; my $error=''; if ($subdir && $dest =~/\./) { $foundbad=1; @@ -367,30 +372,29 @@ sub cleanDest { my ($newpath)=($dest=~m|(.*)/|); ($newpath,$error)=&relativeDest($fn,$newpath,$uname,$udom); if (! -d "$newpath") { - $request->print('' - .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested filename." - ,&display($newpath)) - .'
'); + $warnings = '' + .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested filename." + ,&display($newpath)) + .'
'; $dest=~s|.*/||; } } - if ($dest =~ /\.(\d+)\.(\w+)$/){ - $request->print(''
- .&mt('Bad filename [_1]',&display($dest))
- .'
'
- .&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
- .'
'
- .&mt('Removing the [_1].number.[_2] from requested filename.','','')
- .'
'
+ .&mt('Bad filename [_1]',&display($dest))
+ .'
'
+ .&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
+ .'
'
+ .&mt('Removing the [_1].number.[_2] from requested filename.','','')
+ .'
' - .&mt('Invalid characters in requested name have been removed.') - .'
' - ); + $warnings .= '' + .&mt('Invalid characters in requested name have been removed.') + .'
'; } - return ($dest,$error); + return ($dest,$error,$warnings); } sub relativeDest { @@ -469,7 +473,7 @@ Parameters: sub CloseForm2 { my ($request, $user, $fn) = @_; - $request->print(&done(&url($fn))); + $request->print(&done($fn)); } =pod @@ -708,9 +712,8 @@ sub Copy1 { my ($dir,$fname) = ($fn =~ m{^(.+/)([^/]+)$}); my $filesize = $fileinfo[7]; $filesize = int($filesize/1000); #expressed in kb - my $authorspace = $Apache::lonnet::perlvar{'lonDocRoot'}."/priv/$domain/$user"; - my $output = &Apache::loncommon::excess_filesize_authorspace($user,$domain,$authorspace, - $fname,$filesize,'copy'); + my $output = &Apache::loncommon::excess_filesize_warning($user,$domain,'author', + $fname,$filesize,'copy'); if ($output) { $request->print($output.''. &mt('Invalid filename: ').&display($newfilename).'
'.
&mt('The name of the new file needs to end with an appropriate file extension to indicate the type of file to create.').'
'.
@@ -896,16 +903,22 @@ sub NewFile1 {
'
'.&mt('Make new file').' '.&display($newfilename).'?
'); + $request->print(''); + $request->print(''); + $request->print(''); } - - $request->print(''.&mt('Make new file').' '.&display($newfilename).'?
'); - $request->print(''); - - $request->print(''); - $request->print(''); } return; } @@ -961,8 +974,8 @@ sub phaseone { my $doingdir=0; if ($env{'form.action'} eq 'newdir') { $doingdir=1; } - my ($newfilename,$error) = - &cleanDest($r,$env{'form.newfilename'},$doingdir,$fn,$uname,$udom); + my ($newfilename,$error,$warnings) = + &cleanDest($env{'form.newfilename'},$doingdir,$fn,$uname,$udom); unless ($error) { ($newfilename,$error)=&relativeDest($fn,$newfilename,$uname,$udom); } @@ -973,6 +986,9 @@ sub phaseone { } else { $dirlist=$fn; } + if ($warnings) { + $r->print($warnings); + } $r->print(''.&mt('Return to Directory'). '
'); @@ -982,49 +998,57 @@ sub phaseone { ''. ''. ''); - - if ($env{'form.action'} eq 'rename') { - &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename'); - } elsif ($env{'form.action'} eq 'move') { - &Rename1($r, $uname, $udom, $fn, $newfilename, 'move'); - } elsif ($env{'form.action'} eq 'delete') { - &Delete1($r, $uname, $udom, $fn); - } elsif ($env{'form.action'} eq 'decompress') { - &Decompress1($r, $uname, $udom, $fn); - } elsif ($env{'form.action'} eq 'copy') { - if($newfilename) { - &Copy1($r, $uname, $udom, $fn, $newfilename); - } else { - $r->print('' - .&mt('No new filename specified.') - .'
' - ); - } - } elsif ($env{'form.action'} eq 'newdir') { - my $mode = ''; - if (exists($env{'form.callingmode'}) ) { - $mode = $env{'form.callingmode'}; - } - &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); - } elsif ($env{'form.action'} eq 'newfile' || - $env{'form.action'} eq 'newhtmlfile' || - $env{'form.action'} eq 'newproblemfile' || - $env{'form.action'} eq 'newpagefile' || - $env{'form.action'} eq 'newsequencefile' || - $env{'form.action'} eq 'newrightsfile' || - $env{'form.action'} eq 'newstyfile' || - $env{'form.action'} eq 'newtaskfile' || - $env{'form.action'} eq 'newlibraryfile' || - $env{'form.action'} eq 'Select Action') { + + if ($env{'form.action'} eq 'newfile' || + $env{'form.action'} eq 'newhtmlfile' || + $env{'form.action'} eq 'newproblemfile' || + $env{'form.action'} eq 'newpagefile' || + $env{'form.action'} eq 'newsequencefile' || + $env{'form.action'} eq 'newrightsfile' || + $env{'form.action'} eq 'newstyfile' || + $env{'form.action'} eq 'newtaskfile' || + $env{'form.action'} eq 'newlibraryfile' || + $env{'form.action'} eq 'Select Action') { my $empty=&mt('Type Name Here'); - if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { - &NewFile1($r, $uname, $udom, $fn, $newfilename); - } else { + if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { + &NewFile1($r, $uname, $udom, $fn, $newfilename, $warnings); + } else { + if ($warnings) { + $r->print($warnings); + } $r->print('' .&mt('No new filename specified.') .'
' ); - } + } + } else { + if ($warnings) { + $r->print($warnings); + } + if ($env{'form.action'} eq 'rename') { + &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename'); + } elsif ($env{'form.action'} eq 'move') { + &Rename1($r, $uname, $udom, $fn, $newfilename, 'move'); + } elsif ($env{'form.action'} eq 'delete') { + &Delete1($r, $uname, $udom, $fn); + } elsif ($env{'form.action'} eq 'decompress') { + &Decompress1($r, $uname, $udom, $fn); + } elsif ($env{'form.action'} eq 'copy') { + if ($newfilename) { + &Copy1($r, $uname, $udom, $fn, $newfilename); + } else { + $r->print('' + .&mt('No new filename specified.') + .'
' + ); + } + } elsif ($env{'form.action'} eq 'newdir') { + my $mode = ''; + if (exists($env{'form.callingmode'}) ) { + $mode = $env{'form.callingmode'}; + } + &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); + } } } @@ -1413,7 +1437,7 @@ sub phasetwo { [''.&mt('Return to Directory').'', ''.$disp_newname.''])); } else { - $r->print(&done(&url($dest))); + $r->print(&done($dest)); } } } @@ -1422,7 +1446,7 @@ sub handler { $r=shift; - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename','mode']); &Debug($r, "loncfile.pm - handler entered"); &Debug($r, " filename: ".$env{'form.filename'});