From c74c356ff4dfa80ff5cfd5aec754d0775a28e116 Mon Sep 17 00:00:00 2001 From: Andjelko Horvat <comel@vingd.com> Date: Tue, 8 Jan 2013 11:56:19 +0000 Subject: [PATCH] SimpleSAML_XHTML_Template: add language parameter options (issue #530). git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3217 44740490-163a-0410-bde0-09ae8108e29a --- config-templates/config.php | 6 ++++++ lib/SimpleSAML/XHTML/Template.php | 13 ++++++++++--- templates/includes/header.php | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config-templates/config.php b/config-templates/config.php index dc63b94ed..0e82fb130 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -277,6 +277,12 @@ $config = array ( 'language.rtl' => array('ar','dv','fa','ur','he'), 'language.default' => 'en', + /* + * Options to override the default settings for the language parameter + */ + 'language.parameter.name' => 'language', + 'language.parameter.setcookie' => TRUE, + /* * Options to override the default settings for the language cookie */ diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index b58af7e21..9bb475949 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -38,6 +38,12 @@ class SimpleSAML_XHTML_Template { private $defaultDictionary = NULL; + /** + * HTTP GET language parameter name. + */ + private $languageParameterName = 'language'; + + /** * Constructor * @@ -52,9 +58,10 @@ class SimpleSAML_XHTML_Template { $this->data['baseurlpath'] = $this->configuration->getBaseURL(); $this->availableLanguages = $this->configuration->getArray('language.available', array('en')); - - if (isset($_GET['language'])) { - $this->setLanguage($_GET['language']); + + $this->languageParameterName = $this->configuration->getString('language.parameter.name', 'language'); + if (isset($_GET[$this->languageParameterName])) { + $this->setLanguage($_GET[$this->languageParameterName], $this->configuration->getBoolean('language.parameter.setcookie', TRUE)); } if($defaultDictionary !== NULL && substr($defaultDictionary, -4) === '.php') { diff --git a/templates/includes/header.php b/templates/includes/header.php index 692f21fd0..4dd83e423 100644 --- a/templates/includes/header.php +++ b/templates/includes/header.php @@ -193,7 +193,7 @@ if($onLoad !== '') { if ($current) { $textarray[] = $langnames[$lang]; } else { - $textarray[] = '<a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURL(), array('language' => $lang))) . '">' . + $textarray[] = '<a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURL(), array($this->languageParameterName => $lang))) . '">' . $langnames[$lang] . '</a>'; } } -- GitLab