From 59507c0a5e5507868ebf6db407219da3f17c8ed9 Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Sun, 10 May 2009 21:00:11 +0000 Subject: [PATCH] Make use of new methods defined by template class. Replacing "fillin()" by "set_var()" is not always possible... Sometimes, we need to keep "fillin()" or we will have some variable substitution problems... --- modules/Command.pm | 98 +++++++++++++++++++++++++++------------------- modules/Output.pm | 6 ++- 2 files changed, 61 insertions(+), 43 deletions(-) diff --git a/modules/Command.pm b/modules/Command.pm index 8acd1d7..34a2541 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: 2009-05-09 +# Last modified: 2009-05-10 # # Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann # Copyright (C) 2003-2009 Patrick Canterino @@ -473,8 +473,10 @@ sub exec_mkfile($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'mkfile'}); - $tpl->fillin('DIR','/'); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('DIR','/'); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -512,8 +514,10 @@ sub exec_mkdir($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'mkdir'}); - $tpl->fillin('DIR','/'); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('DIR','/'); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -583,10 +587,12 @@ sub exec_upload($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'upload'}); - $tpl->fillin('DIR',encode_html($virtual)); - $tpl->fillin('DIR_URL',escape($virtual)); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('DIR',encode_html($virtual)); + $tpl->set_var('DIR_URL',escape($virtual)); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -642,16 +648,18 @@ sub exec_copy($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'confirm_replace'}); - $tpl->fillin('FILE',encode_html($virtual)); - $tpl->fillin('NEW_FILE',$new_virtual->{'html'}); - $tpl->fillin('NEW_FILENAME',file_name($new_virtual->{'html'})); - $tpl->fillin('NEW_DIR',encode_html($new_dir)); - $tpl->fillin('DIR',encode_html($dir)); - $tpl->fillin('DIR_URL',escape($dir)); + $tpl->set_var('FILE',encode_html($virtual)); + $tpl->set_var('NEW_FILE',$new_virtual->{'html'}); + $tpl->set_var('NEW_FILENAME',file_name($new_virtual->{'html'})); + $tpl->set_var('NEW_DIR',encode_html($new_dir)); + $tpl->set_var('DIR',encode_html($dir)); + $tpl->set_var('DIR_URL',escape($dir)); + + $tpl->set_var('COMMAND','copy'); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); - $tpl->fillin('COMMAND','copy'); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -671,11 +679,13 @@ sub exec_copy($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'copydir'}); - $tpl->fillin('FILE',encode_html($virtual)); - $tpl->fillin('DIR',encode_html($dir)); - $tpl->fillin('DIR_URL',escape($dir)); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('FILE',encode_html($virtual)); + $tpl->set_var('DIR',encode_html($dir)); + $tpl->set_var('DIR_URL',escape($dir)); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -687,11 +697,13 @@ sub exec_copy($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'copyfile'}); - $tpl->fillin('FILE',encode_html($virtual)); - $tpl->fillin('DIR',encode_html($dir)); - $tpl->fillin('DIR_URL',escape($dir)); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('FILE',encode_html($virtual)); + $tpl->set_var('DIR',encode_html($dir)); + $tpl->set_var('DIR_URL',escape($dir)); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -736,15 +748,17 @@ sub exec_rename($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'confirm_replace'}); - $tpl->fillin('FILE',encode_html($virtual)); - $tpl->fillin('NEW_FILE',$new_virtual->{'html'}); - $tpl->fillin('NEW_FILENAME',file_name($new_virtual->{'html'})); - $tpl->fillin('NEW_DIR',encode_html($new_dir)); - $tpl->fillin('DIR',encode_html($dir)); + $tpl->set_var('FILE',encode_html($virtual)); + $tpl->set_var('NEW_FILE',$new_virtual->{'html'}); + $tpl->set_var('NEW_FILENAME',file_name($new_virtual->{'html'})); + $tpl->set_var('NEW_DIR',encode_html($new_dir)); + $tpl->set_var('DIR',encode_html($dir)); - $tpl->fillin('COMMAND','rename'); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('COMMAND','rename'); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; @@ -761,11 +775,13 @@ sub exec_rename($$) my $tpl = new Template; $tpl->read_file($config->{'templates'}->{'renamefile'}); - $tpl->fillin('FILE',encode_html($virtual)); - $tpl->fillin('DIR',encode_html($dir)); - $tpl->fillin('DIR_URL',escape($dir)); - $tpl->fillin('URL',encode_html(equal_url($config->{'httproot'},$virtual))); - $tpl->fillin('SCRIPT',$script); + $tpl->set_var('FILE',encode_html($virtual)); + $tpl->set_var('DIR',encode_html($dir)); + $tpl->set_var('DIR_URL',escape($dir)); + $tpl->set_var('URL',encode_html(equal_url($config->{'httproot'},$virtual))); + $tpl->set_var('SCRIPT',$script); + + $tpl->parse; my $output = header(-type => 'text/html'); $output .= $tpl->get_template; diff --git a/modules/Output.pm b/modules/Output.pm index 9df2450..c9b6525 100644 --- a/modules/Output.pm +++ b/modules/Output.pm @@ -1,3 +1,4 @@ + package Output; # @@ -6,7 +7,7 @@ package Output; # HTML generating routines # # Author: Patrick Canterino -# Last modified: 2005-05-09 +# Last modified: 2005-05-10 # # Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann # Copyright (C) 2003-2009 Patrick Canterino @@ -67,7 +68,8 @@ sub error($;$$) my $tpl = new Template; $tpl->read_file($tpl_error); - $tpl->set_var('ERROR',$message); + $tpl->fillin('ERROR',$message); + $tpl->set_var('BACK',encode_html($path)); $tpl->set_var('BACK_URL',escape($path)); $tpl->set_var('SCRIPT',encode_html($ENV{'SCRIPT_NAME'})); -- 2.34.1