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

SF.net SVN: ledger-smb:[6342] trunk/LedgerSMB/Template/DB.pm



Revision: 6342
          http://sourceforge.net/p/ledger-smb/code/6342
Author:   einhverfr
Date:     2014-01-02 07:03:49 +0000 (Thu, 02 Jan 2014)
Log Message:
-----------
Initial DB loader for templates

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

Modified: trunk/LedgerSMB/Template/DB.pm
===================================================================
--- trunk/LedgerSMB/Template/DB.pm	2014-01-02 05:54:38 UTC (rev 6341)
+++ trunk/LedgerSMB/Template/DB.pm	2014-01-02 07:03:49 UTC (rev 6342)
@@ -2,6 +2,12 @@
 
 LedgerSMB::Template::DB - Template administration functions for LedgerSMB
 
+=cut
+
+package LedgerSMB::Template::DB;
+use Moose;
+with 'LedgerSMB::DBObject_Moose';
+
 =head1 SYNPOPSIS
 
 To retrieve template data as a scalar ref (for TT):
@@ -35,8 +41,85 @@
 
 =head2 format text (required)
 
+=cut
+
+has id             => (is => 'ro', isa => 'Int', required => 0);
+has template_name  => (is => 'ro', isa => 'Str', required => 1);
+has language_code  => (is => 'ro', isa => 'Str', required => 0);
+has format         => (is => 'ro', isa => 'Str', required => 1);
+has template       => (is => 'ro', isa => 'Str', required => 1);
+
 =head1 METHODS
 
+=head2 get_template(template_name, language_code, format)
+
+Returns a scalar ref to the template text so that Template Toolkit can run it.
+
+=cut
+
+sub get_template {
+    my ($module, $template_name, $language_code, $format) = @_;
+    my ($temp) = __PACKAGE__->call_procedure(
+         procname => 'template__get'
+         args => [$template_name, $language_code, $format]
+    );
+    my $text = $temp->{template};
+    return \$text;
+}
+
+=head2 get_by_id(id)
+
+Gets the template by ID.  Returns a whole template object.
+
+=cut
+
+sub get_by_id {
+    my ($module, $id) = @_;
+    my ($temp) = __PACKAGE__->call_procedure(
+         procname => 'template__get_by_id'
+         args => [$id]
+    );
+    return __PACKAGE__->new(%$temp);
+}
+
+
+=head2 get(hash args)
+
+Gets the template by args (for editing or management).  Args are:
+
+=over
+
+=item template_name
+
+=item language_code
+
+=item format
+
+=back
+
+=cut
+
+sub get {
+    my $module = shift @_;
+    my %args = @_;
+    my ($temp) = __PACKAGE__->call_procedure(
+         procname => 'template__get'
+         args => [$args{template_name}, $args{language_code}, $args{format}]
+    );
+    return __PACKAGE__->new(%$temp);
+}
+
+=head2 save
+
+Saves the current object
+
+=cut
+
+sub save {
+    my ($self) = @_;
+    $self->exec_method(funcname => 'template__save');
+}
+
 =head1 COPYRIGHT
 
 Copyright (C) 2014 The LedgerSMB Core Team

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