";
+ $tpl->read_file($config->{'tpl_viewfile'});
- $output .= htmlfoot;
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin("CONTENT",encode_entities($$content));
}
}
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
return \$output;
}
@@ -275,9 +220,9 @@ sub exec_beginedit($$)
my $virtual = $data->{'virtual'};
my $uselist = $data->{'uselist'};
- return error("You cannot edit directories.",upper_path($virtual)) if(-d $physical);
+ return error($config->{'err_editdir'},upper_path($virtual)) if(-d $physical);
return error_in_use($virtual) if($uselist->in_use($virtual));
- return error("You have not enough permissions to edit this file.",upper_path($virtual)) unless(-r $physical && -w $physical);
+ return error($config->{'err_noedit'},upper_path($virtual)) unless(-r $physical && -w $physical);
# Check on binary files
@@ -285,7 +230,7 @@ sub exec_beginedit($$)
{
# Binary file
- return error("This editor is not able to view/edit binary files.",upper_path($virtual));
+ return error($config->{'err_binary'},upper_path($virtual));
}
else
{
@@ -294,49 +239,41 @@ sub exec_beginedit($$)
$uselist->add_file($virtual);
$uselist->save;
- my $dir = upper_path($virtual);
- my $content = encode_entities(${file_read($physical)});
-
- my $equal_url = equal_url($config->{'httproot'},$virtual);
+ my $content = file_read($physical);
- $virtual = encode_entities($virtual);
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_editfile'});
- my $output = htmlhead("Edit file $virtual");
- $output .= $equal_url;
- $output .= <Caution! This file is locked for other users while you are editing it. To unlock it, click Save and exit or Exit WITHOUT saving. Please don't click the Reload button in your browser! This will confuse the editor.
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+ $tpl->fillin("CONTENT",encode_entities($$content));
-
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
-
-END
+# exec_canceledit()
+#
+# Abort file editing
+#
+# Params: 1. Reference to user input hash
+# 2. Reference to config hash
+#
+# Return: Output of the command (Scalar Reference)
- $output .= htmlfoot;
+sub exec_canceledit($$)
+{
+ my ($data,$config) = @_;
+ my $virtual = $data->{'virtual'};
+ my $uselist = $data->{'uselist'};
- return \$output;
- }
+ file_unlock($uselist,$virtual);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
}
# exec_endedit()
@@ -355,8 +292,8 @@ sub exec_endedit($$)
my $virtual = $data->{'virtual'};
my $content = $data->{'cgi'}->param('filecontent');
- return error("You cannot edit directories.") if(-d $physical);
- return error("You have not enough permissions to edit this file.",upper_path($virtual)) unless(-r $physical && -w $physical);
+ return error($config->{'err_editdir'},upper_path($virtual)) if(-d $physical);
+ return error($config->{'err_noedit'}, upper_path($virtual)) unless(-r $physical && -w $physical);
# Normalize newlines
@@ -381,11 +318,12 @@ sub exec_endedit($$)
{
# Saving of the file was successful - so unlock it!
- return exec_unlock($data,$config);
+ file_unlock($data->{'uselist'},$virtual);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
}
else
{
- return error("Saving of file '".encode_entities($virtual)."' failed'.",upper_path($virtual));
+ return error($config->{'err_editfailed'},upper_path($virtual),{FILE => $virtual});
}
}
@@ -435,188 +373,81 @@ sub exec_mkdir($$)
return devedit_reload({command => 'show', file => $dir});
}
-# exec_workwithfile()
+# exec_copy()
#
-# Display a form for renaming/copying/deleting/unlocking a file
+# Copy a file and return to directory view
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
#
# Return: Output of the command (Scalar Reference)
-sub exec_workwithfile($$)
+sub exec_copy($$)
{
my ($data,$config) = @_;
my $physical = $data->{'physical'};
- my $virtual = $data->{'virtual'};
- my $unused = $data->{'uselist'}->unused($virtual);
-
- my $dir = encode_entities(upper_path($virtual));
-
- my $output = htmlhead("Work with file ".encode_entities($virtual));
- $output .= equal_url($config->{'httproot'},$virtual);
-
- $virtual = encode_entities($virtual);
-
- $output .= dir_link($virtual);
- $output .= "
Note: On UNIX systems, filenames are case-sensitive!
\n\n";
-
- $output .= "
Someone else is currently editing this file. So not all features are available.
\n\n" unless($unused);
-
- $output .= "\n\n";
-
- # Copying of the file is always allowed - but we need read access
-
- if(-r $physical)
- {
- $output .= <Copy
-
-
-
-
+ my $virtual = encode_entities($data->{'virtual'});
+ my $new_physical = $data->{'new_physical'};
-END
- }
+ return error($config->{'err_dircopy'}) if(-d $physical);
+ return error($config->{'err_nocopy'}) unless(-r $physical);
- if($unused)
+ if($new_physical)
{
- # File is not locked
- # Allow renaming and deleting the file
-
- $output .= <Move/rename
-
-
-
-
+ my $new_virtual = $data->{'new_virtual'};
+ my $dir = upper_path($new_virtual);
+ $new_virtual = encode_entities($new_virtual);
-
Delete
+ if(-e $new_physical)
+ {
+ if(-d $new_physical)
+ {
+ return error("A directory called '$new_virtual' already exists. You cannot replace a directory by a file!",$dir);
+ }
+ elsif(not $data->{'cgi'}->param('confirmed'))
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_replace'});
+
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("NEW_FILE",$new_virtual);
+ $tpl->fillin("NEW_FILENAME",file_name($new_virtual));
+ $tpl->fillin("NEW_DIR",$dir);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("COMMAND","copy");
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
-
Click on the button below to remove the file '$virtual'.
+ if($data->{'uselist'}->in_use($data->{'new_virtual'}))
+ {
+ return error("The target file '$new_virtual' already exists and it is edited by someone else.",$dir);
+ }
-
-END
+ copy($physical,$new_physical) or return error("Could not copy '$virtual' to '$new_virtual'",upper_path($virtual));
+ return devedit_reload({command => 'show', file => $dir});
}
else
{
- # File is locked
- # Just display a button for unlocking it
-
- $output .= <Unlock file
-
-
Someone else is currently editing this file. At least, the file is marked so. Maybe, someone who was editing the file has forgotten to unlock it. In this case (and only in this case) you can unlock the file using this button:
-
-
-END
- }
-
- $output .= "\n";
- $output .= htmlfoot;
-
- return \$output;
-}
-
-# exec_workwithdir()
-#
-# Display a form for renaming/deleting a directory
-#
-# Params: 1. Reference to user input hash
-# 2. Reference to config hash
-#
-# Return: Output of the command (Scalar Reference)
-
-sub exec_workwithdir($$)
-{
- my ($data,$config) = @_;
- my $physical = $data->{'physical'};
- my $virtual = $data->{'virtual'};
-
- my $dir = encode_entities(upper_path($virtual));
-
- my $output = htmlhead("Work with directory ".encode_entities($virtual));
- $output .= equal_url($config->{'httproot'},$virtual);
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_copyfile'});
- $virtual = encode_entities($virtual);
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- $output .= dir_link($virtual);
- $output .= "
Note: On UNIX systems, filenames are case-sensitive!