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

Commit 81ecf3c

Browse files
committed
Change work with IdP entities with tags 'social' and 'preferred' on DS
* Width of entities is now counted automatically * Social IdP has 'Sign in with' before name, Preferred IdP hasn't * Added possibility to change display name in attribute 'fullDisplayName' in metadata
1 parent 023b7ba commit 81ecf3c

File tree

3 files changed

+71
-23
lines changed

3 files changed

+71
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55
#### Changed
6-
- Remove star which was shown on items on Discovery Service. Now the star will be shown only at previously selected IdP.
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
711

812
#### Fixed
913
- Fixed the bug in 'getEntitylesAttribute' function to return correct value of Entityless attribute

dictionaries/disco.definition.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"en": "your previous selection",
2020
"cs": "vaše předchozí volba"
2121
},
22+
"sign_in_with": {
23+
"en": "Sign in with ",
24+
"cs": "Přihlásit se pomocí "
25+
},
2226
"type_name_institution": {
2327
"en": "Type the name of your institution",
2428
"cs": "Zadejte název instituce"

themes/perun/perun/disco-tpl.php

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,10 @@
125125
echo showEntry($this, $this->getPreferredIdp(), true);
126126
echo '</div>';
127127

128-
129128
echo getOr();
130129
}
131130

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>';
139-
}
140-
echo '</div>';
141-
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>';
131+
echo showAllTaggedIdPs($this);
151132

152133
echo getOr();
153134

@@ -188,6 +169,11 @@
188169
$this->t('{perun:disco:add_institution}') .
189170
'</a>';
190171
}
172+
173+
if (!empty($this->getPreferredIdp())) {
174+
echo '</div>';
175+
}
176+
191177
echo '</div>';
192178
}
193179

@@ -237,9 +223,11 @@ function showEntry($t, $metadata, $favourite = false)
237223
/**
238224
* @param DiscoTemplate $t
239225
* @param array $metadata
226+
* @param bool $showSignInWith
227+
*
240228
* @return string html
241229
*/
242-
function showTaggedEntry($t, $metadata)
230+
function showTaggedEntry($t, $metadata, $showSignInWith = false)
243231
{
244232

245233
$bck = 'white';
@@ -252,7 +240,14 @@ function showTaggedEntry($t, $metadata)
252240

253241
$html .= '<img src="' . $metadata['icon'] . '">';
254242

255-
$html .= '<strong>Sign in with ' . $t->getTranslatedEntityName($metadata) . '</strong>';
243+
if (isset($metadata['fullDisplayName'])) {
244+
$html .= '<strong>' . $metadata['fullDisplayName'] . '</strong>';
245+
} elseif ($showSignInWith) {
246+
$html .= '<strong>' . $t->t('{perun:disco:sign_in_with}') . $t->getTranslatedEntityName($metadata) .
247+
'</strong>';
248+
} else {
249+
$html .= '<strong>' . $t->getTranslatedEntityName($metadata) . '</strong>';
250+
}
256251

257252
$html .= '</a>';
258253

@@ -285,3 +280,48 @@ function getOr()
285280
$or .= '</div>';
286281
return $or;
287282
}
283+
284+
function showAllTaggedIdPs($t)
285+
{
286+
$html = '';
287+
$html .= showTaggedIdPs($t, 'preferred');
288+
$html .= showTaggedIdPs($t, 'social', true);
289+
return $html;
290+
}
291+
292+
293+
function showTaggedIdPs($t, $tag, $showSignInWith = false)
294+
{
295+
$html = '';
296+
$idps = $t->getIdPs($tag);
297+
$idpCount = count($idps);
298+
$counter = 0;
299+
300+
$fullRowCount = floor($idpCount / 3);
301+
for ($i = 0; $i < $fullRowCount; $i++ ) {
302+
$html .= '<div class="row">';
303+
for ($j = 0; $j < 3; $j++) {
304+
$html .= '<div class="col-md-4">';
305+
$html .= '<div class="metalist list-group">';
306+
$html .= showTaggedEntry($t, $idps[array_keys($idps)[$counter]], $showSignInWith);
307+
$html .= '</div>';
308+
$html .= '</div>';
309+
$counter++;
310+
}
311+
$html .= '</div>';
312+
}
313+
if (($idpCount % 3) !== 0) {
314+
$html .= '<div class="row">';
315+
for ($i = 0; $i < $idpCount % 3; $i++) {
316+
$html .= '<div class="col-md-' . (12 / ($idpCount % 3)) . '">';
317+
$html .= '<div class="metalist list-group">';
318+
$html .= showTaggedEntry($t, $idps[array_keys($idps)[$counter]], $showSignInWith);
319+
$html .= '</div>';
320+
$html .= '</div>';
321+
$counter++;
322+
}
323+
$html .= '</div>';
324+
}
325+
326+
return $html;
327+
}

0 commit comments

Comments
 (0)