Skip to content

Commit c74c356

Browse files
author
Andjelko Horvat
committed
SimpleSAML_XHTML_Template: add language parameter options (issue #530).
git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3217 44740490-163a-0410-bde0-09ae8108e29a
1 parent 50b1778 commit c74c356

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

config-templates/config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@
277277
'language.rtl' => array('ar','dv','fa','ur','he'),
278278
'language.default' => 'en',
279279

280+
/*
281+
* Options to override the default settings for the language parameter
282+
*/
283+
'language.parameter.name' => 'language',
284+
'language.parameter.setcookie' => TRUE,
285+
280286
/*
281287
* Options to override the default settings for the language cookie
282288
*/

lib/SimpleSAML/XHTML/Template.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class SimpleSAML_XHTML_Template {
3838
private $defaultDictionary = NULL;
3939

4040

41+
/**
42+
* HTTP GET language parameter name.
43+
*/
44+
private $languageParameterName = 'language';
45+
46+
4147
/**
4248
* Constructor
4349
*
@@ -52,9 +58,10 @@ function __construct(SimpleSAML_Configuration $configuration, $template, $defaul
5258
$this->data['baseurlpath'] = $this->configuration->getBaseURL();
5359

5460
$this->availableLanguages = $this->configuration->getArray('language.available', array('en'));
55-
56-
if (isset($_GET['language'])) {
57-
$this->setLanguage($_GET['language']);
61+
62+
$this->languageParameterName = $this->configuration->getString('language.parameter.name', 'language');
63+
if (isset($_GET[$this->languageParameterName])) {
64+
$this->setLanguage($_GET[$this->languageParameterName], $this->configuration->getBoolean('language.parameter.setcookie', TRUE));
5865
}
5966

6067
if($defaultDictionary !== NULL && substr($defaultDictionary, -4) === '.php') {

templates/includes/header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
if ($current) {
194194
$textarray[] = $langnames[$lang];
195195
} else {
196-
$textarray[] = '<a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURL(), array('language' => $lang))) . '">' .
196+
$textarray[] = '<a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURL(), array($this->languageParameterName => $lang))) . '">' .
197197
$langnames[$lang] . '</a>';
198198
}
199199
}

0 commit comments

Comments
 (0)