From 88d277816aaa4c402e45d9fb3e3520e67c0f3c64 Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <thijs@kinkhorst.com>
Date: Mon, 16 Mar 2020 13:56:22 +0000
Subject: [PATCH] Unbreak frontpage_core & simplify

---
 modules/core/locales/en/LC_MESSAGES/core.po  |  6 +++---
 modules/core/locales/es/LC_MESSAGES/core.po  |  6 +++---
 modules/core/locales/ja/LC_MESSAGES/core.po  |  2 +-
 modules/core/locales/nl/LC_MESSAGES/core.po  |  6 +++---
 modules/core/templates/frontpage_config.twig |  2 +-
 modules/core/www/frontpage_config.php        | 14 ++------------
 6 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/modules/core/locales/en/LC_MESSAGES/core.po b/modules/core/locales/en/LC_MESSAGES/core.po
index 6abe03ef7..c91dfeb71 100644
--- a/modules/core/locales/en/LC_MESSAGES/core.po
+++ b/modules/core/locales/en/LC_MESSAGES/core.po
@@ -158,7 +158,7 @@ msgstr "Delete my choices of IdP in the IdP discovery services"
 msgid "{core:frontpage:warnings_outdated}"
 msgstr ""
 "You are running an outdated version of SimpleSAMLphp. Please update to <a"
-" href=\"%LATEST_URL%\">the latest version</a> as soon as possible."
+" href=\"https://simplesamlphp.org/download\">the latest version</a> as soon as possible."
 
 msgid "{core:frontpage:loggedin_as_admin}"
 msgstr "You are logged in as administrator"
@@ -365,10 +365,10 @@ msgstr "PHP cURL extension missing. Cannot check for SimpleSAMLphp updates."
 
 msgid ""
 "You are running an outdated version of SimpleSAMLphp. Please update to <a"
-" href=\"%LATEST_URL%\">the latest version</a> as soon as possible."
+" href=\"https://simplesamlphp.org/download\">the latest version</a> as soon as possible."
 msgstr ""
 "You are running an outdated version of SimpleSAMLphp. Please update to <a"
-" href=\"%LATEST_URL%\">the latest version</a> as soon as possible."
+" href=\"https://simplesamlphp.org/download\">the latest version</a> as soon as possible."
 
 msgid "Metadata not found"
 msgstr "Metadata not found"
diff --git a/modules/core/locales/es/LC_MESSAGES/core.po b/modules/core/locales/es/LC_MESSAGES/core.po
index 4950c2496..212de1a03 100644
--- a/modules/core/locales/es/LC_MESSAGES/core.po
+++ b/modules/core/locales/es/LC_MESSAGES/core.po
@@ -132,7 +132,7 @@ msgstr "Borrar mis opciones de IdP en los servicios de descubrimiento de IdP"
 msgid "{core:frontpage:warnings_outdated}"
 msgstr ""
 "Su instalaci&oacute;n de SimpleSAMLphp est&aacute; desactualizada. Por "
-"favor, actualice a la <a href=\"%LATEST_URL%\">&uacute;ltima "
+"favor, actualice a la <a href=\"https://simplesamlphp.org/download\">&uacute;ltima "
 "versi&oacute;n</a> lo antes posible."
 
 msgid "{core:frontpage:loggedin_as_admin}"
@@ -341,10 +341,10 @@ msgstr "Usando los botones atrás y adelante de su navegador web."
 
 msgid ""
 "You are running an outdated version of SimpleSAMLphp. Please update to <a"
-" href=\"%LATEST_URL%\">the latest version</a> as soon as possible."
+" href=\"https://simplesamlphp.org/download\">the latest version</a> as soon as possible."
 msgstr ""
 "Su instalaci&oacute;n de SimpleSAMLphp est&aacute; desactualizada. Por "
-"favor, actualice a la <a href=\"%LATEST_URL%\">&uacute;ltima "
+"favor, actualice a la <a href=\"https://simplesamlphp.org/download\">&uacute;ltima "
 "versi&oacute;n</a> lo antes posible."
 
 msgid "Metadata not found"
diff --git a/modules/core/locales/ja/LC_MESSAGES/core.po b/modules/core/locales/ja/LC_MESSAGES/core.po
index d9f42d940..dab892ab3 100644
--- a/modules/core/locales/ja/LC_MESSAGES/core.po
+++ b/modules/core/locales/ja/LC_MESSAGES/core.po
@@ -150,7 +150,7 @@ msgid "{core:frontpage:link_cleardiscochoices}"
 msgstr "IdPディスカバリサービス内のIdPの選択を削除"
 
 msgid "{core:frontpage:warnings_outdated}"
-msgstr "旧バージョンのSimpleSAMLphpが使われています。できるだけ早く<a href=\"%LATEST_URL%\">最新バーション</a>にアップロードしてください"
+msgstr "旧バージョンのSimpleSAMLphpが使われています。できるだけ早く<a href=\"https://simplesamlphp.org/download\">最新バーション</a>にアップロードしてください"
 
 msgid "{core:frontpage:loggedin_as_admin}"
 msgstr "管理者でログインしています"
diff --git a/modules/core/locales/nl/LC_MESSAGES/core.po b/modules/core/locales/nl/LC_MESSAGES/core.po
index be8f20c20..7f1435515 100644
--- a/modules/core/locales/nl/LC_MESSAGES/core.po
+++ b/modules/core/locales/nl/LC_MESSAGES/core.po
@@ -134,7 +134,7 @@ msgstr "Verwijder IDP keuzes uit de IdP discovery service"
 msgid "{core:frontpage:warnings_outdated}"
 msgstr ""
 "Deze installatie van SimpleSAMLphp is verouderd. Het is aan te raden zo "
-"snel mogelijk te upgraden naar <a href=\"%LATEST_URL%\">de meest recente "
+"snel mogelijk te upgraden naar <a href=\"https://simplesamlphp.org/download\">de meest recente "
 "versie</a>."
 
 msgid "{core:frontpage:warnings_curlmissing}"
@@ -349,10 +349,10 @@ msgstr "Gebruik van de 'Volgende'- en 'Terug'-knoppen in de web browser."
 
 msgid ""
 "You are running an outdated version of SimpleSAMLphp. Please update to <a"
-" href=\"%LATEST_URL%\">the latest version</a> as soon as possible."
+" href=\"https://simplesamlphp.org/download\">the latest version</a> as soon as possible."
 msgstr ""
 "Deze installatie van SimpleSAMLphp is verouderd. Het is aan te raden zo "
-"snel mogelijk te upgraden naar <a href=\"%LATEST_URL%\">de meest recente "
+"snel mogelijk te upgraden naar <a href=\"https://simplesamlphp.org/download\">de meest recente "
 "versie</a>."
 
 msgid "Metadata not found"
diff --git a/modules/core/templates/frontpage_config.twig b/modules/core/templates/frontpage_config.twig
index 74ac7c8a5..bdfe93574 100644
--- a/modules/core/templates/frontpage_config.twig
+++ b/modules/core/templates/frontpage_config.twig
@@ -31,7 +31,7 @@
     {% if warnings is defined and warnings is not empty %}
     <h2>{{ '{core:frontpage:warnings}'|trans|escape('html') }}</h2>
     {% for key, warning in warnings %}
-    <div class="caution">{{ warning|raw }}</div>
+    <div class="caution">{{ warning|trans|raw }}</div>
     {% endfor %}
     {% endif %}
 
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index bfd2cf6ad..d53256465 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -85,10 +85,7 @@ if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master')
 
         if ($latest && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) {
             $outdated = true;
-            $warnings[] = [
-                '{core:frontpage:warnings_outdated}',
-                ['%LATEST_URL%' => $latest['html_url']]
-            ];
+            $warnings[] = '{core:frontpage:warnings_outdated}';
         }
     }
 }
@@ -167,18 +164,11 @@ $funcmatrix[] = [
 $t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_config.twig');
 $translator = $t->getTranslator();
 $t->data['pageid'] = 'frontpage_config';
-$t->data['header'] = $translator->t('{core:frontpage:page_title}');
+$t->data['header'] = '{core:frontpage:page_title}';
 $t->data['isadmin'] = $isadmin;
 $t->data['loginurl'] = $loginurl;
 $t->data['logouturl'] = $logouturl;
 
-foreach ($warnings as &$warning) {
-    if (is_array($warning)) {
-        $warning = $translator->t($warning[0], $warning[1]);
-    } else {
-        $warning = $translator->t($warning);
-    }
-}
 $t->data['warnings'] = $warnings;
 
 
-- 
GitLab