From a180f0b982f525ea2d17516f9aa43d3313399de1 Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Sun, 11 Jul 2004 14:04:51 +0000 Subject: [PATCH] In directory listing, when clicking on the buttons next to the fields for creating new files and directories without entering a file or directory name, the user got an error message which is a little bit strange. Now, the user will see a form for creating new files or directories. Well, this is not perfect, but at least, this error will be catched. --- modules/Command.pm | 46 ++++++++++++++++++++++++++++++++++++-------- templates/mkdir.htm | 28 +++++++++++++++++++++++++++ templates/mkfile.htm | 28 +++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 templates/mkdir.htm create mode 100644 templates/mkfile.htm diff --git a/modules/Command.pm b/modules/Command.pm index 64f4900..6db5d07 100644 --- a/modules/Command.pm +++ b/modules/Command.pm @@ -6,7 +6,7 @@ package Command; # Execute Dev-Editor's commands # # Author: Patrick Canterino -# Last modified: 2004-07-03 +# Last modified: 2004-07-11 # use strict; @@ -25,8 +25,6 @@ use HTML::Entities; use Output; use Template; -use Data::Dumper; - my $script = $ENV{'SCRIPT_NAME'}; my %dispatch = ('show' => \&exec_show, @@ -376,10 +374,26 @@ sub exec_mkfile($$) my $dir = upper_path($new_virtual); $new_virtual = encode_entities($new_virtual); - return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical); + if($new_physical) + { + return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical); + + file_create($new_physical) or return error($config->{'errors'}->{'mkfile_failed'},$dir,{FILE => $new_virtual}); + return devedit_reload({command => 'show', file => $dir}); + } + else + { + my $tpl = new Template; + $tpl->read_file($config->{'templates'}->{'mkfile'}); + + $tpl->fillin("DIR","/"); + $tpl->fillin("SCRIPT",$script); - file_create($new_physical) or return error($config->{'errors'}->{'mkfile_failed'},$dir,{FILE => $new_virtual}); - return devedit_reload({command => 'show', file => $dir}); + my $output = header(-type => "text/html"); + $output .= $tpl->get_template; + + return \$output; + } } # exec_mkdir() @@ -401,8 +415,24 @@ sub exec_mkdir($$) return error($config->{'errors'}->{'file_exists'},$dir,{FILE => $new_virtual}) if(-e $new_physical); - mkdir($new_physical,0777) or return error($config->{'errors'}->{'mkdir_failed'},$dir,{DIR => $new_virtual}); - return devedit_reload({command => 'show', file => $dir}); + if($new_physical) + { + mkdir($new_physical,0777) or return error($config->{'errors'}->{'mkdir_failed'},$dir,{DIR => $new_virtual}); + return devedit_reload({command => 'show', file => $dir}); + } + else + { + my $tpl = new Template; + $tpl->read_file($config->{'templates'}->{'mkdir'}); + + $tpl->fillin("DIR","/"); + $tpl->fillin("SCRIPT",$script); + + my $output = header(-type => "text/html"); + $output .= $tpl->get_template; + + return \$output; + } } # exec_upload() diff --git a/templates/mkdir.htm b/templates/mkdir.htm new file mode 100644 index 0000000..45d237c --- /dev/null +++ b/templates/mkdir.htm @@ -0,0 +1,28 @@ + + + + +Create new directory + + + + +

Create new directory

+ +

Back to {DIR}

+ +

Using this form, you can create a new directory in the current directory ('{DIR}').

+ +
+ + +

{DIR}

+
+ +
+ +

About Dev-Editor

+ \ No newline at end of file diff --git a/templates/mkfile.htm b/templates/mkfile.htm new file mode 100644 index 0000000..ef75c3f --- /dev/null +++ b/templates/mkfile.htm @@ -0,0 +1,28 @@ + + + + +Create new file + + + + +

Create new file

+ +

Back to {DIR}

+ +

Using this form, you can create a new file in the current directory ('{DIR}').

+ +
+ + +

{DIR}

+
+ +
+ +

About Dev-Editor

+ \ No newline at end of file -- 2.34.1