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

SF.net SVN: ledger-smb: [1032] branches/1.2-experimental/LedgerSMB/Template .pm



Revision: 1032
          http://svn.sourceforge.net/ledger-smb/?rev=1032&view=rev
Author:   einhverfr
Date:     2007-04-04 13:59:10 -0700 (Wed, 04 Apr 2007)

Log Message:
-----------
Cleaned up Template.pm a bit

Modified Paths:
--------------
    branches/1.2-experimental/LedgerSMB/Template.pm

Modified: branches/1.2-experimental/LedgerSMB/Template.pm
===================================================================
--- branches/1.2-experimental/LedgerSMB/Template.pm	2007-04-04 20:53:05 UTC (rev 1031)
+++ branches/1.2-experimental/LedgerSMB/Template.pm	2007-04-04 20:59:10 UTC (rev 1032)
@@ -57,8 +57,8 @@
 	if (!$self->{include_path}){
 		$self->{include_path} = $self->{'myconfig'}->{'templates'};
 		if (defined $self->{language}){
-			if (!$self->valid_language){
-				# TODO:  Throw errors or something.
+			if (!$self->_valid_language){
+				throw Error::Simple 'Invalid language';
 				return undef;
 			}
 			$self->{include_path} = "$self->{'include_path'}"
@@ -70,7 +70,7 @@
 	return $self;
 }
 
-sub valid_language {
+sub _valid_language {
 	my $self = shift;
 	if ($self->{language} =~ m#(/|\\|:|\.\.|^\.)#){
 		return 0;
@@ -83,23 +83,12 @@
 	my $vars = shift;
 	my $template;
 
-	if (not defined $self->{language}) {
-		$template = Template->new({
-			INCLUDE_PATH => $self->{'myconfig'}->{'templates'},
-			START_TAG => quotemeta('<?lsmb'),
-			END_TAG => quotemeta('?>'),
-			DELIMITER => ';',
-			}) || throw Error::Simple Template->error(); 
-	} elsif ($self->valid_language()) {
-		$template = Template->new({
-			INCLUDE_PATH => "$self->{'myconfig'}->{'templates'}/$self->{language};$self->{'myconfig'}->{'templates'}",
-			START_TAG => quotemeta('<?lsmb'),
-			END_TAG => quotemeta('?>'),
-			DELIMITER => ';',
-			}) || throw Error::Simple Template->error();
-	} else {
-		throw Error::Simple 'Invalid language';
-	}
+	$template = Template->new({
+		INCLUDE_PATH => $self->{include_path},
+		START_TAG => quotemeta('<?lsmb'),
+		END_TAG => quotemeta('?>'),
+		DELIMITER => ';',
+		}) || throw Error::Simple Template->error(); 
 
 	eval "require LedgerSMB::Template::$self->{format}";
 	if ($@) {


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