X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/aacd5750af1d2371dff2abd2db5f6f5f0cca02e6..6277aefffea29c8aa6f684bd86c55cdc6366f32f:/bin/mozilla/common.pl diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 4ca0b8a0c..ea34189db 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -16,9 +16,14 @@ use SL::Common; sub save_form { $lxdebug->enter_sub(); - my $old_form = ""; - map({ $old_form .= "$_=" . $form->escape($form->{$_}) . '&'; } keys(%{$form})); - chop($old_form); + my (@names, @values); + foreach my $key (keys(%{$form})) { + push(@names, "\$form->{\"$key\"}"); + push(@values, $form->{$key}); + } + my $dumper = Data::Dumper->new(\@values, \@names); + $dumper->Indent(0); + my $old_form = $dumper->Dump(); $lxdebug->leave_sub(); @@ -28,16 +33,34 @@ sub save_form { sub restore_form { $lxdebug->enter_sub(); - my ($old_form) = @_; + my ($old_form, $no_delete) = @_; + + map({ delete($form->{$_}); } keys(%{$form})) unless ($no_delete); + eval($old_form); + + $lxdebug->leave_sub(); +} - map({ delete($form->{$_}); } keys(%{$form})); +sub build_std_url { + $lxdebug->enter_sub(); - foreach my $pair (split('&', $old_form)) { - my ($key, $value) = split('=', $form->unescape($pair), 2); - $form->{$key} = $value; + my $url = "$form->{script}?"; + my $first = 1; + foreach my $key ((qw(login password path), @_)) { + next unless ($key); + $url .= "&" unless ($first); + $first = 0; + + if ($key =~ /=/) { + $url .= $key; + } else { + $url .= "${key}=" . E($form->{$key}); + } } $lxdebug->leave_sub(); + + return $url; } sub select_employee { @@ -419,4 +442,82 @@ sub H { return $form->quote_html($_[0]); } +sub Q { + return $form->quote($_[0]); +} + +sub E { + return $form->escape($_[0]); +} + +sub format_dates { + $lxdebug->enter_sub(); + + my ($dateformat, $longformat, @indices) = @_; + + $dateformat = $myconfig{"dateformat"} unless ($dateformat); + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $locale->reformat_date(\%myconfig, $form->{$idx}, + $dateformat, $longformat); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $locale->reformat_date(\%myconfig, $form->{$idx}->[$i], + $dateformat, $longformat); + } + } + } + + $lxdebug->leave_sub(); +} + +sub reformat_numbers { + $lxdebug->enter_sub(); + + my ($numberformat, $places, @indices) = @_; + + return $lxdebug->leave_sub() + if (!$numberformat || ($numberformat eq $myconfig{"numberformat"})); + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $form->parse_amount(\%myconfig, $form->{$idx}); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $form->parse_amount(\%myconfig, $form->{$idx}->[$i]); + } + } + } + + my $saved_numberformat = $myconfig{"numberformat"}; + $myconfig{"numberformat"} = $numberformat; + + foreach my $idx (@indices) { + next unless (defined($form->{$idx})); + + if (!ref($form->{$idx})) { + $form->{$idx} = $form->format_amount(\%myconfig, $form->{$idx}, $places); + + } elsif (ref($form->{$idx}) eq "ARRAY") { + for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { + $form->{$idx}->[$i] = + $form->format_amount(\%myconfig, $form->{$idx}->[$i], $places); + } + } + } + + $myconfig{"numberformat"} = $saved_numberformat; + + $lxdebug->leave_sub(); +} + 1;