Skip to content
Snippets Groups Projects
Commit ca63a255 authored by Olav Morken's avatar Olav Morken
Browse files

Template: add readDictionaryFile()-method and change includeLanguageFile() to use it.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@752 44740490-163a-0410-bde0-09ae8108e29a
parent 41815691
No related branches found
No related tags found
No related merge requests found
...@@ -349,28 +349,44 @@ class SimpleSAML_XHTML_Template { ...@@ -349,28 +349,44 @@ class SimpleSAML_XHTML_Template {
$filebase = $this->configuration->getPathValue('dictionarydir'); $filebase = $this->configuration->getPathValue('dictionarydir');
} }
SimpleSAML_Logger::info('Template: Loading [' . $filebase . $file . ']'); $lang = $this->readDictionaryFile($filebase . $file);
if (is_array($this->langtext)) {
if (!file_exists($filebase . $file)) { SimpleSAML_Logger::info('Template: Merging language array. Loading [' . $file . ']');
SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filebase . $file . ']'); $this->langtext = array_merge($this->langtext, $lang);
return; } else {
SimpleSAML_Logger::info('Template: Setting new language array. Loading [' . $file . ']');
$this->langtext = $lang;
}
}
/**
* Read a dictionary file.
*
* @param $filename The absolute path to the dictionary file.
* @return The translation array which was found in the dictionary file.
*/
private function readDictionaryFile($filename) {
assert('is_string($filename)');
SimpleSAML_Logger::info('Template: Reading [' . $filename . ']');
if (!file_exists($filename)) {
SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
return array();
} }
include($filebase . $file);
$lang = NULL;
include($filename);
if (isset($lang)) { if (isset($lang)) {
if (is_array($this->langtext)) { return $lang;
SimpleSAML_Logger::info('Template: Merging language array. Loading [' . $file . ']');
$this->langtext = array_merge($this->langtext, $lang);
} else {
SimpleSAML_Logger::info('Template: Setting new language array. Loading [' . $file . ']');
$this->langtext = $lang;
}
} }
return array();
} }
/** /**
* Show the template to the user. * Show the template to the user.
*/ */
......
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