X-Git-Url: https://git.p6c8.net/devedit.git/blobdiff_plain/7416fb4edc504143cf5888717f30ed78d57511a7..e7d91227055ce4f15477dc60c4d54a844928878d:/modules/Command.pm?ds=sidebyside diff --git a/modules/Command.pm b/modules/Command.pm index 4e64a36..0a368e9 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: 2003-10-27 +# Last modified: 2003-11-10 # use strict; @@ -60,7 +60,7 @@ sub exec_show($$$) # Create directory listing my $direntries = dir_read($physical); - return error("Reading of directory $virtual failed") unless($direntries); + return error("Reading of directory $virtual failed.",upper_path($virtual)) unless($direntries); my $files = $direntries->{'files'}; my $dirs = $direntries->{'dirs'}; @@ -120,19 +120,47 @@ sub exec_show($$$) $output .= $stat[7]; $output .= " "; $output .= strftime($config->{'timeformat'},localtime($stat[9])); - $output .= ($in_use) ? " (IN USE) " : (not -T $phys_path) ? " (BINARY) " : " " x 10; + $output .= " " x 10; $output .= encode_entities($file); $output .= " " x ($max_name_len - length($file))."\t ("; - $output .= (-r $phys_path && -T $phys_path) - ? "View" - : 'View'; + # Link "View" + + if(-r $phys_path && -T $phys_path) + { + $output .= "View"; + } + else + { + $output .= 'Edit" - : 'Edit'; + # Link "Edit" + + if(-w $phys_path && -r $phys_path && -T $phys_path && not $in_use) + { + $output .= "Edit"; + } + else + { + $output .= 'Do other stuff)\n"; } @@ -170,7 +198,7 @@ END { # View a file - return error("You have not enough permissions to view this file.") unless(-r $physical); + return error("You have not enough permissions to view this file.",upper_path($virtual)) unless(-r $physical); # Check on binary files # We have to do it in this way, or empty files @@ -180,7 +208,7 @@ END { # Binary file - return error("This editor is not able to view/edit binary files."); + return error("This editor is not able to view/edit binary files.",upper_path($virtual)); } else { @@ -218,9 +246,9 @@ sub exec_beginedit($$) my $virtual = $data->{'virtual'}; my $uselist = $data->{'uselist'}; - return error("You cannot edit directories.") if(-d $physical); + return error("You cannot edit directories.",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.") unless(-r $physical && -w $physical); + return error("You have not enough permissions to edit this file.",upper_path($virtual)) unless(-r $physical && -w $physical); # Check on binary files @@ -228,7 +256,7 @@ sub exec_beginedit($$) { # Binary file - return error("This editor is not able to view/edit binary files."); + return error("This editor is not able to view/edit binary files.",upper_path($virtual)); } else { @@ -299,7 +327,7 @@ sub exec_endedit($$) 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.") unless(-r $physical && -w $physical); + return error("You have not enough permissions to edit this file.",upper_path($virtual)) unless(-r $physical && -w $physical); # Normalize newlines @@ -551,7 +579,7 @@ sub exec_remove($$) my $physical = $data->{'physical'}; my $virtual = $data->{'virtual'}; - return error("Deleting directories is currently unsupported.") if(-d $physical); + return error("Deleting directories is currently unsupported.",upper_path($virtual)) if(-d $physical); return error_in_use($virtual) if($data->{'uselist'}->in_use($virtual)); unlink($physical) or return error("Could not delete file '".encode_entities($virtual)."'.",upper_path($virtual));