From 3bd1773c6719bf99658ba570c5942ac3f29cc8c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 7 May 2009 09:47:39 +0000 Subject: [PATCH] Verbesserung an der Formelmeachanik. Fehlertoleranteres Parsing, und Dokumentation im Tooltip. Ausserdem das sehr suspekte Konstrukt "split m/;/, $formel; for (@_) { ... }" entfernt. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix für Bug 461. --- bin/mozilla/common.pl | 47 +++++++++-------------- locale/de/all | 2 +- templates/webpages/ic/form_header_de.html | 2 +- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 0d7862b30..efeb8f040 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -276,45 +276,36 @@ sub vendor_selection { sub calculate_qty { $lxdebug->enter_sub(); - my @variable_sort = (); - my %variable_list = (); - my $unit_list = (); $form->{formel} =~ s/\r\n//g; my ($variable_string, $formel) = split /###/,$form->{formel}; - - split m/;/, $variable_string; - foreach $item (@_) { - my($name, $valueunit) = split /=/,$item; - my($value, $unit) = split / /, $valueunit; - - push(@variable_sort, $value); - $variable_list{$value} = $name; - $unit_list{$value} = $unit; + foreach $item (split m/;/, $variable_string) { + next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x; + push @variable, { + description => $1, + name => $2, + unit => $3, + }; } my @header_sort = qw(variable value unit); - my %header_title = ( "variable" => $locale->text("Variable"), - "value" => $locale->text("Value"), - "unit" => $locale->text("Unit"), - ); + my %header_title = ( + variable => $locale->text("Variable"), + value => $locale->text("Value"), + unit => $locale->text("Unit"), + ); + my @header = map +{ + column_title => $header_title{$_}, + column => $_, + }, @header_sort; - my @variable = map(+{ "description" => $variable_list{$_}, - "name" => $_, - "unit" => $unit_list{$_} }, @variable_sort); - - my @header = - map(+{ "column_title" => $header_title{$_}, - "column" => $_, - }, - @header_sort); $form->{formel} = $formel; - $form->{"title"} = $locale->text("Please enter values"); + $form->{title} = $locale->text("Please enter values"); $form->header(); - print($form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, + print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, "VARIABLES" => \@variable, - "onload" => $onload })); + "onload" => $onload }); $lxdebug->leave_sub(); } diff --git a/locale/de/all b/locale/de/all index 589e029c1..66f4cd3d5 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1448,7 +1448,7 @@ $self->{texts} = { 'The following units exist already:' => 'Die folgenden Einheiten existieren bereits:', 'The following users have been migrated into the authentication database:' => 'Die folgenden Benutzer wurden in die Authentifizierungsdatenbank migriert:', 'The following warnings occured during an upgrade to the document templates:' => 'Die folgenden Warnungen traten während einer Aktualisierung der Dokumentenvorlagen auf:', - 'The formula needs the following syntax:
For regular article:
Variablename= Variable Unit;
Variablename2= Variable2 Unit2;
...
###
Variable + ( Variable2 / Variable )
Please be beware of the spaces in the formula
' => 'Die Formeln müssen in der folgenden Syntax eingegeben werden:
Bei normalen Artikeln:
Variablenname= Variable Einheit;
Variablenname2= Variable2 Einheit2;
...
###
Variable + Variable2 * ( Variable - Variable2 )
Bitte achten Sie auf die Leerzeichen in der Formel
Es muss jeweils die Gesamte Zeile eingegeben werden', + 'The formula needs the following syntax:
For regular article:
Variablename= Variable Unit;
Variablename2= Variable2 Unit2;
...
###
Variable + ( Variable2 / Variable )
Please be beware of the spaces in the formula
' => 'Die Formeln müssen in der folgenden Syntax eingegeben werden:
Bei normalen Artikeln:
Variablenname = Variable Einheit;
Variablenname2 = Variable2 Einheit2;
...
###
Variable + Variable2 * ( Variable - Variable2 )
Variablennamen und Einheiten dürfen nur aus alphanumerischen Zeichen bestehen.
Es muss jeweils die Gesamte Zeile eingegeben werden', 'The group has been added.' => 'Die Gruppe wurde erfasst.', 'The group has been deleted.' => 'Die Gruppe wurde gelöscht.', 'The group has been saved.' => 'Die Gruppe wurde gespeichert.', diff --git a/templates/webpages/ic/form_header_de.html b/templates/webpages/ic/form_header_de.html index 85ff5537d..a3e8e002c 100644 --- a/templates/webpages/ic/form_header_de.html +++ b/templates/webpages/ic/form_header_de.html @@ -130,7 +130,7 @@ [%- UNLESS is_service %] - + [%- END %] -- 2.20.1