[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 26 Apr 2007 21:17:17 -0000
This is a MIME encoded message
--albertel1177622237
Content-Type: text/plain
albertel Thu Apr 26 17:17:17 2007 EDT
Modified files:
/loncom/publisher loncfile.pm
Log:
- switch <font color="red". to css
- bug#5245 allow creation of files with the same name as previously deleted obsolte files, but warn about it
--albertel1177622237
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070426171717.txt"
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.82 loncom/publisher/loncfile.pm:1.83
--- loncom/publisher/loncfile.pm:1.82 Fri Apr 20 16:55:01 2007
+++ loncom/publisher/loncfile.pm Thu Apr 26 17:17:16 2007
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.82 2007/04/20 20:55:01 albertel Exp $
+# $Id: loncfile.pm,v 1.83 2007/04/26 21:17:16 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -239,6 +239,9 @@
=over 4
+=item string - Either undef, 'warning' or 'error' depending on the
+ type of problem
+
=item string - Either where the resource exists as an html string that can
be embedded in a dialog or an empty string if the resource
does not exist.
@@ -251,17 +254,27 @@
my ($user, $domain, $construct) = @_;
my $published=$construct;
$published=~
- s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//;
- my $result='';
+ s{^/home/$user/public_html/}{/home/httpd/html/res/$domain/$user/};
+ my ($type,$result);
if ( -d $construct ) {
- return &mt('Error: destination for operation is an existing directory.');
+ return ('error','<p><span class="LC_error">'.&mt('Error: destination for operation is an existing directory.').'</span></p>');
+
}
+
if ( -e $published) {
- $result.='<p><font color="red">'.&mt('Warning: target file exists, and has been published!').'</font></p>';
+ if ( -e $construct ) {
+ $type = 'warning';
+ $result.='<p><span class="LC_warning">'.&mt('Warning: target file exists, and has been published!').'</span></p>';
+ } else {
+ $type = 'warning';
+ $result.='<p><span class="LC_warning">'.&mt('Warning: a published file of this names exists.').'</span></p>';
+ }
} elsif ( -e $construct) {
- $result.='<p><font color="red">'.&mt('Warning: target file exists!').'</font></p>';
+ $type = 'warning';
+ $result.='<p><span class="LC_warning">'.&mt('Warning: target file exists!').'</span></p>';
}
- return $result;
+
+ return ($type,$result);
}
=pod
@@ -323,12 +336,12 @@
my ($newpath)=($dest=~m|(.*)/|);
$newpath=&relativeDest($fn,$newpath,$uname);
if (! -d "$newpath") {
- $request->print("<p><font color=\"red\">".&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.','"<tt>'.$newpath.'</tt>"')."</font></p>");
+ $request->print("<p><span class=\"LC_error\">".&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.','"<tt>'.$newpath.'</tt>"')."</span></p>");
$dest=~s|.*/||;
}
}
if ($foundbad) {
- $request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");
+ $request->print("<p><span class=\"LC_error\">".&mt('Invalid characters in requested name have been removed.')."</span></p>");
}
return $dest;
}
@@ -475,9 +488,9 @@
while ($newfilename=~m:/\.\./:) {
$newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
}
- my $return=&exists($user, $domain, $newfilename);
+ my ($type, $return)=&exists($user, $domain, $newfilename);
$request->print($return);
- if ($return =~/^Error:/) {
+ if ($type eq 'error') {
$request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
return;
}
@@ -603,9 +616,9 @@
$newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
}
$request->print(&checksuffix($fn,$newfilename));
- my $return=&exists($user, $domain, $newfilename);
+ my ($type,$return)=&exists($user, $domain, $newfilename);
$request->print($return);
- if ($return =~/^Error:/) {
+ if ($type eq 'error') {
$request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
return;
}
@@ -661,9 +674,10 @@
sub NewDir1 {
my ($request, $username, $domain, $fn, $newfilename, $mode) = @_;
- my $result=&exists($username,$domain,$newfilename);
+ my ($type, $result)=&exists($username,$domain,$newfilename);
+ $request->print($result);
if ($result) {
- $request->print('<font color="red">'.$result.'</font></form>');
+ $request->print('</form>');
} else {
if ($mode eq 'testbank') {
$request->print('<input type="hidden" name="callingmode" value="testbank">');
@@ -737,15 +751,15 @@
##Informs User (name).(number).(extension) not allowed
if($newfilename =~ /\.(\d+)\.(\w+)$/){
- $r->print('<font color="red">'.$newfilename.
+ $r->print('<span class="LC_error">'.$newfilename.
' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').') '.
- ' '.&mt('Not Allowed').'</font>');
+ ' '.&mt('Not Allowed').'</span>');
return;
}
if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
- $r->print('<font color="red">'.$newfilename.
+ $r->print('<span class="LC_error">'.$newfilename.
' - '.&mt('Bad Filename').'<br />('.&mt('Must not include').' '.$1.') '.
- ' '.&mt('Not Allowed').'</font>');
+ ' '.&mt('Not Allowed').'</span>');
return;
}
if ($newfilename !~ /\Q.$extension\E$/) {
@@ -756,10 +770,12 @@
$newfilename.=".$extension";
}
}
- my $result=&exists($user,$domain,$newfilename);
- if($result) {
- $request->print('<span class="LC_error">'.$result.'</span></form>');
+ my ($type, $result)=&exists($user,$domain,$newfilename);
+ $request->print($result);
+ if ($type eq 'error') {
+ $request->print('</form>');
} else {
+
$request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>');
$request->print('</form>');
$request->print('<form action="'.&url($newfilename).
@@ -894,7 +910,7 @@
my $oRN=$oldfile;
my $nRN=$newfile;
unless (rename($oldfile,$newfile)) {
- $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
}
## If old name.(extension) exits, move under new name.
@@ -968,12 +984,12 @@
my ($request, $user, $filename) = @_;
if (-d $filename) {
unless (&empty_directory($filename,'Delete2')) {
- $request->print('<font color="red"> '.&mt('Error: Directory Non Empty').'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error: Directory Non Empty').'</span>');
return 0;
} else {
if(-e $filename) {
unless(rmdir($filename)) {
- $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
}
} else {
@@ -984,7 +1000,7 @@
} else {
if(-e $filename) {
unless(unlink($filename)) {
- $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
}
} else {
@@ -1028,20 +1044,20 @@
&Debug($request ,"Will try to copy $oldfile to $newfile");
if(-e $oldfile) {
if ($oldfile eq $newfile) {
- $request->print('<font color="red"> '.&mt('Warning').': '.&mt('Name of new file is the same as name of old file').' - '.&mt('no action taken').'.</font>');
+ $request->print('<span class="LC_error">'.&mt('Warning').': '.&mt('Name of new file is the same as name of old file').' - '.&mt('no action taken').'.</span>');
return 1;
}
unless (copy($oldfile, $newfile)) {
- $request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('copy Error').': '.$!.'</span>');
return 0;
} elsif (!chmod(0660, $newfile)) {
- $request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('chmod error').': '.$!.'</span>');
return 0;
} elsif (-e $oldfile.'.meta' &&
!copy($oldfile.'.meta', $newfile.'.meta') &&
!chmod(0660, $newfile.'.meta')) {
- $request->print('<font color="red"> '.&mt('copy metadata error').
- ': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('copy metadata error').
+ ': '.$!.'</span>');
return 0;
} else {
return 1;
@@ -1079,11 +1095,11 @@
my ($request, $user, $newdirectory) = @_;
unless(mkdir($newdirectory, 02770)) {
- $request->print('<font color="red">'.&mt('Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
}
unless(chmod(02770, ($newdirectory))) {
- $request->print('<font color="red"> '.&mt('Error').': '.$!.'</font>');
+ $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
return 0;
}
return 1;
@@ -1310,8 +1326,8 @@
$r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- $r->print('<h3><font color="red">'.&mt('Co-Author').': '.$uname.' at '.$udom.
- '</font></h3>');
+ $r->print('<h3><span class="LC_error">'.&mt('Co-Author').': '.$uname.' at '.$udom.
+ '</span></h3>');
}
--albertel1177622237--