From 20dd9657fa0b8a78a078f372c6c7ce9be898d82f Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sun, 11 Mar 2007 00:22:29 +0000 Subject: Adding format_string back into LedgerSMB.pm for now git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@882 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/LedgerSMB.pm b/LedgerSMB.pm index e827774f..7f1306ff 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -161,6 +161,42 @@ sub redirect { } } +sub format_string { + + my ($self, @fields) = @_; + + my $format = $self->{format}; + + if ($self->{format} =~ /(postscript|pdf)/) { + $format = 'tex'; + } + + my %replace = ( + 'order' => { + html => [ '<', '>', '\n', '\r' ], + txt => [ '\n', '\r' ], + tex => [ quotemeta('\\'), '&', '\n','\r', + '\$', '%', '_', '#', + quotemeta('^'), '{', '}', '<', '>', '£' + ] }, + html => { '<' => '<', '>' => '>','\n' => '
', + '\r' => '
' }, + txt => { '\n' => "\n", '\r' => "\r" }, + tex => {'&' => '\&', '$' => '\$', '%' => '\%', '_' => '\_', + '#' => '\#', quotemeta('^') => '\^\\', '{' => '\{', + '}' => '\}', '<' => '$<$', '>' => '$>$', + '\n' => '\newline ', '\r' => '\newline ', + '£' => '\pounds ', quotemeta('\\') => '/'} + ); + + my $key; + + foreach $key (@{ $replace{order}{$format} }) { + for (@fields) { $self->{$_} =~ s/$key/$replace{$format}{$key}/g } + } + +} + sub format_amount { -- cgit v1.2.3