+sub parse_html_template {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $file, $additional_params) = @_;
+ my $language;
+
+ if (!defined($main::myconfig) || !defined($main::myconfig{"countrycode"})) {
+ $language = $main::language;
+ } else {
+ $language = $main::myconfig{"countrycode"};
+ }
+
+ if (-f "templates/webpages/${file}_${language}.html") {
+ if ((-f ".developer") &&
+ (-f "templates/webpages/${file}_master.html") &&
+ ((stat("templates/webpages/${file}_master.html"))[9] >
+ (stat("templates/webpages/${file}_${language}.html"))[9])) {
+ my $info = "Developper information: templates/webpages/${file}_master.html is newer than the localized version.\n" .
+ "Please re-run 'locales.pl' in 'locale/${language}'.";
+ print(qq|<pre>$info</pre>|);
+ die($info);
+ }
+
+ $file = "templates/webpages/${file}_${language}.html";
+ } elsif (-f "templates/webpages/${file}.html") {
+ $file = "templates/webpages/${file}.html";
+ } else {
+ my $info = "Web page template '${file}' not found.\n" .
+ "Please re-run 'locales.pl' in 'locale/${language}'.";
+ print(qq|<pre>$info</pre>|);
+ die($info);
+ }
+
+ my $template = HTML::Template->new("filename" => $file,
+ "die_on_bad_params" => 0,
+ "strict" => 0,
+ "case_sensitive" => 1,
+ "loop_context_vars" => 1,
+ "global_vars" => 1);
+
+ $additional_params = {} unless ($additional_params);
+ if ($self->{"DEBUG"}) {
+ $additional_params->{"DEBUG"} = $self->{"DEBUG"};
+ }
+
+ if ($additional_params->{"DEBUG"}) {
+ $additional_params->{"DEBUG"} =
+ "<br><em>DEBUG INFORMATION:</em><pre>" . $additional_params->{"DEBUG"} . "</pre>";
+ }
+
+ if (%main::myconfig) {
+ map({ $additional_params->{"myconfig_${_}"} = $main::myconfig{$_}; } keys(%main::myconfig));
+ my $jsc_dateformat = $main::myconfig{"dateformat"};
+ $jsc_dateformat =~ s/d+/\%d/gi;
+ $jsc_dateformat =~ s/m+/\%m/gi;
+ $jsc_dateformat =~ s/y+/\%Y/gi;
+ $additional_params->{"myconfig_jsc_dateformat"} = $jsc_dateformat;
+ }
+
+ $additional_params->{"conf_jscalendar"} = $main::jscalendar;
+ $additional_params->{"conf_lizenzen"} = $main::lizenzen;
+ $additional_params->{"conf_latex_templates"} = $main::latex;
+ $additional_params->{"conf_opendocument_templates"} = $main::opendocument_templates;
+
+ my @additional_param_names = keys(%{$additional_params});
+ foreach my $key ($template->param()) {
+ my $param = $self->{$key};
+ $param = $additional_params->{$key} if (grep(/^${key}$/, @additional_param_names));
+ $param = [] if (($template->query("name" => $key) eq "LOOP") && (ref($param) ne "ARRAY"));
+ $template->param($key => $param);
+ }
+
+ my $output = $template->output();
+
+ $main::lxdebug->leave_sub();
+
+ return $output;
+}
+
+sub show_generic_error {
+ my ($self, $error, $title, $action) = @_;
+
+ my $add_params = {};
+ $add_params->{"title"} = $title if ($title);
+ $self->{"label_error"} = $error;
+
+ my @vars;
+ if ($action) {
+ map({ delete($self->{$_}); } qw(action));
+ map({ push(@vars, { "name" => $_, "value" => $self->{$_} })
+ if (!ref($self->{$_})); }
+ keys(%{$self}));
+ $add_params->{"SHOW_BUTTON"} = 1;
+ $add_params->{"BUTTON_LABEL"} = $action;
+ }
+ $add_params->{"VARIABLES"} = \@vars;
+
+ $self->header();
+ print($self->parse_html_template("generic/error", $add_params));
+
+ die("Error: $error\n");
+}
+
+sub show_generic_information {
+ my ($self, $error, $title) = @_;
+
+ my $add_params = {};
+ $add_params->{"title"} = $title if ($title);
+ $self->{"label_information"} = $error;
+
+ $self->header();
+ print($self->parse_html_template("generic/information", $add_params));
+
+ die("Information: $error\n");
+}
+