Skip to content
Snippets Groups Projects
Commit dd5e8e5a authored by Olimpia Magliulo's avatar Olimpia Magliulo
Browse files

Merge branch 'Xnew-ui' of https://github.com/simplesamlphp/simplesamlphp into Xnew-ui

parents 004749f7 bd16880c
No related branches found
No related tags found
No related merge requests found
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
*/ */
class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
{ {
/** /**
* The configuration for this instance. * The configuration for this instance.
* *
...@@ -127,7 +125,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco ...@@ -127,7 +125,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
$tags = $val['tags']; $tags = $val['tags'];
} }
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (!empty($enableTabs) && !in_array($tag, $enableTabs, true)) { if (!empty($enableTabs) && !in_array($tag, $enableTabs)) {
continue; continue;
} }
$slist[$tag][$key] = $val; $slist[$tag][$key] = $val;
...@@ -153,21 +151,21 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco ...@@ -153,21 +151,21 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
*/ */
private function processFilter($filter, $entry, $default = true) private function processFilter($filter, $entry, $default = true)
{ {
if (in_array($entry['entityid'], $filter['entities.include'], true)) { if (in_array($entry['entityid'], $filter['entities.include'])) {
return true; return true;
} }
if (in_array($entry['entityid'], $filter['entities.exclude'], true)) { if (in_array($entry['entityid'], $filter['entities.exclude'])) {
return false; return false;
} }
if (array_key_exists('tags', $entry)) { if (array_key_exists('tags', $entry)) {
foreach ($filter['tags.include'] as $fe) { foreach ($filter['tags.include'] as $fe) {
if (in_array($fe, $entry['tags'], true)) { if (in_array($fe, $entry['tags'])) {
return true; return true;
} }
} }
foreach ($filter['tags.exclude'] as $fe) { foreach ($filter['tags.exclude'] as $fe) {
if (in_array($fe, $entry['tags'], true)) { if (in_array($fe, $entry['tags'])) {
return false; return false;
} }
} }
...@@ -246,12 +244,6 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco ...@@ -246,12 +244,6 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
$idpList = $this->getIdPList(); $idpList = $this->getIdPList();
$idpList = $this->idplistStructured($this->filterList($idpList)); $idpList = $this->idplistStructured($this->filterList($idpList));
$preferredIdP = $this->getRecommendedIdP(); $preferredIdP = $this->getRecommendedIdP();
$faventry = NULL;
foreach ($idpList AS $tab => $slist) {
if (!empty($preferredIdP) && array_key_exists($preferredIdP, $slist)) {
$faventry = $slist[$preferredIdP];
}
}
$t = new SimpleSAML_XHTML_Template($this->config, 'discopower:disco.tpl.php', 'disco'); $t = new SimpleSAML_XHTML_Template($this->config, 'discopower:disco.tpl.php', 'disco');
$discoPowerTabs = array( $discoPowerTabs = array(
...@@ -269,21 +261,104 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco ...@@ -269,21 +261,104 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
'switzerland' => $t->noop('{discopower:tabs:switzerland}'), 'switzerland' => $t->noop('{discopower:tabs:switzerland}'),
'ukacessfederation' => $t->noop('{discopower:tabs:ukacessfederation}'), 'ukacessfederation' => $t->noop('{discopower:tabs:ukacessfederation}'),
); );
$t->data['faventry'] = $faventry;
$t->data['tabNames'] = $discoPowerTabs;
$t->data['idplist'] = $idpList;
$t->data['preferredidp'] = $preferredIdP;
$t->data['return'] = $this->returnURL; $t->data['return'] = $this->returnURL;
$t->data['returnIDParam'] = $this->returnIdParam; $t->data['returnIDParam'] = $this->returnIdParam;
$t->data['entityID'] = $this->spEntityId; $t->data['entityID'] = $this->spEntityId;
$t->data['defaulttab'] = $this->discoconfig->getValue('defaulttab', 0);
$idpList = $this->processMetadata($t, $idpList, $preferredIdP);
$t->data['idplist'] = $idpList;
$faventry = null;
foreach ($idpList as $tab => $slist) {
if (!empty($preferredIdP) && array_key_exists($preferredIdP, $slist)) {
$t->data['faventry'] = $slist[$preferredIdP];
break;
}
}
if (!empty($this->data['faventry'])) {
$this->data['autofocus'] = 'favouritesubmit';
}
$search = '<script type="text/javascript">
$(document).ready(function() {
$("#tabdiv").tabs({ selected: ' . $t->data['defaulttab'] . ' });';
$i = 0;
foreach ($idpList as $tab => $slist) {
$search .= "\n" . '$("#query_' . $tab . '").liveUpdate("#list_' . $tab . '")' .
(($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '') . ';';
}
$search .= "});\n</script>";
$t->data['search'] = $search;
$t->data['score'] = $this->discoconfig->getValue('score', 'quicksilver');
$t->data['tabNames'] = $discoPowerTabs;
$t->data['preferredidp'] = $preferredIdP;
$t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); $t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
$t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', false); $t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', false);
$t->data['rememberchecked'] = $this->config->getBoolean('idpdisco.rememberchecked', false); $t->data['rememberchecked'] = $this->config->getBoolean('idpdisco.rememberchecked', false);
$t->data['defaulttab'] = $this->discoconfig->getValue('defaulttab', 0); $t->data['jquery'] = array('core' => true, 'ui' => true);
$t->data['score'] = $this->discoconfig->getValue('score', 'quicksilver');
$t->show(); $t->show();
} }
private function processMetadata($t, $metadata, $favourite)
{
$basequerystring = '?' .
'entityID=' . urlencode($t->data['entityID']) . '&amp;' .
'return=' . urlencode($t->data['return']) . '&amp;' .
'returnIDParam=' . urlencode($t->data['returnIDParam']) . '&amp;idpentityid=';
foreach ($metadata as $tab => $idps) {
foreach ($idps as $entityid => $entity) {
$translation = false;
// Translate name
if (isset($entity['UIInfo']['DisplayName'])) {
$displayName = $entity['UIInfo']['DisplayName'];
// Should always be an array of language code -> translation
assert(is_array($displayName));
if (!empty($displayName)) {
$translation = $t->getTranslator()->getPreferredTranslation($displayName);
}
}
if ((translation === false) && array_key_exists('name', $entity)) {
if (is_array($entity['name'])) {
$translation = $t->getTranslator()->getPreferredTranslation($entity['name']);
} else {
$translation = $entity['name'];
}
}
if ($translation === false) {
$translation = $entity['entityid'];
}
$entity['translated'] = $translation;
// HTML output
if ($entity['entityid'] === $favourite) {
$html = '<a class="metaentry favourite" href="' . $basequerystring . urlencode($entity['entityid']) . '">';
} else {
$html = '<a class="metaentry" href="' . $basequerystring . urlencode($entity['entityid']) . '">';
}
$html .= $entity['translated'];
if (array_key_exists('icon', $entity) && $entity['icon'] !== null) {
$iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($entity['icon']);
$html .= '<img alt="Icon for identity provider" class="entryicon" src="' . htmlspecialchars($iconUrl) . '" />';
}
$html .= '</a>';
$entity['html'] = $html;
// Save processed data
$metadata[$tab][$entityid] = $entity;
}
}
return $metadata;
}
/** /**
* Get the IdP entities saved in the common domain cookie. * Get the IdP entities saved in the common domain cookie.
...@@ -319,7 +394,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco ...@@ -319,7 +394,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco
*/ */
protected function setPreviousIdP($idp) protected function setPreviousIdP($idp)
{ {
assert(is_string($idp)); assert('is_string($idp)');
if ($this->cdcDomain === null) { if ($this->cdcDomain === null) {
parent::setPreviousIdP($idp); parent::setPreviousIdP($idp);
......
...@@ -8,28 +8,8 @@ $this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE); ...@@ -8,28 +8,8 @@ $this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE);
$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('discopower/style.css') . '" />'; $this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('discopower/style.css') . '" />';
$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/jquery.livesearch.js') . '"></script>'; $this->data['post'] = '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/jquery.livesearch.js') . '"></script>';
$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/' . $this->data['score'] . '.js') . '"></script>'; $this->data['post'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/quicksilver.js') . '"></script>';
$this->data['head'] .= '<script type="text/javascript">
$(document).ready(function() {
$("#discotabs").tabs({ selected: ' . $this->data['defaulttab'] . ' }); ';
$i = 0;
foreach ($this->data['idplist'] AS $tab => $slist) {
$this->data['head'] .= "\n" . '$("#query_' . $tab . '").liveUpdate("#list_' . $tab . '")' .
(($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '') .
';';
}
$this->data['head'] .= '
});
</script>';
...@@ -70,7 +50,7 @@ function showEntry($t, $metadata, $favourite = FALSE) { ...@@ -70,7 +50,7 @@ function showEntry($t, $metadata, $favourite = FALSE) {
function getTranslatedName($t, $metadata) { function getTranslatedName($t, $metadata) {
if (isset($metadata['UIInfo']['DisplayName'])) { if (isset($metadata['UIInfo']['DisplayName'])) {
$displayName = $metadata['UIInfo']['DisplayName']; $displayName = $metadata['UIInfo']['DisplayName'];
assert(is_array($displayName)); // Should always be an array of language code -> translation assert('is_array($displayName)'); // Should always be an array of language code -> translation
if (!empty($displayName)) { if (!empty($displayName)) {
return $t->getTranslator()->getPreferredTranslation($displayName); return $t->getTranslator()->getPreferredTranslation($displayName);
} }
...@@ -116,15 +96,21 @@ if (!empty($this->data['faventry'])) { ...@@ -116,15 +96,21 @@ if (!empty($this->data['faventry'])) {
<div id="discotabs"> <div id="tabdiv">
<ul class="tabset_tabs"> <ul class="tabset_tabs">
<?php <?php
$tabs = array_keys( $this->data['idplist']); $tabs = array_keys( $this->data['idplist']);
$i = 1;
foreach ($tabs AS $tab) { foreach ($tabs AS $tab) {
if(!empty($this->data['idplist'][$tab])) { if(!empty($this->data['idplist'][$tab])) {
echo '<li><a href="#' . $tab . '"><span>' . $this->t($this->data['tabNames'][$tab]) . '</span></a></li> '; if ($i === 1) {
echo '<li class="tab-link current" data-tab="'.$tab.'"><a href="#' . $tab . '"><span>' . $this->t($this->data['tabNames'][$tab]) . '</span></a></li>';
} else {
echo '<li class="tab-link" data-tab="'.$tab.'"><a href="#' . $tab . '"><span>' . $this->t($this->data['tabNames'][$tab]) . '</span></a></li> ';
}
$i++;
} }
} }
...@@ -138,14 +124,17 @@ if (!empty($this->data['faventry'])) { ...@@ -138,14 +124,17 @@ if (!empty($this->data['faventry'])) {
foreach( $this->data['idplist'] AS $tab => $slist) { foreach( $this->data['idplist'] AS $tab => $slist) {
$first = array_keys($this->data['idplist']);
echo '<div id="' . $tab . '">'; if ($first[0] === $tab) {
echo '<div id="' . $tab . '" class="tabset_content current">';
} else {
echo '<div id="' . $tab . '" class="tabset_content">';
}
if (!empty($slist)) { if (!empty($slist)) {
echo(' <div class="inlinesearch">'); echo(' <div class="inlinesearch">');
echo(' <p>Incremental search...</p>'); echo(' <p>Incremental search...</p>');
echo(' <form id="idpselectform" action="?" method="get"><input class="inlinesearchf" type="text" value="" name="query_' . $tab . '" id="query_' . $tab . '" /></form>'); echo(' <form id="idpselectform" action="?" method="get"><input class="inlinesearch" type="text" value="" name="query_' . $tab . '" id="query_' . $tab . '" /></form>');
echo(' </div>'); echo(' </div>');
echo(' <div class="metalist" id="list_' . $tab . '">'); echo(' <div class="metalist" id="list_' . $tab . '">');
...@@ -171,5 +160,22 @@ foreach( $this->data['idplist'] AS $tab => $slist) { ...@@ -171,5 +160,22 @@ foreach( $this->data['idplist'] AS $tab => $slist) {
</div> </div>
<script type="text/javascript">
<?php $this->includeAtTemplateBase('includes/footer.php'); $(document).ready(function() {
<?php
$i = 0;
foreach ($this->data['idplist'] AS $tab => $slist) {
echo "\n" . '$("#query_' . $tab . '").liveUpdate("#list_' . $tab . '")' .
(($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '') .
';';
}
?>
});
</script>
<?php
$this->data['post'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/javascript.js') . '"></script>';
$this->includeAtTemplateBase('includes/footer.php');
{% set pagetitle = 'selectidp'|trans %}
{% extends "base.twig" %}
{% block preload %}
<link href="{{ baseurlpath }}style.css" rel="stylesheet" type="text/css" media="screen" />
{% endblock %}
{% block postload %}
<script type="text/javascript" src="{{ baseurlpath }}js/jquery.livesearch.js"></script>
<script type="text/javascript" src="{{ baseurlpath }}js/{{ score }}.js"></script>
{{ search|raw }}
{% endblock %}
{% block content %}
{% if faventry is not empty %}
<div class="favourite">{{ '{disco:previous_auth}'|trans }}
<strong>{{ faventry.translated|escape('html') }}</strong>
<form id="idpselectform" method="get" action="{{ urlpattern }}">
<input type="hidden" name="entityID" value="{{ entityID|escape('html') }}" />
<input type="hidden" name="return" value="{{ return|escape('html') }}" />
<input type="hidden" name="returnIDParam" value="{{ returnIDParam|escape('html') }}" />
<input type="hidden" name="idpentityid" value="{{ faventry.entityid|escape('html') }}" />
<input type="submit" name="formsubmit" id="favouritesubmit" value="{{ '{disco:login_at}'|trans }} {{ faventry.translated|escape('html') }}" />
</form>
</div>
{% endif %}
<div id="tabdiv">
<ul class="tabset_tabs">
{% set i = 1 %}
{% for tab, idps in idplist %}
{% if idps is not empty %}
{% if i == 1 %}
<li class="tab-link current" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li>
{% set i = 2 %}
{% else %}
<li class="tab-link" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
{% set i = 1 %}
{% for tab, idps in idplist %}
{% if idps is not empty %}
{% if i == 1 %}
<div id="{{ tab }}" class="tabset_content current">
{% set i = 2 %}
{% else %}
<div id="{{ tab }}" class="tabset_content">
{% endif %}
<div class="inlinesearch">
<p>Incremental search...</p>
<form id="idpselectform" method="get">
<input class="inlinesearch" type="text" value="" name="query_{{ tab }}" id="query_{{ tab }}" />
</form>
</div>
<div class="metalist" id="list_{{ tab }}">
{% for entityid, entity in idps %}
{{ entity.html|raw }}
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endblock %}
.inlinesearch:hover {
}
.inlinesearch { .inlinesearch {
float: right; float: right;
margin: 0em 3px .5em 1em; margin: 0em 3px .5em 1em;
/* padding: .3em;*/
} }
.inlinesearch p { .inlinesearch p {
font-size: 94%; font-size: 94%;
color: #aaa; color: #aaa;
} }
.inlinesearch input { .inlinesearch input {
background-image:url('../../resources/icons/silk/magnifier.png'); background-image:url('../../resources/icons/silk/magnifier.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center left; background-position:center left;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 2px 2px 2px 20px; padding: 2px 2px 2px 20px;
margin: 0px 2px 0px 0px; margin: 0px 2px 0px 0px;
} }
.inlinesearch * { .inlinesearch * {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
div.metalist { div.metalist {
clear: both; clear: both;
list-style: none; list-style: none;
margin: 1em 2px .5em 2px; margin: 1em 2px .5em 2px;
padding: 0px; padding: 0px;
} }
a.metaentry { a.metaentry {
display: block; display: block;
border: 1px solid #ccc; border: 1px solid #ccc;
margin: 0px 0px -1px 0px; margin: 0px 0px -1px 0px;
padding: .2em 1em .2em 20px; padding: .2em 1em .2em 20px;
cursor: pointer; cursor: pointer;
cursor: hand; cursor: hand;
} }
a.metaentry.favourite { a.metaentry.favourite {
background-image:url('../../resources/icons/silk/heart.png'); background-image:url('../../resources/icons/silk/heart.png');
background-repeat:no-repeat; background-repeat:no-repeat;
background-position:center left; background-position:center left;
} }
a.metaentry:hover { a.metaentry:hover {
border: 1px solid #ccc; border: 1px solid #ccc;
background: #eee; background: #eee;
background-image:url('../../resources/icons/silk/star.png');
background-image:url('../../resources/icons/silk/star.png'); background-repeat:no-repeat;
background-repeat:no-repeat; background-position:center left;
background-position:center left;
} }
a.metaentry img.entryicon { a.metaentry img.entryicon {
display: none; display: none;
} }
a.metaentry:hover img.entryicon { a.metaentry:hover img.entryicon {
display: inline; display: inline;
top: 0px; top: 0px;
bottom: 0px; bottom: 0px;
clear: both; clear: both;
float: right; float: right;
margin: 1em; margin: 1em;
padding: 3px; padding: 3px;
border: 1px solid #999; border: 1px solid #999;
} }
div.favourite { div.favourite {
margin: 1em 0px;
padding: 1em;
border: 1px solid #ccc;
background-color: #eee;
}
div#content {
margin: .4em ! important;
}
form {
display: inline;
}
margin: 1em 0px; table#statmeta {
padding: 1em; width: 100%;
border: 1px solid #ccc; }
background-color: #eee;
ul.tabset_tabs {
margin: 0px;
padding: 0px;
list-style: none;
}
ul.tabset_tabs li {
background: none;
color: #222;
display: inline-block;
padding: 10px 15px;
cursor: pointer;
}
ul.tabset_tabs li.current {
background: #ededed;
color: #222;
}
.tabset_content {
display: none;
background: #ededed;
padding: 15px;
}
.tabset_content.current {
display: inherit;
} }
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
</div> </div>
<!-- postload javascript --> <!-- postload javascript -->
<script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/jquery-3.2.1.min.js"></script>
{% spaceless %}{% if jquery %} {% spaceless %}{% if jquery %}
{% set version = '1.8' %} {% set version = '1.8' %}
{% if jquery.version %} {% if jquery.version %}
...@@ -48,7 +49,6 @@ ...@@ -48,7 +49,6 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}{% endspaceless -%} {% endif %}{% endspaceless -%}
<script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/clipboard.min.js"></script> <script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/clipboard.min.js"></script>
<script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/selectize.min.js"></script> <script type="text/javascript" src="/{{ baseurlpath }}assets/js/lib/selectize.min.js"></script>
<script type="text/javascript" src="/{{ baseurlpath }}assets/js/src/language.js"></script> <script type="text/javascript" src="/{{ baseurlpath }}assets/js/src/language.js"></script>
......
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