summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-11 00:22:29 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-11 00:22:29 +0000
commit20dd9657fa0b8a78a078f372c6c7ce9be898d82f (patch)
tree77ecb25cb47f7fb06188b7e4356582c0b9e65e71
parentd5b5bd5b26f0dfa659b260f222e66122d8453310 (diff)
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
-rwxr-xr-xLedgerSMB.pm36
1 files changed, 36 insertions, 0 deletions
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 => { '<' => '&lt;', '>' => '&gt;','\n' => '<br />',
+ '\r' => '<br />' },
+ 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 {