Skip to content
Snippets Groups Projects
Commit 45759aa7 authored by Andjelko Horvat's avatar Andjelko Horvat
Browse files

SimpleSAML_XHTML_Template::getLanguage(): add support for custom function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2996 44740490-163a-0410-bde0-09ae8108e29a
parent 8cb5b817
No related branches found
No related tags found
No related merge requests found
...@@ -251,6 +251,18 @@ $config = array ( ...@@ -251,6 +251,18 @@ $config = array (
'language.rtl' => array('ar','dv','fa','ur','he'), 'language.rtl' => array('ar','dv','fa','ur','he'),
'language.default' => 'en', 'language.default' => 'en',
/**
* Custom getLanguage function called from SimpleSAML_XHTML_Template::getLanguage().
* Function should return language code of one of the available languages or NULL.
* See SimpleSAML_XHTML_Template::getLanguage() source code for more info.
*
* This option can be used to implement a custom function for determining
* the default language for the user.
*
* Example:
* 'language.get_language_function' => array('sspmod_example_Template', 'getLanguage'),
*/
/* /*
* Extra dictionary for attribute names. * Extra dictionary for attribute names.
* This can be used to define local attributes. * This can be used to define local attributes.
......
...@@ -97,6 +97,16 @@ class SimpleSAML_XHTML_Template { ...@@ -97,6 +97,16 @@ class SimpleSAML_XHTML_Template {
return $this->language; return $this->language;
} }
// Run custom getLanguage function if defined
$customFunction = $this->configuration->getArray('language.get_language_function', NULL);
if (isset($customFunction)) {
assert('is_callable($customFunction)');
$customLanguage = call_user_func($customFunction, $this);
if ($customLanguage !== NULL && $customLanguage !== FALSE) {
return $customLanguage;
}
}
// Language is provided in a stored COOKIE // Language is provided in a stored COOKIE
$languageCookie = SimpleSAML_XHTML_Template::getLanguageCookie(); $languageCookie = SimpleSAML_XHTML_Template::getLanguageCookie();
if ($languageCookie !== NULL && in_array($languageCookie, $this->availableLanguages, TRUE)) { if ($languageCookie !== NULL && in_array($languageCookie, $this->availableLanguages, TRUE)) {
......
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