From d2851bc0e9380893d786da3b0ecfddecb50dc5e7 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 18:06:40 +0000 Subject: [PATCH] Fix to template file inclusion git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@428 44740490-163a-0410-bde0-09ae8108e29a --- config-templates/config.php | 2 +- lib/SimpleSAML/XHTML/Template.php | 37 ++++++++++++++++++++------- templates/default/includes/header.php | 3 ++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/config-templates/config.php b/config-templates/config.php index 7fbb9b5fb..a0ddc3ab1 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -22,7 +22,7 @@ $config = array ( * See the user manual for more details. */ 'baseurlpath' => 'simplesaml/', - 'templatedir' => 'templates/default/', + 'templatedir' => 'templates/', 'metadatadir' => 'metadata/', 'attributenamemapdir' => 'attributemap/', 'certdir' => 'cert/', diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 9e8fd50ca..a475f0b12 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -26,6 +26,10 @@ class SimpleSAML_XHTML_Template { $this->data['baseurlpath'] = $this->configuration->getBaseURL(); + if (isset($_GET['language'])) { + $this->setLanguage($_GET['language']); + } + if (!empty($languagefile)) $this->includeLanguageFile($languagefile); } @@ -41,11 +45,7 @@ class SimpleSAML_XHTML_Template { // Language is set in object if (isset($this->language)) { return $this->language; - - // Language is provided in query string - } else if (isset($_GET['language'])) { - $this->setLanguage($_GET['language']); - + // Language is provided in a stored COOKIE } else if (isset($_COOKIE['language'])) { $this->language = $_COOKIE['language']; @@ -75,11 +75,29 @@ class SimpleSAML_XHTML_Template { private function includeAtTemplateBase($file) { $data = $this->data; - $filebase = $this->configuration->getPathValue('templatedir'); - include($filebase . $file); + $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.use') . '/' . $file; + + 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; + + 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); } private function includeAtLanguageBase($file) { + + throw new Exception('Deprecated method call includeAtLanguageBase()'); + /* $data = $this->data; $filebase = $this->configuration->getPathValue('templatedir') . $this->getLanguage() . '/' ; @@ -94,6 +112,7 @@ class SimpleSAML_XHTML_Template { } } include($filebase . $file); + */ } @@ -191,14 +210,14 @@ class SimpleSAML_XHTML_Template { $filename = $this->configuration->getPathValue('templatedir') . - $this->configuration->getPathValue('template.use') . '/' . $this->template; + $this->configuration->getValue('template.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'); $filename = $this->configuration->getPathValue('templatedir') . - $this->configuration->getPathValue('template.base') . '/' . $this->template; + $this->configuration->getValue('template.base') . '/' . $this->template; if (!file_exists($filename)) { diff --git a/templates/default/includes/header.php b/templates/default/includes/header.php index cfff2a881..c10c90d99 100644 --- a/templates/default/includes/header.php +++ b/templates/default/includes/header.php @@ -35,7 +35,8 @@ $langnames = array( 'no' => 'Norsk', 'en' => 'English', 'de' => 'Deutch', - 'dk' => 'Dansk' + 'dk' => 'Dansk', + 'es' => 'Spanish', ); if (empty($_POST) ) { -- GitLab