From 06dafa3c52065cf1d974694c43b3c227c7700c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Wed, 11 Jun 2008 10:08:37 +0000 Subject: [PATCH] Fix consent module to accept not translated service names git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@631 44740490-163a-0410-bde0-09ae8108e29a --- docs/source/simplesamlphp-idp.xml | 2 +- docs/source/simplesamlphp-maintenance.xml | 2 +- docs/source/simplesamlphp-sp.xml | 18 +++++++++--------- lib/SimpleSAML/XHTML/Template.php | 20 ++++++++++++++------ templates/default/consent.php | 22 +++++++++------------- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/docs/source/simplesamlphp-idp.xml b/docs/source/simplesamlphp-idp.xml index 689f26b4a..768fec9d6 100644 --- a/docs/source/simplesamlphp-idp.xml +++ b/docs/source/simplesamlphp-idp.xml @@ -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> diff --git a/docs/source/simplesamlphp-maintenance.xml b/docs/source/simplesamlphp-maintenance.xml index 0ec33a19f..c1643be38 100644 --- a/docs/source/simplesamlphp-maintenance.xml +++ b/docs/source/simplesamlphp-maintenance.xml @@ -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> diff --git a/docs/source/simplesamlphp-sp.xml b/docs/source/simplesamlphp-sp.xml index b17a1eaeb..d3860e892 100644 --- a/docs/source/simplesamlphp-sp.xml +++ b/docs/source/simplesamlphp-sp.xml @@ -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><simpleSAMLphp-root>/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> diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 2d8bc1f1a..20e34788e 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -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!"); } diff --git a/templates/default/consent.php b/templates/default/consent.php index db4284a79..8ef0ebbc6 100644 --- a/templates/default/consent.php +++ b/templates/default/consent.php @@ -1,18 +1,17 @@ -<?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']; -- GitLab