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

SF.net SVN: ledger-smb:[6341] trunk/LedgerSMB/Template



Revision: 6341
          http://sourceforge.net/p/ledger-smb/code/6341
Author:   einhverfr
Date:     2014-01-02 05:54:38 +0000 (Thu, 02 Jan 2014)
Log Message:
-----------
Changes to look up file if stored in db

Modified Paths:
--------------
    trunk/LedgerSMB/Template/CSV.pm
    trunk/LedgerSMB/Template/HTML.pm
    trunk/LedgerSMB/Template/LaTeX.pm
    trunk/LedgerSMB/Template/ODS.pm
    trunk/LedgerSMB/Template/TXT.pm

Added Paths:
-----------
    trunk/LedgerSMB/Template/DB.pm

Modified: trunk/LedgerSMB/Template/CSV.pm
===================================================================
--- trunk/LedgerSMB/Template/CSV.pm	2014-01-02 05:46:09 UTC (rev 6340)
+++ trunk/LedgerSMB/Template/CSV.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -111,7 +111,11 @@
 	} else {
 		$output = \$parent->{output};
 	}
-	if (ref $parent->{template} eq 'SCALAR') {
+        if ($parent->{include_path} eq 'DB'){
+                $source = LedgerSMB::Template::DB->get_template(
+                       $parent->{template}, $parent->{include_path_lang}, 'csv'
+                );
+	} elsif (ref $parent->{template} eq 'SCALAR') {
 		$source = $parent->{template};
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};

Added: trunk/LedgerSMB/Template/DB.pm
===================================================================
--- trunk/LedgerSMB/Template/DB.pm	                        (rev 0)
+++ trunk/LedgerSMB/Template/DB.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -0,0 +1,50 @@
+=head1 NAME
+
+LedgerSMB::Template::DB - Template administration functions for LedgerSMB
+
+=head1 SYNPOPSIS
+
+To retrieve template data as a scalar ref (for TT):
+
+   LedgerSMB::Template::DB->get_template($template_name, $language_code);
+
+To retrieve for editing:
+
+   LedgerSMB::Template::DB->get_by_id($id);
+
+or
+
+   LedgerSMB::Template::DB->get(
+           template_name => $template_name, language_code => $language_code
+   );
+
+To save:
+
+   my $template =  LedgerSMB::Template::DB->new(%$request);
+   $template->save;
+
+=head1 PROPERTIES
+
+=head2 id int
+
+=head2 template_name text (required)
+
+=head2 language_code text
+
+=head2 template text (required)
+
+=head2 format text (required)
+
+=head1 METHODS
+
+=head1 COPYRIGHT
+
+Copyright (C) 2014 The LedgerSMB Core Team
+
+This file may be re-used under the terms of the GNU General Public License 
+version 2 or at your option any later version.  Please see the included 
+LICENSE.txt for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;

Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm	2014-01-02 05:46:09 UTC (rev 6340)
+++ trunk/LedgerSMB/Template/HTML.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -129,7 +129,7 @@
 	}
         if ($parent->{include_path} eq 'DB'){
                 $source = LedgerSMB::Template::DB->get_template(
-                       $parent->{template}, $parent->{include_path_lang}
+                       $parent->{template}, $parent->{include_path_lang}, 'html'
                 );
 	} elsif (ref $parent->{template} eq 'SCALAR') {
 		$source = $parent->{template};

Modified: trunk/LedgerSMB/Template/LaTeX.pm
===================================================================
--- trunk/LedgerSMB/Template/LaTeX.pm	2014-01-02 05:46:09 UTC (rev 6340)
+++ trunk/LedgerSMB/Template/LaTeX.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -161,7 +161,11 @@
 		"${LedgerSMB::Sysconfig::tempdir}/$parent->{template}-output-$$";
 
         $parent->{binmode} = $binmode;
-	if (ref $parent->{template} eq 'SCALAR') {
+        if ($parent->{include_path} eq 'DB'){
+                $source = LedgerSMB::Template::DB->get_template(
+                       $parent->{template}, $parent->{include_path_lang}, 'tex'
+                );
+	} elsif (ref $parent->{template} eq 'SCALAR') {
 		$source = $parent->{template};
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};

Modified: trunk/LedgerSMB/Template/ODS.pm
===================================================================
--- trunk/LedgerSMB/Template/ODS.pm	2014-01-02 05:46:09 UTC (rev 6340)
+++ trunk/LedgerSMB/Template/ODS.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -847,7 +847,11 @@
         $parent->{binmode} = $binmode;
 	$parent->{outputfile} ||= "$tempdir/$parent->{template}-output-$$";
 
-	if (ref $parent->{template} eq 'SCALAR') {
+        if ($parent->{include_path} eq 'DB'){
+                $source = LedgerSMB::Template::DB->get_template(
+                       $parent->{template}, $parent->{include_path_lang}, 'ods'
+                );
+	} elsif (ref $parent->{template} eq 'SCALAR') {
 		$source = $parent->{template};
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};

Modified: trunk/LedgerSMB/Template/TXT.pm
===================================================================
--- trunk/LedgerSMB/Template/TXT.pm	2014-01-02 05:46:09 UTC (rev 6340)
+++ trunk/LedgerSMB/Template/TXT.pm	2014-01-02 05:54:38 UTC (rev 6341)
@@ -119,7 +119,11 @@
 		$output = "$parent->{outputfile}.". get_extension($parent);
                 $parent->{outputfile} = $output;
 	}
-	if (ref $parent->{template} eq 'SCALAR') {
+        if ($parent->{include_path} eq 'DB'){
+                $source = LedgerSMB::Template::DB->get_template(
+                       $parent->{template}, $parent->{include_path_lang}, 'ods'
+                );
+	} elsif (ref $parent->{template} eq 'SCALAR') {
 		$source = $parent->{template};
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};

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


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits