Skip to content
Snippets Groups Projects
Commit d2851bc0 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Fix to template file inclusion

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@428 44740490-163a-0410-bde0-09ae8108e29a
parent ce89b07b
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ $config = array ( ...@@ -22,7 +22,7 @@ $config = array (
* See the user manual for more details. * See the user manual for more details.
*/ */
'baseurlpath' => 'simplesaml/', 'baseurlpath' => 'simplesaml/',
'templatedir' => 'templates/default/', 'templatedir' => 'templates/',
'metadatadir' => 'metadata/', 'metadatadir' => 'metadata/',
'attributenamemapdir' => 'attributemap/', 'attributenamemapdir' => 'attributemap/',
'certdir' => 'cert/', 'certdir' => 'cert/',
......
...@@ -26,6 +26,10 @@ class SimpleSAML_XHTML_Template { ...@@ -26,6 +26,10 @@ class SimpleSAML_XHTML_Template {
$this->data['baseurlpath'] = $this->configuration->getBaseURL(); $this->data['baseurlpath'] = $this->configuration->getBaseURL();
if (isset($_GET['language'])) {
$this->setLanguage($_GET['language']);
}
if (!empty($languagefile)) $this->includeLanguageFile($languagefile); if (!empty($languagefile)) $this->includeLanguageFile($languagefile);
} }
...@@ -41,11 +45,7 @@ class SimpleSAML_XHTML_Template { ...@@ -41,11 +45,7 @@ class SimpleSAML_XHTML_Template {
// Language is set in object // Language is set in object
if (isset($this->language)) { if (isset($this->language)) {
return $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 // Language is provided in a stored COOKIE
} else if (isset($_COOKIE['language'])) { } else if (isset($_COOKIE['language'])) {
$this->language = $_COOKIE['language']; $this->language = $_COOKIE['language'];
...@@ -75,11 +75,29 @@ class SimpleSAML_XHTML_Template { ...@@ -75,11 +75,29 @@ class SimpleSAML_XHTML_Template {
private function includeAtTemplateBase($file) { private function includeAtTemplateBase($file) {
$data = $this->data; $data = $this->data;
$filebase = $this->configuration->getPathValue('templatedir'); $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.use') . '/' . $file;
include($filebase . $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) { private function includeAtLanguageBase($file) {
throw new Exception('Deprecated method call includeAtLanguageBase()');
/*
$data = $this->data; $data = $this->data;
$filebase = $this->configuration->getPathValue('templatedir') . $this->getLanguage() . '/' ; $filebase = $this->configuration->getPathValue('templatedir') . $this->getLanguage() . '/' ;
...@@ -94,6 +112,7 @@ class SimpleSAML_XHTML_Template { ...@@ -94,6 +112,7 @@ class SimpleSAML_XHTML_Template {
} }
} }
include($filebase . $file); include($filebase . $file);
*/
} }
...@@ -191,14 +210,14 @@ class SimpleSAML_XHTML_Template { ...@@ -191,14 +210,14 @@ class SimpleSAML_XHTML_Template {
$filename = $this->configuration->getPathValue('templatedir') . $filename = $this->configuration->getPathValue('templatedir') .
$this->configuration->getPathValue('template.use') . '/' . $this->template; $this->configuration->getValue('template.use') . '/' . $this->template;
if (!file_exists($filename)) { 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'); 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') . $filename = $this->configuration->getPathValue('templatedir') .
$this->configuration->getPathValue('template.base') . '/' . $this->template; $this->configuration->getValue('template.base') . '/' . $this->template;
if (!file_exists($filename)) { if (!file_exists($filename)) {
......
...@@ -35,7 +35,8 @@ $langnames = array( ...@@ -35,7 +35,8 @@ $langnames = array(
'no' => 'Norsk', 'no' => 'Norsk',
'en' => 'English', 'en' => 'English',
'de' => 'Deutch', 'de' => 'Deutch',
'dk' => 'Dansk' 'dk' => 'Dansk',
'es' => 'Spanish',
); );
if (empty($_POST) ) { if (empty($_POST) ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment