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 {
$filebase = $this->configuration->getPathValue('dictionarydir');
}
SimpleSAML_Logger::info('Template: Loading [' . $filebase . $file . ']');
if (!file_exists($filebase . $file)) {
SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filebase . $file . ']');
return;
$lang = $this->readDictionaryFile($filebase . $file);
if (is_array($this->langtext)) {
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;
}
}
/**
* 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 (is_array($this->langtext)) {
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 $lang;
}
return array();
}
/**
* 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