Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 7e01b08

Browse files
author
Dominik František Bučík
authored
Merge pull request #71 from pajavyskocil/DS_changes
Ds changes
2 parents c16c546 + f473509 commit 7e01b08

File tree

4 files changed

+124
-47
lines changed

4 files changed

+124
-47
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
#### Changed
6+
- Remove star which was shown on items on Discovery Service. Now the star will be shown only at previously selected IdP.
7+
- Change work with IdP entities with tags 'social' and 'preferred' on DS
8+
- Width of entities is now counted automatically
9+
- Social IdP has 'Sign in with' before name, Preferred IdP hasn't
10+
- Added possibility to change display name in attribute 'fullDisplayName' in metadata
11+
- If user's last selected IdP is known then show only this IdP and button to show all IdPs
12+
- Set autofocus on previously selected IdP if exist
13+
- Removed unused function showIcon() in disco-tpl.php
14+
515
#### Fixed
616
- Fixed the bug in 'getEntitylesAttribute' function to return correct value of Entityless attribute
717

dictionaries/disco.definition.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@
1515
"en": "your institutional account",
1616
"cs": "váš univerzitní účet"
1717
},
18+
"sign_with_other_institution": {
19+
"en": "Sign in using other institution",
20+
"cs": "Přihlásit se účtem jiné instituce"
21+
},
1822
"previous_selection": {
1923
"en": "your previous selection",
2024
"cs": "vaše předchozí volba"
2125
},
26+
"sign_in_with": {
27+
"en": "Sign in with ",
28+
"cs": "Přihlásit se pomocí "
29+
},
2230
"type_name_institution": {
2331
"en": "Type the name of your institution",
2432
"cs": "Zadejte název instituce"

themes/perun/perun/disco-tpl.php

Lines changed: 95 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
Module::getModuleUrl('discopower/assets/js/suggest.js') . '"></script>';
3030

3131
$this->data['head'] .= searchScript();
32+
$this->data['head'] .= showEntriesScript();
33+
$this->data['head'] .= setFocus();
3234

3335
const CONFIG_FILE_NAME = 'module_perun.php';
3436

@@ -121,33 +123,18 @@
121123
if (!$warningIsOn || $warningType === WARNING_TYPE_INFO || $warningType === WARNING_TYPE_WARNING) {
122124
if (!empty($this->getPreferredIdp())) {
123125
echo '<p class="descriptionp">' . $this->t('{perun:disco:previous_selection}') . '</p>';
124-
echo '<div class="metalist list-group">';
126+
echo '<div id="last-used-idp" class="metalist list-group">';
125127
echo showEntry($this, $this->getPreferredIdp(), true);
126128
echo '</div>';
127129

128-
129130
echo getOr();
130-
}
131131

132-
echo '<div class="row">';
133-
foreach ($this->getIdps('preferred') as $idpentry) {
134-
echo '<div class="col-md-4">';
135-
echo '<div class="metalist list-group">';
136-
echo showEntry($this, $idpentry, false);
137-
echo '</div>';
138-
echo '</div>';
132+
echo '<span id="showEntries" class="btn btn-block btn-default btn-lg">' .
133+
$this->t('{perun:disco:sign_with_other_institution}') .'</span>' ;
134+
echo '<div id="entries" style="display: none">';
139135
}
140-
echo '</div>';
141136

142-
echo '<div class="row">';
143-
foreach ($this->getIdps('social') as $idpentry) {
144-
echo '<div class="col-md-4">';
145-
echo '<div class="metalist list-group">';
146-
echo showEntry($this, $idpentry, false);
147-
echo '</div>';
148-
echo '</div>';
149-
}
150-
echo '</div>';
137+
echo showAllTaggedIdPs($this);
151138

152139
echo getOr();
153140

@@ -188,11 +175,29 @@
188175
$this->t('{perun:disco:add_institution}') .
189176
'</a>';
190177
}
178+
179+
if (!empty($this->getPreferredIdp())) {
180+
echo '</div>';
181+
}
182+
191183
echo '</div>';
192184
}
193185

194186
$this->includeAtTemplateBase('includes/footer.php');
195187

188+
function showEntriesScript()
189+
{
190+
$script = '<script type="text/javascript">
191+
$(document).ready(function() {
192+
$("#showEntries").click(function() {
193+
$("#entries").show();
194+
$("#showEntries").hide();
195+
});
196+
});
197+
</script>';
198+
return $script;
199+
}
200+
196201
function searchScript()
197202
{
198203

@@ -207,6 +212,21 @@ function searchScript()
207212
return $script;
208213
}
209214

215+
function setFocus()
216+
{
217+
$script = '<script type="text/javascript">
218+
219+
$(document).ready(function() {
220+
if ($("#last-used-idp")) {
221+
$("#last-used-idp .metaentry").focus();
222+
}
223+
});
224+
225+
</script>';
226+
227+
return $script;
228+
}
229+
210230
/**
211231
* @param DiscoTemplate $t
212232
* @param array $metadata
@@ -227,8 +247,6 @@ function showEntry($t, $metadata, $favourite = false)
227247

228248
$html .= '<strong>' . $t->getTranslatedEntityName($metadata) . '</strong>';
229249

230-
$html .= showIcon($metadata);
231-
232250
$html .= '</a>';
233251

234252
return $html;
@@ -237,9 +255,11 @@ function showEntry($t, $metadata, $favourite = false)
237255
/**
238256
* @param DiscoTemplate $t
239257
* @param array $metadata
258+
* @param bool $showSignInWith
259+
*
240260
* @return string html
241261
*/
242-
function showTaggedEntry($t, $metadata)
262+
function showTaggedEntry($t, $metadata, $showSignInWith = false)
243263
{
244264

245265
$bck = 'white';
@@ -252,36 +272,69 @@ function showTaggedEntry($t, $metadata)
252272

253273
$html .= '<img src="' . $metadata['icon'] . '">';
254274

255-
$html .= '<strong>Sign in with ' . $t->getTranslatedEntityName($metadata) . '</strong>';
275+
if (isset($metadata['fullDisplayName'])) {
276+
$html .= '<strong>' . $metadata['fullDisplayName'] . '</strong>';
277+
} elseif ($showSignInWith) {
278+
$html .= '<strong>' . $t->t('{perun:disco:sign_in_with}') . $t->getTranslatedEntityName($metadata) .
279+
'</strong>';
280+
} else {
281+
$html .= '<strong>' . $t->getTranslatedEntityName($metadata) . '</strong>';
282+
}
256283

257284
$html .= '</a>';
258285

259286
return $html;
260287
}
261288

289+
function getOr()
290+
{
291+
$or = '<div class="hrline">';
292+
$or .= ' <span>or</span>';
293+
$or .= '</div>';
294+
return $or;
295+
}
262296

263-
function showIcon($metadata)
297+
function showAllTaggedIdPs($t)
264298
{
265299
$html = '';
266-
// Logos are turned off, because they are loaded via URL from IdP. Some IdPs have bad configuration,
267-
// so it breaks the WAYF.
268-
269-
/*if (isset($metadata['UIInfo']['Logo'][0]['url'])) {
270-
$html .= '<img src="' .
271-
htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['UIInfo']['Logo'][0]['url'])) .
272-
'" class="idp-logo">';
273-
} else if (isset($metadata['icon'])) {
274-
$html .= '<img src="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['icon'])) .
275-
'" class="idp-logo">';
276-
}*/
277-
300+
$html .= showTaggedIdPs($t, 'preferred');
301+
$html .= showTaggedIdPs($t, 'social', true);
278302
return $html;
279303
}
280304

281-
function getOr()
305+
306+
function showTaggedIdPs($t, $tag, $showSignInWith = false)
282307
{
283-
$or = '<div class="hrline">';
284-
$or .= ' <span>or</span>';
285-
$or .= '</div>';
286-
return $or;
308+
$html = '';
309+
$idps = $t->getIdPs($tag);
310+
$idpCount = count($idps);
311+
$counter = 0;
312+
313+
$fullRowCount = floor($idpCount / 3);
314+
for ($i = 0; $i < $fullRowCount; $i++ ) {
315+
$html .= '<div class="row">';
316+
for ($j = 0; $j < 3; $j++) {
317+
$html .= '<div class="col-md-4">';
318+
$html .= '<div class="metalist list-group">';
319+
$html .= showTaggedEntry($t, $idps[array_keys($idps)[$counter]], $showSignInWith);
320+
$html .= '</div>';
321+
$html .= '</div>';
322+
$counter++;
323+
}
324+
$html .= '</div>';
325+
}
326+
if (($idpCount % 3) !== 0) {
327+
$html .= '<div class="row">';
328+
for ($i = 0; $i < $idpCount % 3; $i++) {
329+
$html .= '<div class="col-md-' . (12 / ($idpCount % 3)) . '">';
330+
$html .= '<div class="metalist list-group">';
331+
$html .= showTaggedEntry($t, $idps[array_keys($idps)[$counter]], $showSignInWith);
332+
$html .= '</div>';
333+
$html .= '</div>';
334+
$counter++;
335+
}
336+
$html .= '</div>';
337+
}
338+
339+
return $html;
287340
}

www/res/css/disco.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
a.metaentry {
2-
padding: 10px 15px 10px 35px;
2+
padding: 10px 15px 10px 15px;
3+
}
4+
5+
a.metaentry:hover {
6+
background-image: none;
7+
}
8+
9+
a.metaentry:focus {
10+
outline: none;
11+
background-color: rgba(0, 0, 0, 0.05);
312
}
413

514
a.metaentry.favourite {
615
background-image: url(../../../../resources/icons/silk/star.png);
716
background-position: 10px center;
17+
padding-left: 35px;
818
}
919

1020
a.metaentry .idp-logo {
@@ -13,10 +23,6 @@ a.metaentry .idp-logo {
1323
max-width: 120px;
1424
}
1525

16-
a.metaentry:hover {
17-
background-position: 10px center;
18-
}
19-
2026
a.metaentryrow .idp-logo {
2127
max-height: 40px;
2228
max-width: 200px;

0 commit comments

Comments
 (0)