From 99160ca341366b244e9319bcbe33f6d0c26712e3 Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Tue, 20 Jul 2004 12:07:37 +0000 Subject: [PATCH 1/1] When viewing a file and if the file is editable, there is a new link to edit this file. --- modules/Command.pm | 11 ++++++++--- templates/viewfile.htm | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/Command.pm b/modules/Command.pm index 6db5d07..0ae3416 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-11 +# Last modified: 2004-07-20 # use strict; @@ -81,6 +81,7 @@ sub exec_show($$) my ($data,$config) = @_; my $physical = $data->{'physical'}; my $virtual = $data->{'virtual'}; + my $uselist = $data->{'uselist'}; my $tpl = new Template; @@ -138,7 +139,7 @@ sub exec_show($$) my $virt_path = encode_entities($virtual.$file); my @stat = stat($phys_path); - my $in_use = $data->{'uselist'}->in_use($virtual.$file); + my $in_use = $uselist->in_use($virtual.$file); my $ftpl = new Template; $ftpl->read_file($config->{'templates'}->{'dirlist_file'}); @@ -192,7 +193,9 @@ sub exec_show($$) { # Text file - if($config->{'max_file_size'} && (stat($physical))[7] > $config->{'max_file_size'}) + my $size = (stat($physical))[7]; + + if($config->{'max_file_size'} && $size > $config->{'max_file_size'}) { return error($config->{'errors'}->{'file_too_large'},upper_path($virtual),{SIZE => $config->{'max_file_size'}}) } @@ -208,6 +211,8 @@ sub exec_show($$) $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual)); $tpl->fillin("SCRIPT",$script); $tpl->fillin("CONTENT",encode_entities($$content)); + + $tpl->parse_if_block("editable",-r $physical && -w $physical && -T $physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual)); } } } diff --git a/templates/viewfile.htm b/templates/viewfile.htm index 56d6595..30db604 100644 --- a/templates/viewfile.htm +++ b/templates/viewfile.htm @@ -20,7 +20,7 @@ -
+{IF editable}

Edit this file

{ELSE}
{ENDIF}
-- 2.34.1