Skip to content
Snippets Groups Projects
Commit 06dafa3c authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Fix consent module to accept not translated service names

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@631 44740490-163a-0410-bde0-09ae8108e29a
parent 3e8b9ce0
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
<articleinfo>
<date>2007-10-15</date>
<pubdate>Mon Apr 28 11:48:30 2008</pubdate>
<pubdate>Tue Jun 3 12:15:38 2008</pubdate>
<author>
<firstname>Andreas Åkre</firstname>
......
......@@ -7,7 +7,7 @@
<articleinfo>
<date>2007-08-30</date>
<pubdate>Thu Mar 27 20:47:47 2008</pubdate>
<pubdate>Tue Jun 3 12:14:40 2008</pubdate>
<author>
<firstname>Andreas Åkre</firstname>
......
......@@ -7,7 +7,7 @@
<articleinfo>
<date>2007-10-15</date>
<pubdate>Mon Apr 28 11:48:32 2008</pubdate>
<pubdate>Fri Jun 6 00:43:25 2008</pubdate>
<author>
<firstname>Andreas Åkre</firstname>
......@@ -267,8 +267,8 @@
<para>Note that this only changes the values in the generated
metadata and in the messages sent to others. You must also
configure your webserver to deliver this URL to the correct
PHP page.</para>
configure your webserver to deliver this URL to the correct PHP
page.</para>
</glossdef>
</glossentry>
......@@ -276,14 +276,14 @@
<glossterm>SingleLogoutService</glossterm>
<glossdef>
<para>Override the default URL for the SingleLogoutService
for this SP. This is an absolute URL. The default value is
<para>Override the default URL for the SingleLogoutService for
this SP. This is an absolute URL. The default value is
<literal>&lt;simpleSAMLphp-root&gt;/saml2/sp/SingleLogoutService.php</literal></para>
<para>Note that this only changes the values in the generated
metadata and in the messages sent to others. You must also
configure your webserver to deliver this URL to the correct
PHP page.</para>
configure your webserver to deliver this URL to the correct PHP
page.</para>
</glossdef>
</glossentry>
......@@ -724,8 +724,8 @@
<para>Note that this only changes the values in the generated
metadata and in the messages sent to others. You must also
configure your webserver to deliver this URL to the correct
PHP page.</para>
configure your webserver to deliver this URL to the correct PHP
page.</para>
</glossdef>
</glossentry>
......
......@@ -133,6 +133,12 @@ class SimpleSAML_XHTML_Template {
return $bestLanguage;
}
/**
* Returns the language base (from configuration)
*/
private function getBaseLanguage() {
return $this->configuration->getValue('language.base', 'en');
}
/**
* Returns the language default (from configuration)
......@@ -201,7 +207,7 @@ class SimpleSAML_XHTML_Template {
* @param $replacements An associative array of keys that should be replaced with values in the translated string.
* @param $striptags Should HTML tags be stripped from the translation
*/
private function t($tag, $fallbacktag = true, $fallbackdefault = true, $replacements = array(), $striptags = false) {
private function t($tag, $fallbacktag = TRUE, $fallbackdefault = true, $replacements = array(), $striptags = false) {
if (empty($this->langtext) || !is_array($this->langtext)) {
SimpleSAML_Logger::error('Template: No language text loaded. Looking up [' . $tag . ']');
......@@ -210,7 +216,7 @@ class SimpleSAML_XHTML_Template {
$selected_language = $this->getLanguage();
$default_language = $this->getDefaultLanguage();
$base_language = $this->configuration->getValue('language.base', 'en');
$base_language = $this->getBaseLanguage();
if (array_key_exists($tag, $this->langtext) ) {
......@@ -218,6 +224,8 @@ class SimpleSAML_XHTML_Template {
* Look up translation of tag in the selected language
*/
if (array_key_exists($selected_language, $this->langtext[$tag])) {
//SimpleSAML_Logger::debug('Template: Found up [' . $tag . ']: in selected language [' . $selected_language . ']. Text is: [' . $this->langtext[$tag][$selected_language] . '].');
$translated = $this->langtext[$tag][$selected_language];
/**
......@@ -249,14 +257,14 @@ class SimpleSAML_XHTML_Template {
* Return the string that should be used when no translation was found.
*
* @param $tag A name tag of the string that should be returned.
* @param $fallbacktag If set to true and string was not found in any languages, return
* the tag it self. If false return null.
* @param $fallbacktag If set to TRUE and string was not found in any languages, return
* the tag it self. If FALSE return NULL.
*/
private function t_not_translated($tag, $fallbacktag) {
if ($fallbacktag) {
return 'not translated (' . $tag . ')';
} else {
return null;
return NULL;
}
}
......@@ -273,7 +281,7 @@ class SimpleSAML_XHTML_Template {
public function includeInlineTranslation($tag, $translation) {
if (is_string($translation)) {
$translation = array($selected_language => $translated);
$translation = array($this->getBaseLanguage() => $translation);
} elseif (!is_array($translation)) {
throw new Exception("Inline translation should be string or array. Is " . gettype($translation) . " now!");
}
......
<?php $this->includeAtTemplateBase('includes/header.php'); ?>
<?php
//array('SP'=>
$this->includeLanguageFile('consent.php');
$this->includeInlineTranslation('spname', $this->data['sp_name']);
//$this->includeInlineTranslation('spdescription', $this->data['description']);
<?php
$this->includeAtTemplateBase('includes/header.php');
$this->includeLanguageFile('consent.php');
$this->includeInlineTranslation('spname', $this->data['sp_name']);
?>
<div id="content">
[default]
<p><?php echo htmlspecialchars($this->t('consent_notice')); ?> <strong><?php echo htmlspecialchars($this->t('spname', false, true) ); ?></strong>.
<p><?php echo htmlspecialchars($this->t('consent_notice')); ?> <strong><?php echo htmlspecialchars($this->t('spname')); ?></strong>.
<?php echo htmlspecialchars($this->t('consent_accept')) ?>
</p>
<form action="<?php echo htmlspecialchars($this->data['consenturl']); ?>">
<form style="display: inline" action="<?php echo htmlspecialchars($this->data['consenturl']); ?>">
<input type="submit" value="<?php echo htmlspecialchars($this->t('yes')) ?>" />
<input type="hidden" name="consent" value="<?php echo htmlspecialchars($this->data['consent_cookie']); ?>" />
<input type="hidden" name="RequestID" value="<?php echo htmlspecialchars($this->data['requestid']); ?>" />
......@@ -20,14 +19,11 @@
<input type="checkbox" name="saveconsent" id="saveconsent" value="1" /> <?php echo htmlspecialchars($this->t('remember')) ?>
<?php } ?>
</form>
<form action="<?php echo htmlspecialchars($this->data['noconsent']); ?>" method="GET">
<form style="display: inline; margin-left: .5em;" action="<?php echo htmlspecialchars($this->data['noconsent']); ?>" method="GET">
<input type="submit" value="<?php echo htmlspecialchars($this->t('no')) ?>" />
</form>
<table style="font-size: x-small">
<?php
$attributes = $this->data['attributes'];
......
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