Skip to content
Snippets Groups Projects
Commit 9ab7a518 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

Make use of entityDisplayName twig filter

parent 13992b16
No related branches found
No related tags found
No related merge requests found
...@@ -149,29 +149,6 @@ class Federation ...@@ -149,29 +149,6 @@ class Federation
} }
} }
$translators = [
'name' => 'name_translated',
'descr' => 'descr_translated',
'OrganizationDisplayName' => 'organizationdisplayname_translated',
];
foreach ($entries['remote'] as $key => $set) {
foreach ($set as $entityid => $entity) {
foreach ($translators as $old => $new) {
if (isset($entity[$old][$language])) {
$entries['remote'][$key][$entityid][$new] = $entity[$old][$language];
} elseif (isset($entity[$old][$defaultLang])) {
$entries['remote'][$key][$entityid][$new] = $entity[$old][$defaultLang];
} elseif (isset($entity[$old]['en'])) {
$entries['remote'][$key][$entityid][$new] = $entity[$old]['en'];
} elseif (isset($entries['remote'][$key][$entityid][$old])) {
$old_entry = $entries['remote'][$key][$entityid][$old];
$entries['remote'][$key][$entityid][$new] = is_array($old_entry) ? $entityid : $old_entry;
}
}
}
}
$t->data = [ $t->data = [
'links' => [ 'links' => [
[ [
......
...@@ -16,10 +16,7 @@ ...@@ -16,10 +16,7 @@
{%- block general %} {%- block general %}
<dl> <dl>
{%- if set.name is defined %} <dt>{{ set|entityDisplayName }}</dt>
<dt>{{ set.name|translateFromArray }}</dt>
{%- endif %}
<dd>EntityID: <code>{{ set.entityid }}</code></dd> <dd>EntityID: <code>{{ set.entityid }}</code></dd>
{%- if set.deprecated is defined and set.deprecated %} {%- if set.deprecated is defined and set.deprecated %}
...@@ -105,16 +102,7 @@ ...@@ -105,16 +102,7 @@
{% for entityid, entity in set %} {% for entityid, entity in set %}
<li><a href="{{ moduleURL('admin/federation/show?entityid=' ~ (entity.entityid|url_encode) ~ '&set=' ~ key) }}"> <li><a href="{{ moduleURL('admin/federation/show?entityid=' ~ (entity.entityid|url_encode) ~ '&set=' ~ key) }}">
{%- if entity.name_translated is defined -%} {{ entity | entityDisplayName }}
{{ entity.name_translated }}
{%- elseif entity.organizationdisplayname_translated is defined -%}
{{ entity.organizationdisplayname_translated }}
{%- else -%}
{{ entity.entityid|escape('html') }}
{%- endif -%}
</a> </a>
{% if entity.expire is defined %} {% if entity.expire is defined %}
{% if entity.expire < date().timestamp %} {% if entity.expire < date().timestamp %}
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
{% block content %} {% block content %}
<h2>{{ 'Invalid Identity Provider'|trans }}</h2> <h2>{{ 'Invalid Identity Provider'|trans }}</h2>
<p>{{ 'You already have a valid session with an identity provider (<em>%IDP%</em>) that is not accepted by <em>%SP%</em>. Would you like to log out from your existing session and log in again with another identity provider?'|trans({"%IDP%": idp_name|translateFromArray|default(idp_entityid), "%SP%": sp_name|translateFromArray|default(sp_entityid)}, "app")|raw</p> <p>{{ 'You already have a valid session with an identity provider (<em>%IDP%</em>) that is not accepted by <em>%SP%</em>. Would you like to log out from your existing session and log in again with another identity provider?'|trans({"%IDP%": entity_idp|entityDiplayName, "%SP%": entity_sp|entityDisplayName}, "app")|raw</p>
<form method="post" action="?"> <form method="post" action="?">
<input type="hidden" name="AuthState" value="{{ AuthState|escape('html') }}" /> <input type="hidden" name="AuthState" value="{{ AuthState|escape('html') }}">
<input type="submit" name="continue" value="{{ 'Yes, continue'|trans }}" /> <input type="submit" name="continue" value="{{ 'Yes, continue'|trans }}">
<input type="submit" name="cancel" value="{{ 'No, cancel'|trans }}" /> <input type="submit" name="cancel" value="{{ 'No, cancel'|trans }}">
</form> </form>
{% endblock %} {% endblock %}
...@@ -48,27 +48,11 @@ if (isset($_POST['continue'])) { ...@@ -48,27 +48,11 @@ if (isset($_POST['continue'])) {
$cfg = \SimpleSAML\Configuration::getInstance(); $cfg = \SimpleSAML\Configuration::getInstance();
$template = new \SimpleSAML\XHTML\Template($cfg, 'saml:proxy/invalid_session.twig'); $template = new \SimpleSAML\XHTML\Template($cfg, 'saml:proxy/invalid_session.twig');
$translator = $template->getTranslator();
$template->data['AuthState'] = (string) $_REQUEST['AuthState']; $template->data['AuthState'] = (string) $_REQUEST['AuthState'];
// get the name of the IdP
$idpmdcfg = $state['saml:sp:IdPMetadata']; $idpmdcfg = $state['saml:sp:IdPMetadata'];
/** @var \SimpleSAML\Configuration $idpmdcfg */ /** @var \SimpleSAML\Configuration $idpmdcfg */
$idpmd = $idpmdcfg->toArray(); $template->data['entity_idp'] = $idpmdcfg->toArray();
if (array_key_exists('name', $idpmd)) { $template->data['entity_sp'] = $state['SPMetadata'];
$template->data['idp_name'] = $idpmd['name'];
} elseif (array_key_exists('OrganizationDisplayName', $idpmd)) {
$template->data['idp_name'] = $idpmd['OrganizationDisplayName'];
}
$template->data['idp_entityid'] = $idpmd['entityid'];
// get the name of the SP
$spmd = $state['SPMetadata'];
if (array_key_exists('name', $spmd)) {
$template->data['sp_name'] = $spmd['name'];
} elseif (array_key_exists('OrganizationDisplayName', $spmd)) {
$template->data['sp_name'] = $spmd['OrganizationDisplayName'];
}
$template->data['sp_entityid'] = $spmd['entityid'];
$template->send(); $template->send();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment