version 1.50, 2004/01/05 16:48:50
|
version 1.53, 2004/04/03 00:23:47
|
Line 406 new filename relative to the current dir
|
Line 406 new filename relative to the current dir
|
=cut |
=cut |
|
|
sub Rename1 { |
sub Rename1 { |
my ($request, $user, $domain, $fn, $newfilename) = @_; |
my ($request, $user, $domain, $fn, $newfilename, $style) = @_; |
|
|
if(-e $fn) { |
if(-e $fn) { |
if($newfilename) { |
if($newfilename) { |
# is dest a dir |
# is dest a dir |
if (-d $newfilename) { |
if ($style eq 'move') { |
if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; } |
if (-d $newfilename) { |
|
if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; } |
|
} |
} |
} |
if ($newfilename =~ m|/[^\.]+$|) { |
if ($newfilename =~ m|/[^\.]+$|) { |
#no extension add on original extension |
#no extension add on original extension |
Line 424 sub Rename1 {
|
Line 426 sub Rename1 {
|
#renaming a dir, delete the trailing / |
#renaming a dir, delete the trailing / |
#remove second to last element for current dir |
#remove second to last element for current dir |
if (-d $fn) { |
if (-d $fn) { |
|
$newfilename=~/\.(\w+)$/; |
|
if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { |
|
$request->print('<br /><font color="red">'. |
|
&mt('Cannot change MIME type of a directory'). |
|
'</font>'. |
|
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
|
return; |
|
} |
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/; |
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/; |
} |
} |
$newfilename=~s://+:/:g; # remove duplicate / |
$newfilename=~s://+:/:g; # remove duplicate / |
Line 441 sub Rename1 {
|
Line 451 sub Rename1 {
|
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
'<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>'); |
return; |
return; |
} |
} |
|
my $action; |
|
if ($style eq 'rename') { |
|
$action=&mt('Rename'); |
|
} else { |
|
$action=&mt('Move'); |
|
} |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$newfilename. |
$newfilename. |
'" /><p>'.&mt('Rename').' '.&display($fn). |
'" /><p>'.$action.' '.&display($fn). |
'</tt><br />to '.&display($newfilename).'?</p>'); |
'</tt><br />to '.&display($newfilename).'?</p>'); |
&CloseForm1($request, $fn); |
&CloseForm1($request, $fn); |
} else { |
} else { |
Line 599 causes the newdir operation to transitio
|
Line 615 causes the newdir operation to transitio
|
|
|
sub NewDir1 |
sub NewDir1 |
{ |
{ |
my ($request, $username, $domain, $fn, $newfilename) = @_; |
my ($request, $username, $domain, $fn, $newfilename, $mode) = @_; |
|
|
my $result=&exists($username,$domain,$newfilename); |
my $result=&exists($username,$domain,$newfilename); |
if ($result) { |
if ($result) { |
$request->print('<font color="red">'.$result.'</font></form>'); |
$request->print('<font color="red">'.$result.'</font></form>'); |
} else { |
} else { |
|
if ($mode eq 'testbank') { |
|
$request->print('<input type="hidden" name="callingmode" value="testbank">'); |
|
} elsif ($mode eq 'imsimport') { |
|
$request->print('<input type="hidden" name="callingmode" value="imsimport">'); |
|
} |
$request->print('<input type="hidden" name="newfilename" value="'. |
$request->print('<input type="hidden" name="newfilename" value="'. |
$newfilename.'" /><p>'.&mt('Make new directory').' '. |
$newfilename.'" /><p>'.&mt('Make new directory').' '. |
&display($newfilename).'?</p>'); |
&display($newfilename).'?</p>'); |
Line 737 sub phaseone {
|
Line 758 sub phaseone {
|
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
|
|
if ($ENV{'form.action'} eq 'rename') { |
if ($ENV{'form.action'} eq 'rename') { |
&Rename1($r, $uname, $udom, $fn, $newfilename); |
&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') { |
} elsif ($ENV{'form.action'} eq 'delete') { |
&Delete1($r, $uname, $udom, $fn); |
&Delete1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'decompress') { |
} elsif ($ENV{'form.action'} eq 'decompress') { |
Line 749 sub phaseone {
|
Line 772 sub phaseone {
|
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
} |
} |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
&NewDir1($r, $uname, $udom, $fn, $newfilename); |
my $mode = ''; |
|
if (exists($ENV{'form.callingmode'}) ) { |
|
$mode = $ENV{'form.callingmode'}; |
|
} |
|
&NewDir1($r, $uname, $udom, $fn, $newfilename, $mode); |
} elsif ($ENV{'form.action'} eq 'newfile' || |
} elsif ($ENV{'form.action'} eq 'newfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
$ENV{'form.action'} eq 'newproblemfile' || |
Line 1121 sub phasetwo {
|
Line 1148 sub phasetwo {
|
} |
} |
$dest = $newdir."/" |
$dest = $newdir."/" |
} |
} |
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>'); |
if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) { |
|
$r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>'); |
|
} else { |
|
$r->print('<h3><a href="'.&url($dest).'">'.&mt('Done').'</a></h3>'); |
|
} |
} |
} |
|
|
sub handler { |
sub handler { |
Line 1189 sub handler {
|
Line 1220 sub handler {
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
$r->print('<html><head><title>LON-CAPA Construction Space</title></head>'); |
if ( ($ENV{'form.action'} eq 'newdir') && ($ENV{'form.phase'} eq 'two') && ( ($ENV{'form.callingmode'} eq 'testbank') || ($ENV{'form.callingmode'} eq 'imsimport') ) ) { |
|
my $newdirname = $ENV{'form.newfilename'}; |
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation')); |
$r->print('<html><head><title>LON-CAPA Construction Space</title><script language="Javascript">'); |
|
$r->print(qq| |
|
function writeDone() { |
|
var winName = window.opener |
|
window.focus(); |
|
winName.document.dataForm.newdir.value = "$newdirname" |
|
setTimeout("self.close()",10000) |
|
} |
|
</script> |
|
</head>|); |
|
my $loaditem = 'onLoad="writeDone()"'; |
|
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation','',$loaditem)); |
|
} else { |
|
$r->print('<html><head><title>LON-CAPA Construction Space</title></head>'); |
|
$r->print(&Apache::loncommon::bodytag('Construction Space File Operation')); |
|
} |
|
|
|
|
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>'); |
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>'); |
Line 1208 sub handler {
|
Line 1254 sub handler {
|
$r->print('<h3>'.&mt('Delete').'</h3>'); |
$r->print('<h3>'.&mt('Delete').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'rename') { |
} elsif ($ENV{'form.action'} eq 'rename') { |
$r->print('<h3>'.&mt('Rename').'</h3>'); |
$r->print('<h3>'.&mt('Rename').'</h3>'); |
|
} elsif ($ENV{'form.action'} eq 'move') { |
|
$r->print('<h3>'.&mt('Move').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
$r->print('<h3>'.&mt('New Directory').'</h3>'); |
$r->print('<h3>'.&mt('New Directory').'</h3>'); |
} elsif ($ENV{'form.action'} eq 'decompress') { |
} elsif ($ENV{'form.action'} eq 'decompress') { |