From 394c05a4dca13c85c788cc56b7585bf3a67cdee2 Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Fri, 5 Feb 2016 18:04:19 +0100
Subject: [PATCH] Fix the calls to the old getTranslation() and
 getAttributeTranslation() methods from SimpleSAML_XHTML_Template.

---
 modules/consent/templates/consentform.php        |  2 +-
 modules/consentAdmin/templates/consentadmin.php  |  2 +-
 .../core/templates/frontpage_federation.tpl.php  | 16 ++++++++++------
 modules/core/templates/logout-iframe.php         |  4 ++--
 modules/discopower/templates/disco-tpl.php       |  4 ++--
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php
index cb6eb4ff6..d32a1a128 100644
--- a/modules/consent/templates/consentform.php
+++ b/modules/consent/templates/consentform.php
@@ -72,7 +72,7 @@ if (array_key_exists('descr_purpose', $this->data['dstMetadata'])) {
         '{consent:consent:consent_purpose}',
         array(
             'SPNAME' => $dstName,
-            'SPDESC' => $this->getTranslation(
+            'SPDESC' => $this->getTranslator()->getPreferredTranslation(
                 SimpleSAML\Utils\Arrays::arrayize(
                     $this->data['dstMetadata']['descr_purpose'],
                     'en'
diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php
index 2ca91e568..015c44e28 100644
--- a/modules/consentAdmin/templates/consentadmin.php
+++ b/modules/consentAdmin/templates/consentadmin.php
@@ -101,7 +101,7 @@ TRSTART;
 				if (isset($this->data['attribute_' . htmlspecialchars(strtolower($name)) ])) {
 				  $name = $this->data['attribute_' . htmlspecialchars(strtolower($name))];
 				}
-				$name = $this->getAttributeTranslation($name); // translate
+				$name = $this->getTranslator()->getAttributeTranslation($name); // translate
 				if (sizeof($value) > 1) {
 						echo "<li>" . htmlspecialchars($name) . ":\n<ul>\n";
 						foreach ($value AS $v) {
diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php
index c4e18d247..d69843206 100644
--- a/modules/core/templates/frontpage_federation.tpl.php
+++ b/modules/core/templates/frontpage_federation.tpl.php
@@ -54,11 +54,13 @@ if (is_array($this->data['metaentries']['hosted']) && count($this->data['metaent
             echo '<br />Index: '.$hm['metadata-index'];
         }
         if (!empty($hm['name'])) {
-            echo '<br /><strong>'.$this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['name'], 'en')).
+            echo '<br /><strong>'.
+                $this->getTranslator()->getPreferredTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['name'], 'en')).
                 '</strong>';
         }
         if (!empty($hm['descr'])) {
-            echo '<br /><strong>'.$this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['descr'], 'en')).
+            echo '<br /><strong>'.
+                $this->getTranslator()->getPreferredTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['descr'], 'en')).
                 '</strong>';
         }
 
@@ -84,11 +86,13 @@ if (is_array($this->data['metaentries']['remote']) && count($this->data['metaent
                     )
                 ).'">');
             if (!empty($entry['name'])) {
-                echo htmlspecialchars($this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($entry['name'], 'en')));
+                echo htmlspecialchars($this->getTranslator()->getPreferredTranslation(
+                    SimpleSAML\Utils\Arrays::arrayize($entry['name'], 'en')
+                ));
             } elseif (!empty($entry['OrganizationDisplayName'])) {
-                echo htmlspecialchars(
-                    $this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($entry['OrganizationDisplayName'], 'en'))
-                );
+                echo htmlspecialchars($this->getTranslator()->getPreferredTranslation(
+                    SimpleSAML\Utils\Arrays::arrayize($entry['OrganizationDisplayName'], 'en')
+                ));
             } else {
                 echo htmlspecialchars($entry['entityid']);
             }
diff --git a/modules/core/templates/logout-iframe.php b/modules/core/templates/logout-iframe.php
index e6d041e6c..e71c2f266 100644
--- a/modules/core/templates/logout-iframe.php
+++ b/modules/core/templates/logout-iframe.php
@@ -42,7 +42,7 @@ foreach ($SPs as $assocId => $sp) {
 }
 
 if ($from !== NULL) {
-	$from = $this->getTranslation($from);
+	$from = $this->getTranslator()->getPreferredTranslation($from);
 }
 
 
@@ -99,7 +99,7 @@ echo '<table id="slostatustable">';
 
 foreach ($SPs AS $assocId => $sp) {
 	if (isset($sp['core:Logout-IFrame:Name'])) {
-		$spName = $this->getTranslation($sp['core:Logout-IFrame:Name']);
+		$spName = $this->getTranslator()->getPreferredTranslation($sp['core:Logout-IFrame:Name']);
 	} else {
 		$spName = $assocId;
 	}
diff --git a/modules/discopower/templates/disco-tpl.php b/modules/discopower/templates/disco-tpl.php
index 752badc74..8f1e4e279 100644
--- a/modules/discopower/templates/disco-tpl.php
+++ b/modules/discopower/templates/disco-tpl.php
@@ -84,13 +84,13 @@ function getTranslatedName($t, $metadata) {
 		$displayName = $metadata['UIInfo']['DisplayName'];
 		assert('is_array($displayName)'); // Should always be an array of language code -> translation
 		if (!empty($displayName)) {
-			return $t->getTranslation($displayName);
+			return $t->getTranslator()->getPreferredTranslation($displayName);
 		}
 	}
 
 	if (array_key_exists('name', $metadata)) {
 		if (is_array($metadata['name'])) {
-			return $t->getTranslation($metadata['name']);
+			return $t->getTranslator()->getPreferredTranslation($metadata['name']);
 		} else {
 			return $metadata['name'];
 		}
-- 
GitLab