--- loncom/publisher/loncfile.pm 2008/03/12 02:46:38 1.88
+++ loncom/publisher/loncfile.pm 2012/06/04 19:23:41 1.115
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.88 2008/03/12 02:46:38 raeburn Exp $
+# $Id: loncfile.pm,v 1.115 2012/06/04 19:23:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -109,6 +109,17 @@ sub Debug {
}
}
+sub done {
+ my ($url)=@_;
+ my $done=&mt("Done");
+ return(< '.&mt('Error: destination for operation is an existing directory.').' ".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"'.&display($newpath).'"')." '
+ .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested file name."
+ ,&display($newpath))
+ .' '
+ .&mt('Bad filename [_1]',&display($dest))
+ .' ".&mt('Invalid characters in requested name have been removed.')." '
+ .&mt('Invalid characters in requested name have been removed.')
+ .' '.
+ &mt('Cannot change MIME type of a directory.').
''.
- ' '
+ .&mt('Cannot rename or move non-obsolete published file.')
+ .' '.$action.' '.&display($fn).
- '
(name).(number).(extension) not allowed.
Removing the .number. from requested filename.',&display($dest))
- .'');
+ $request->print('
'
+ .&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
+ .'
'
+ .&mt('Removing the [_1].number.[_2] from requested filename.','','')
+ .''.&mt('Done').'
');
+ $request->print(&done(&url($fn)));
}
=pod
@@ -496,10 +530,10 @@ sub Rename1 {
if (-d $fn) {
$newfilename=~/\.(\w+)$/;
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
- $request->print('
'.
- &mt('Cannot change MIME type of a directory').
+ $request->print('
'.&mt('Cancel').'');
+ '
'.&mt('Cancel').''.&mt('Cannot rename or move non-obsolete published file').'
'.
- '
'.&mt('Cancel').'');
+ $request->print('
'
+ .''.&mt('Cancel').'
to '.&display($newfilename).'?
' + .&mt($action.' [_1] to [_2]?', + &display($fn), + &display($newfilename)) + .'
' + ); &CloseForm1($request, $fn); } else { - $request->print(''.&mt('No new filename specified.').'
'); + $request->print(''.&mt('No new filename specified.').'
'); return; } } else { - $request->print(''.&mt('No such file').': '.&display($fn).'
'); + $request->print('' + .&mt('No such file: [_1]', + &display($fn)) + .'
' + ); return; } @@ -570,25 +615,41 @@ sub Delete1 { if( -e $fn) { $request->print(''); + $fn.'" />'); if (-d $fn) { unless (&empty_directory($fn,'Delete1')) { - $request->print(''
+ .''
+ .&mt('Only empty directories may be deleted.')
+ .'
'
+ .&mt('You must delete the contents of the directory first.')
+ .'
'
+ .&mt('Cannot delete non-obsolete published file.')
+ .'
'
+ .''.&mt('Cancel').'
'.&mt('Delete').' '.&display($fn).'?
'); + $request->print('' + .&mt('Delete [_1]?', + &display($fn)) + .'
' + ); &CloseForm1($request, $fn); } else { - $request->print(''.&mt('No such file').': '.&display($fn).'
'); + $request->print('' + .&mt('No such file: [_1]', + &display($fn)) + .'
' + ); } } @@ -642,13 +703,22 @@ sub Copy1 { $request->print(''.&mt('Copy').' '.&display($fn).'
to '.
- &display($newfilename).'?
' + .&mt('Copy [_1] to [_2]?', + &display($fn), + &display($newfilename)) + .'
' + ); &CloseForm1($request, $fn); } else { - $request->print(''.&mt('No such file').': '.&display($fn).'
'); + $request->print('' + .&mt('No such file: [_1]', + &display($fn)) + .'
' + ); } } @@ -699,14 +769,17 @@ sub NewDir1 { if ($type eq 'error') { $request->print(''); } else { - if ($mode eq 'testbank') { - $request->print(''); - } elsif ($mode eq 'imsimport') { - $request->print(''); - } - $request->print(''.&mt('Make new directory').' '. - &display($newfilename).'?
'); + if (($mode eq 'testbank') || ($mode eq 'imsimport')) { + $request->print(''."\n". + ''); + } + $request->print('' + .'' + .&mt('Make new directory [_1]?', + &display($newfilename)) + .'
' + ); &CloseForm1($request, $fn); } } @@ -715,11 +788,19 @@ sub NewDir1 { sub Decompress1 { my ($request, $user, $domain, $fn) = @_; if( -e $fn) { - $request->print(''); - $request->print(''.&mt('Decompress').' '.&display($fn).'?
'); + $request->print(''); + $request->print('' + .&mt('Decompress [_1]?', + &display($fn)) + .'
' + ); &CloseForm1($request, $fn); } else { - $request->print(''.&mt('No such file').': '.&display($fn).'
'); + $request->print('' + .&mt('No such file: [_1]', + &display($fn)) + .'
' + ); } } @@ -765,23 +846,10 @@ button which returns you to the driector sub NewFile1 { my ($request, $user, $domain, $fn, $newfilename) = @_; + return if (&filename_check($newfilename) ne 'ok'); if ($env{'form.action'} =~ /new(.+)file/) { my $extension=$1; - - ##Informs User (name).(number).(extension) not allowed - if($newfilename =~ /\.(\d+)\.(\w+)$/){ - $r->print(''.$newfilename. - ' - '.&mt('Bad Filename').''. + &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.').'
'.
+ &mt('The following are valid extensions: [_1].',$validexts).
+ '
'. + '
'. + ''); + return; + } + $request->print(''.&mt('Make new file').' '.&display($newfilename).'?
'); $request->print(''); + $request->print(''); + '" method="post">'); $request->print(''); + '" method="post">'); } + return; +} + +sub filename_check { + my ($newfilename) = @_; + ##Informs User (name).(number).(extension) not allowed + if($newfilename =~ /\.(\d+)\.(\w+)$/){ + $r->print(''.$newfilename. + ' - '.&mt('Bad Filename').'' + .&mt('No new filename specified.') + .'
' + ); } } elsif ($env{'form.action'} eq 'newdir') { my $mode = ''; @@ -879,7 +1008,10 @@ sub phaseone { if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { &NewFile1($r, $uname, $udom, $fn, $newfilename); } else { - $r->print(''.&mt('No new filename specified.').'
'); + $r->print('' + .&mt('No new filename specified.') + .'
' + ); } } } @@ -966,7 +1098,12 @@ sub Rename2 { unlink $tmp2; } } else { - $request->print("".&mt('No such file').": ".&display($oldfile).'
'); + $request->print( + '' + .&mt('No such file: [_1]', + &display($oldfile)) + .'
' + ); return 0; } return 1; @@ -1014,7 +1151,7 @@ sub Delete2 { return 0; } } else { - $request->print(''.&mt('No such file').'.
'); + $request->print(''.&mt('No such file').'
'); return 0; } } @@ -1025,7 +1162,7 @@ sub Delete2 { return 0; } } else { - $request->print(''.&mt('No such file').'.
'); + $request->print(''.&mt('No such file').'
'); return 0; } } @@ -1084,7 +1221,7 @@ sub Copy2 { return 1; } } else { - $request->print(''.&mt('No such file').'
'); + $request->print(''.&mt('No such file').'
'); return 0; } return 1; @@ -1238,7 +1375,7 @@ sub phasetwo { } $dest = $env{'form.newfilename'}; } else { - $r->print(''.&mt('No New filename specified').'
'); + $r->print(''.&mt('No New filename specified').'
'); return; } @@ -1256,7 +1393,7 @@ sub phasetwo { $r->print('' + .&mt('Co-Author [_1]',$uname.':'.$udom) + .'
' + ); } @@ -1377,8 +1532,11 @@ function writeDone() { $env{'form.action'} eq 'Select Action' ) { $r->print(''.&mt('Unknown Action').' '.$env{'form.action'}.'
'. - &Apache::loncommon::end_page()); + $r->print('' + .&mt('Unknown Action').' '.$env{'form.action'} + .'
' + .&Apache::loncommon::end_page() + ); return OK; } if ($env{'form.phase'} eq 'two') {