From d1c335e9bb0a35d45acd03b29d1e759f26c5664c Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 6 Apr 2006 10:16:31 +0000 Subject: [PATCH] HTML-Vorlagen: Die globale Konfigurationsvariable $latex in $latex_templates umbenannt. Einige globale Konfigurationsvariablen in allen HTML-Vorlagen unter dem Namen "conf_" bekannt gemacht. Zwei Variablen lokal zur aktuellen Funktion gemacht. Automatisch in HTML-Vorlagen die Zugriffsberechtigungen als Variablen der Form "access_menu_name" verfuegbar machen. Alle Variablen aus %myconfig in HTML-Webseitenvorlagen verfuegbar gemacht. Ausserdem aus das Datumsformat fuer den Javascript-Kalendar aus dem Datenbankdatumsformat ableiten und zur Verfuegung stellen. Beim Aufruf von $form->show_generic_error() auf jeden Fall $form->header() aufrufen und danach das Script beenden. [Merge der Revisionen 876 883 902 987 1093 aus dem LINET prog Repo] --- SL/Form.pm | 59 ++++++++++++++++++++++++++++++++++---------- bin/mozilla/cp.pl | 6 ++--- bin/mozilla/io.pl | 15 ++++++++--- bin/mozilla/rp.pl | 12 ++++----- bin/mozilla/ustva.pl | 2 +- lx-erp.conf | 2 +- 6 files changed, 68 insertions(+), 28 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 80c67fc39..725eace5a 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -38,6 +38,7 @@ package Form; use HTML::Template; +use SL::Menu; sub _input_to_hash { $main::lxdebug->enter_sub(2); @@ -242,12 +243,8 @@ sub error { if ($ENV{HTTP_USER_AGENT}) { $msg =~ s/\n/
/g; - - $self->header; $self->show_generic_error($msg); - die "Error: $msg\n"; - } else { if ($self->{error_function}) { @@ -373,7 +370,7 @@ function fokus(){document.$self->{fokus}.focus();} } #Set Calendar - $jsscript = ""; + my $jsscript = ""; if ($self->{jsscript} == 1) { $jsscript = qq| @@ -410,7 +407,6 @@ function fokus(){document.$self->{fokus}.focus();} $main::lxdebug->leave_sub(); } -use Data::Dumper; sub parse_html_template { $main::lxdebug->enter_sub(); @@ -461,6 +457,28 @@ sub parse_html_template { "
DEBUG INFORMATION:
" . $additional_params->{"DEBUG"} . "
"; } + 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 $menu; + if (-f $self->{"login"} . "_menu.ini") { + $menu = Menu->new($self->{"login"} . "_menu.ini"); + } else { + $menu = Menu->new("menu.ini"); + } + $menu->generate_acl("", $additional_params); + my @additional_param_names = keys(%{$additional_params}); foreach my $key ($template->param()) { @@ -485,7 +503,23 @@ sub show_generic_error { $add_params->{"title"} = $title if ($title); $self->{"label_error"} = $error; + $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"); } # write Trigger JavaScript-Code ($qty = quantity of Triggers) @@ -536,7 +570,7 @@ sub write_trigger { ); |; } - $jsscript = qq| + my $jsscript = qq| @@ -715,7 +749,6 @@ sub parse_template { my ($current_page, $current_line, $current_row) = (1, 1, 0); my $pagebreak = ""; my $sum = 0; - # } Moritz Bunkus # Make sure that all *notes* (intnotes, partnotes_*, notes etc) are converted to markup correctly. @@ -1073,10 +1106,10 @@ Content-Length: $numbytes close(IN); } - $self->cleanup; - } + $self->cleanup; + chdir("$self->{cwd}"); $main::lxdebug->leave_sub(); } @@ -1730,7 +1763,7 @@ sub create_links { $query = qq| SELECT * FROM tax t|; $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); - $form->{TAX} = (); + $self->{TAX} = (); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{TAX} }, $ref; } @@ -2105,7 +2138,7 @@ sub update_defaults { $query = qq|UPDATE defaults SET $fld = '$var'|; - $dbh->do($query) || $form->dberror($query); + $dbh->do($query) || $self->dberror($query); $dbh->commit; $dbh->disconnect; @@ -2133,7 +2166,7 @@ sub update_business { } $query = qq|UPDATE business SET customernumberinit = '$var' WHERE id=$business_id|; - $dbh->do($query) || $form->dberror($query); + $dbh->do($query) || $self->dberror($query); $dbh->commit; $dbh->disconnect; diff --git a/bin/mozilla/cp.pl b/bin/mozilla/cp.pl index 7836eb2fc..ad646b1f1 100644 --- a/bin/mozilla/cp.pl +++ b/bin/mozilla/cp.pl @@ -443,12 +443,12 @@ sub form_footer { $media = qq| |; %lang = (de => "deutsch", en => "englisch", fr => "französisch"); @@ -1371,7 +1378,7 @@ sub print_options { $media |; - if ($myconfig{printer} && $latex && $form->{media} ne 'email') { + if ($myconfig{printer} && $latex_templates && $form->{media} ne 'email') { print qq| | . $locale->text('Copies') . qq| {copies}> diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 34b12848f..fe46f179e 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -1906,14 +1906,14 @@ sub print_options { } else { $media = qq| |; - if ($latex) { + if ($latex_templates) { $format .= qq|