From 99ccfeab2e445e4ae4aaf4b11afdc38a5c776d6f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 14 Feb 2006 16:43:20 +0000 Subject: [PATCH] Erste Version eines Template-Systems fuer die HTML-Seiten. Nur die Backend-Funktion ist implementiert. Verwendet wird HTML::Template. Die Templates muessen im Verzeichnis templates/webpages liegen. Neue Masken koennen nun mit dem Template-System erstellt werden. Bestehende Masken sind davon nicht beruehrt. --- SL/Form.pm | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/SL/Form.pm b/SL/Form.pm index acc6c6b58..124e972ab 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -37,6 +37,8 @@ package Form; +use HTML::Template; + sub _input_to_hash { $main::lxdebug->enter_sub(); @@ -419,6 +421,46 @@ function fokus(){document.$self->{fokus}.focus();} $main::lxdebug->leave_sub(); } +sub parse_html_template { + $main::lxdebug->enter_sub(); + + my ($self, $file) = @_; + + my $template = HTML::Template->new("filename" => "templates/webpages/$file", + "die_on_bad_params" => 0, + "strict" => 0, + "case_sensitive" => 1, + "loop_context_vars" => 1, + "global_vars" => 1); + my @params = $template->param(); + + if (grep("DEBUG", @params) && $self->{"DEBUG"}) { + $template->param("DEBUG" => "
DEBUG INFORMATION:
" .
+                     $self->{"DEBUG"} . "
"); + } + + foreach my $key (keys(%{$self})) { + if (("DEBUG" ne $key) && grep(${key}, @params)) { + $template->param($key => $self->{$key}); + } + } + + my $output = $template->output(); + + $main::lxdebug->leave_sub(); + + return $output; +} + +sub show_generic_error { + my ($self, $error, $title) = @_; + + $self->{"title"} = $title if ($title); + $self->{"label_error"} = $error; + + print($self->parse_html_template("generic/error.html")); +} + # write Trigger JavaScript-Code ($qty = quantity of Triggers) # changed it to accept an arbitrary number of triggers - sschoeling sub write_trigger { -- 2.20.1