Revision 99ccfeab
Von Moritz Bunkus vor fast 19 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
37 | 37 |
|
38 | 38 |
package Form; |
39 | 39 |
|
40 |
use HTML::Template; |
|
41 |
|
|
40 | 42 |
sub _input_to_hash { |
41 | 43 |
$main::lxdebug->enter_sub(); |
42 | 44 |
|
... | ... | |
419 | 421 |
$main::lxdebug->leave_sub(); |
420 | 422 |
} |
421 | 423 |
|
424 |
sub parse_html_template { |
|
425 |
$main::lxdebug->enter_sub(); |
|
426 |
|
|
427 |
my ($self, $file) = @_; |
|
428 |
|
|
429 |
my $template = HTML::Template->new("filename" => "templates/webpages/$file", |
|
430 |
"die_on_bad_params" => 0, |
|
431 |
"strict" => 0, |
|
432 |
"case_sensitive" => 1, |
|
433 |
"loop_context_vars" => 1, |
|
434 |
"global_vars" => 1); |
|
435 |
my @params = $template->param(); |
|
436 |
|
|
437 |
if (grep("DEBUG", @params) && $self->{"DEBUG"}) { |
|
438 |
$template->param("DEBUG" => "<br><em>DEBUG INFORMATION:</em><pre>" . |
|
439 |
$self->{"DEBUG"} . "</pre>"); |
|
440 |
} |
|
441 |
|
|
442 |
foreach my $key (keys(%{$self})) { |
|
443 |
if (("DEBUG" ne $key) && grep(${key}, @params)) { |
|
444 |
$template->param($key => $self->{$key}); |
|
445 |
} |
|
446 |
} |
|
447 |
|
|
448 |
my $output = $template->output(); |
|
449 |
|
|
450 |
$main::lxdebug->leave_sub(); |
|
451 |
|
|
452 |
return $output; |
|
453 |
} |
|
454 |
|
|
455 |
sub show_generic_error { |
|
456 |
my ($self, $error, $title) = @_; |
|
457 |
|
|
458 |
$self->{"title"} = $title if ($title); |
|
459 |
$self->{"label_error"} = $error; |
|
460 |
|
|
461 |
print($self->parse_html_template("generic/error.html")); |
|
462 |
} |
|
463 |
|
|
422 | 464 |
# write Trigger JavaScript-Code ($qty = quantity of Triggers) |
423 | 465 |
# changed it to accept an arbitrary number of triggers - sschoeling |
424 | 466 |
sub write_trigger { |
Auch abrufbar als: Unified diff
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.