From: Moritz Bunkus Date: Thu, 24 May 2007 06:38:25 +0000 (+0000) Subject: Die Funtktionen save_form() und restore_form() aus common.pl in ein eigenes Modul... X-Git-Tag: release-2.4.3^2~271 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6b293028a4c1f27bcb07c665a4f43f5362debf1f;p=kivitendo-erp.git Die Funtktionen save_form() und restore_form() aus common.pl in ein eigenes Modul verlagert, das sie auch automatisch in den Namensraum des Aufrufers exportiert. Damit können sie auch von den Modulen in SL/ benutzt werden. --- diff --git a/SL/MoreCommon.pm b/SL/MoreCommon.pm new file mode 100644 index 000000000..196702c22 --- /dev/null +++ b/SL/MoreCommon.pm @@ -0,0 +1,42 @@ +package SL::MoreCommon; + +require Exporter; +@ISA = qw(Exporter); + +@EXPORT = qw(save_form restore_form); + +use YAML; + +sub save_form { + $main::lxdebug->enter_sub(); + + my $old_form = YAML::Dump($main::form); + $old_form =~ s|!|!!|g; + $old_form =~ s|\n|!n|g; + $old_form =~ s|\r|!r|g; + + $main::lxdebug->leave_sub(); + + return $old_form; +} + +sub restore_form { + $main::lxdebug->enter_sub(); + + my ($old_form, $no_delete) = @_; + + my $form = $main::form; + + map { delete $form->{$_}; } keys %{$form} unless ($no_delete); + + $old_form =~ s|!r|\r|g; + $old_form =~ s|!n|\n|g; + $old_form =~ s|!!|!|g; + + my $new_form = YAML::Load($old_form); + map { $form->{$_} = $new_form->{$_}; } keys %{$new_form}; + + $main::lxdebug->leave_sub(); +} + +1; diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 7c8b1e5f1..47de5b044 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -10,37 +10,8 @@ ###################################################################### use SL::Form; -use YAML; - use SL::Common; - -sub save_form { - $lxdebug->enter_sub(); - - my $old_form = YAML::Dump($form); - $old_form =~ s|!|!!|g; - $old_form =~ s|\n|!n|g; - $old_form =~ s|\r|!r|g; - - $lxdebug->leave_sub(); - - return $old_form; -} - -sub restore_form { - $lxdebug->enter_sub(); - - my ($old_form, $no_delete) = @_; - - map({ delete($form->{$_}); } keys(%{$form})) unless ($no_delete); - $old_form =~ s|!r|\r|g; - $old_form =~ s|!n|\n|g; - $old_form =~ s|!!|!|g; - my $new_form = YAML::Load($old_form); - map({ $form->{$_} = $new_form->{$_}; } keys(%{$new_form})); - - $lxdebug->leave_sub(); -} +use SL::MoreCommon; sub build_std_url { $lxdebug->enter_sub();