From 811948310a0ca2ccd0056c5c8438a47a1867749a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Sun, 11 Jan 2009 14:07:36 +0000
Subject: [PATCH] Change in getLanguage, that allows to not fallback to default
 or http preferences

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1138 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XHTML/Template.php | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index d87c62a72..d9186cd99 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -87,7 +87,7 @@ class SimpleSAML_XHTML_Template {
 	 * then it tries to calculate the preferred language from HTTP headers.
 	 * Last it returns the default language.
 	 */	
-	public function getLanguage() {
+	public function getLanguage($checkHTTP = TRUE, $defaultFallback = TRUE) {
 		
 		// Language is set in object
 		if (isset($this->language)) {
@@ -99,15 +99,20 @@ class SimpleSAML_XHTML_Template {
 			$this->language = $_COOKIE['language'];
 			return $this->language;
 		}
-
-		/* Check if we can find a good language from the Accept-Language http header. */
-		$httpLanguage = $this->getHTTPLanguage();
-		if ($httpLanguage !== NULL) {
-			return $httpLanguage;
+		
+		if ($checkHTTP) {
+			/* Check if we can find a good language from the Accept-Language http header. */
+			$httpLanguage = $this->getHTTPLanguage();
+			if ($httpLanguage !== NULL) {
+				return $httpLanguage;
+			}
 		}
 
 		// Language is not set, and we get the default language from the configuration.
-		return $this->getDefaultLanguage();
+		if ($defaultFallback) 
+			return $this->getDefaultLanguage();
+			
+		return NULL;
 	}
 
 
-- 
GitLab