[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [882] trunk/LedgerSMB.pm



Revision: 882
          http://svn.sourceforge.net/ledger-smb/?rev=882&view=rev
Author:   einhverfr
Date:     2007-03-10 16:22:29 -0800 (Sat, 10 Mar 2007)

Log Message:
-----------
Adding format_string back into LedgerSMB.pm for now

Modified Paths:
--------------
    trunk/LedgerSMB.pm

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-03-11 00:08:02 UTC (rev 881)
+++ trunk/LedgerSMB.pm	2007-03-11 00:22:29 UTC (rev 882)
@@ -161,7 +161,43 @@
 	}
 }
 
+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 {
 
 	my ($self, $myconfig, $amount, $places, $dash) = @_;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.