From 0cf29c377c01d668a3ecd9421c167d2cb14dbff2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Wed, 26 Mar 2008 20:41:50 +0000
Subject: [PATCH] renaming theme variable

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@430 44740490-163a-0410-bde0-09ae8108e29a
---
 config-templates/config.php       |  7 ++++---
 lib/SimpleSAML/XHTML/Template.php | 32 +++++++++++++++++++++----------
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/config-templates/config.php b/config-templates/config.php
index a0ddc3ab1..7feb83a43 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -116,10 +116,11 @@ $config = array (
 	'language.default'		=> 'en',
 	
 	/*
-	 * Which template directory should be used? The base is fallback (leave it to default).
+	 * Which theme directory should be used? The base is fallback (leave it to default).
 	 */
-	'template.use' 			=> 'default',
-	'template.base' 		=> 'default',
+	'theme.use' 		=> 'default',
+	'theme.base' 		=> 'default',
+
 	
 	/*
 	 * Default IdPs. If you do not enter an idpentityid in the SSO initialization endpoints,
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index a475f0b12..fe70ff62a 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -17,6 +17,7 @@ class SimpleSAML_XHTML_Template {
 	private $language = null;
 	
 	private $langtext = null;
+	private $usebasetheme = false;
 	
 	public $data = null;
 
@@ -71,25 +72,34 @@ class SimpleSAML_XHTML_Template {
 		}
 		return $lang;
 	}
-
 	
 	private function includeAtTemplateBase($file) {
 		$data = $this->data;
-		$filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.use') . '/' . $file;
+		$filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.use') . '/' . $file;
+
+		if ($this->usebasetheme) {
+			SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Using base for inclusion');
+			
+			$filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.base') . '/' . $file;
+			if (!file_exists($filename)) {
+				SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . 
+					'] at [' . $filename . ']');
+				throw new Exception('Could not load template file [' . $file . ']');
+			}
+			
+		} elseif (!file_exists($filename)) {
 		
-		if (!file_exists($filename)) {
 			SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . 
 				'] at [' . $filename . '] - Now trying at base');
 			
-			$filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.base') . '/' . $file;
-			
+			$filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.base') . '/' . $file;
 			if (!file_exists($filename)) {
 				SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . 
 					'] at [' . $filename . ']');
 				throw new Exception('Could not load template file [' . $file . ']');
 			}
-			
-		}
+		
+		} 
 		
 		include($filename);
 	}
@@ -210,14 +220,16 @@ class SimpleSAML_XHTML_Template {
 		
 
 		$filename  = $this->configuration->getPathValue('templatedir') . 
-			$this->configuration->getValue('template.use') . '/' . $this->template;
-
+			$this->configuration->getValue('theme.use') . '/' . $this->template;
+		
 
 		if (!file_exists($filename)) {
 			SimpleSAML_Logger::warning($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . '] - now trying the base template');
 			
+			$this->usebasetheme = true;
+			
 			$filename = $this->configuration->getPathValue('templatedir') . 
-				$this->configuration->getValue('template.base') . '/' . $this->template;
+				$this->configuration->getValue('theme.base') . '/' . $this->template;
 			
 
 			if (!file_exists($filename)) {
-- 
GitLab