--- loncom/publisher/loncfile.pm 2009/03/26 16:50:12 1.94
+++ loncom/publisher/loncfile.pm 2009/05/26 16:29:56 1.99
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.94 2009/03/26 16:50:12 bisitz Exp $
+# $Id: loncfile.pm,v 1.99 2009/05/26 16:29:56 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -423,7 +423,7 @@ sub CloseForm1 {
my ($request, $fn) = @_;
$request->print('
');
$request->print('');
+ '" method="post">
');
}
@@ -588,7 +588,7 @@ 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.').' '.
@@ -718,9 +718,9 @@ sub NewDir1 {
$request->print('');
} else {
if ($mode eq 'testbank') {
- $request->print(' ');
+ $request->print(' ');
} elsif ($mode eq 'imsimport') {
- $request->print(' ');
+ $request->print(' ');
}
$request->print(''.&mt('Make new directory').' '.
@@ -733,7 +733,7 @@ sub NewDir1 {
sub Decompress1 {
my ($request, $user, $domain, $fn) = @_;
if( -e $fn) {
- $request->print(' ');
+ $request->print(' ');
$request->print('
'.&mt('Decompress').' '.&display($fn).'?
');
&CloseForm1($request, $fn);
} else {
@@ -783,23 +783,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('name').').('.&mt('number').').('.&mt('extension').') '.
- ' '.&mt('Not Allowed').' ');
- return;
- }
- if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
- $r->print(''.$newfilename.
- ' - '.&mt('Bad Filename').' ('.&mt('Must not include').' '.$1.') '.
- ' '.&mt('Not Allowed').' ');
- return;
- }
if ($newfilename !~ /\Q.$extension\E$/) {
if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) {
#already has an extension strip it and add in expected one
@@ -813,14 +800,57 @@ sub NewFile1 {
if ($type eq 'error') {
$request->print('');
} else {
-
+ my $extension;
+
+ if ($newfilename =~ m{[^/.]+\.([^/.]+)$}) {
+ $extension = $1;
+ }
+
+ my @okexts = qw(xml html xhtml htm xhtm problem page sequence rights sty library js css txt);
+ if (($extension eq '') || (!grep(/^\Q$extension\E/,@okexts))) {
+ my $validexts = '.'.join(', .',@okexts);
+ $request->print(''.
+ &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('name').').('.&mt('number').').('.&mt('extension').') '.
+ ' '.&mt('Not Allowed').' ');
+ return;
+ }
+ if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
+ $r->print(''.$newfilename.
+ ' - '.&mt('Bad Filename').' ('.&mt('Must not include').' '.$1.') '.
+ ' '.&mt('Not Allowed').' ');
+ return;
+ }
+ return 'ok';
}
=pod
@@ -1357,15 +1387,31 @@ function writeDone() {
$loaditem{'onload'} = "writeDone()";
}
+ # Breadcrumbs
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'Construction Space',
+ 'href' => '', # FIXME Add link to /priv/[user]
+ });
+ &Apache::lonhtmlcommon::add_breadcrumb({
+ 'text' => 'File Operation',
+ 'title' => 'Construction Space File Operation',
+ 'href' => '',
+ });
+
$r->print(&Apache::loncommon::start_page('Construction Space File Operation',
$js,
- {'add_entries' => \%loaditem,}));
+ {'add_entries' => \%loaditem,})
+ .&Apache::lonhtmlcommon::breadcrumbs()
+ .&Apache::loncommon::head_subbox(
+ &Apache::loncommon::CSTR_pageheader())
+ );
$r->print(''.&mt('Location').': '.&display($fn).' ');
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
$r->print(''
- .&mt('Co-Author [_1]:[_2]',$uname,$udom)
+ .&mt('Co-Author [_1]',$uname.':'.$udom)
.'
'
);
}