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;
-}
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_copyfile'});
-# exec_copy()
-#
-# 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_copy($$)
-{
- my ($data,$config) = @_;
- my $physical = $data->{'physical'};
- my $virtual = encode_entities($data->{'virtual'});
- my $new_physical = $data->{'new_physical'};
- my $new_virtual = $data->{'new_virtual'};
- my $dir = upper_path($new_virtual);
- $new_virtual = encode_entities($new_virtual);
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- return error("This editor is not able to copy directories.") if(-d $physical);
- return error("You have not enough permissions to copy this file.") unless(-r $physical);
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
- if(-e $new_physical)
- {
- return error("A file or directory called '$new_virtual' already exists and this editor is currently not able to ask to overwrite the existing file or directory.",upper_path($virtual));
+ return \$output;
}
-
- copy($physical,$new_physical) or return error("Could not copy '$virtual' to '$new_virtual'",upper_path($virtual));
-
- my $output = redirect("http://$ENV{'HTTP_HOST'}$script?command=show&file=$dir");
- return \$output;
}
# exec_rename()
@@ -529,26 +470,67 @@ sub exec_rename($$)
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
my $new_physical = $data->{'new_physical'};
- my $new_virtual = $data->{'new_virtual'};
- my $dir = upper_path($new_virtual);
- $new_virtual = encode_entities($new_virtual);
return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
- if(-e $new_physical)
+ if($new_physical)
{
- return error("A file or directory called '$new_virtual' already exists and this editor is currently not able to ask to overwrite the existing file or directory.",upper_path($virtual));
+ my $new_virtual = $data->{'new_virtual'};
+ my $dir = upper_path($new_virtual);
+ $new_virtual = encode_entities($new_virtual);
+
+ if(-e $new_physical)
+ {
+ return error($config->{'err_exist_edited'},$dir,{FILE => $new_virtual}) if($data->{'uselist'}->in_use($data->{'new_virtual'}));
+
+ if(-d $new_physical)
+ {
+ return error($config->{'err_dircopy'});
+ }
+ 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","rename");
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
+
+ rename($physical,$new_physical) or return error($config->{'err_rename_failed'},upper_path($virtual),{FILE => $virtual, NEW_FILE => $new_virtual});
+ return devedit_reload({command => 'show', file => $dir});
}
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_renamefile'});
- rename($physical,$new_physical) or return error("Could not move/rename '".encode_entities($virtual)."' to '$new_virtual'.",upper_path($virtual));
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
- my $output = redirect("http://$ENV{'HTTP_HOST'}$script?command=show&file=$dir");
- return \$output;
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
}
# exec_remove()
#
-# Remove a file and return to directory view
+# Remove a file or a directory and return to directory view
#
# Params: 1. Reference to user input hash
# 2. Reference to config hash
@@ -561,13 +543,58 @@ sub exec_remove($$)
my $physical = $data->{'physical'};
my $virtual = $data->{'virtual'};
- return error("Deleting directories is currently unsupported.") if(-d $physical);
- return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+ if(-d $physical)
+ {
+ # Remove a directory
- unlink($physical) or return error("Could not delete file '".encode_entities($virtual)."'.",upper_path($virtual));
+ if($data->{'cgi'}->param('confirmed'))
+ {
+ rmtree($physical);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_rmdir'});
- my $output = redirect("http://$ENV{'HTTP_HOST'}$script?command=show&file=".upper_path($virtual));
- return \$output;
+ $tpl->fillin("DIR",$virtual);
+ $tpl->fillin("UPPER_DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
+ else
+ {
+ # Remove a file
+
+ return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual));
+
+ if($data->{'cgi'}->param('confirmed'))
+ {
+ unlink($physical) or return error($config->{'err_delete_failed'},upper_path($virtual),{FILE => $virtual});
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_rmfile'});
+
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
+ }
}
# exec_unlock()
@@ -584,13 +611,27 @@ sub exec_unlock($$)
{
my ($data,$config) = @_;
my $virtual = $data->{'virtual'};
- my $uselist = $data->{'uselist'};
- $uselist->remove_file($virtual);
- $uselist->save;
+ if($data->{'cgi'}->param('confirmed'))
+ {
+ file_unlock($data->{'uselist'},$virtual);
+ return devedit_reload({command => 'show', file => upper_path($virtual)});
+ }
+ else
+ {
+ my $tpl = new Template;
+ $tpl->read_file($config->{'tpl_confirm_unlock'});
- my $output = redirect("http://$ENV{'HTTP_HOST'}$script?command=show&file=".upper_path($virtual));
- return \$output;
+ $tpl->fillin("FILE",$virtual);
+ $tpl->fillin("DIR",upper_path($virtual));
+ $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual));
+ $tpl->fillin("SCRIPT",$script);
+
+ my $output = header(-type => "text/html");
+ $output .= $tpl->get_template;
+
+ return \$output;
+ }
}
# it's true, baby ;-)