@@ -373,4 +373,171 @@ public function removeAuthContextClassRefWithPrefix(&$state)
373373 = $ array ;
374374 }
375375 }
376+
377+ public static function buildEntry (DiscoTemplate $ t , $ idp , $ favourite = false )
378+ {
379+
380+ $ extra = ($ favourite ? 'favourite ' : '' );
381+ $ html = '<a class="metaentry ' . $ extra . ' list-group-item" ' .
382+ ' href=" ' . $ t ->getContinueUrl ($ idp ['entityid ' ]) . '"> ' ;
383+
384+ $ html .= '<strong> ' . htmlspecialchars ($ t ->getTranslatedEntityName ($ idp )) . '</strong> ' ;
385+ $ html .= '</a> ' ;
386+
387+ return $ html ;
388+ }
389+
390+ /**
391+ * @param DiscoTemplate $t
392+ * @param array $metadata
393+ * @param bool $favourite
394+ * @return string html
395+ */
396+ public static function showEntry ($ t , $ metadata , $ favourite = false )
397+ {
398+
399+ if (isset ($ metadata ['tags ' ]) &&
400+ (in_array ('social ' , $ metadata ['tags ' ]) || in_array ('preferred ' , $ metadata ['tags ' ]))) {
401+ return self ::showTaggedEntry ($ t , $ metadata );
402+ }
403+
404+ $ extra = ($ favourite ? ' favourite ' : '' );
405+ $ html = '<a class="metaentry ' . $ extra . ' list-group-item" href=" ' .
406+ $ t ->getContinueUrl ($ metadata ['entityid ' ]) . '"> ' ;
407+
408+ $ html .= '<strong> ' . $ t ->getTranslatedEntityName ($ metadata ) . '</strong> ' ;
409+
410+ $ html .= '</a> ' ;
411+
412+ return $ html ;
413+ }
414+
415+ /**
416+ * @param DiscoTemplate $t
417+ * @param array $metadata
418+ * @param bool $showSignInWith
419+ *
420+ * @return string html
421+ */
422+ public static function showTaggedEntry ($ t , $ metadata , $ showSignInWith = false )
423+ {
424+
425+ $ bck = 'white ' ;
426+ if (!empty ($ metadata ['color ' ])) {
427+ $ bck = $ metadata ['color ' ];
428+ }
429+
430+ $ html = '<a class="metaentry btn btn-block tagged" href=" ' . $ t ->getContinueUrl ($ metadata ['entityid ' ]) .
431+ '" style="background: ' . $ bck . '"> ' ;
432+
433+ $ html .= '<img src=" ' . $ metadata ['icon ' ] . '"> ' ;
434+
435+ if (isset ($ metadata ['fullDisplayName ' ])) {
436+ $ html .= '<strong> ' . $ metadata ['fullDisplayName ' ] . '</strong> ' ;
437+ } elseif ($ showSignInWith ) {
438+ $ html .= '<strong> ' . $ t ->t ('{perun:disco:sign_in_with} ' ) . $ t ->getTranslatedEntityName ($ metadata ) .
439+ '</strong> ' ;
440+ } else {
441+ $ html .= '<strong> ' . $ t ->getTranslatedEntityName ($ metadata ) . '</strong> ' ;
442+ }
443+
444+ $ html .= '</a> ' ;
445+
446+ return $ html ;
447+ }
448+
449+ public static function getOr ()
450+ {
451+ $ or = '<div class="hrline"> ' ;
452+ $ or .= ' <span>or</span> ' ;
453+ $ or .= '</div> ' ;
454+ return $ or ;
455+ }
456+
457+ public static function showAllTaggedIdPs ($ t )
458+ {
459+ $ html = '' ;
460+ $ html .= self ::showTaggedIdPs ($ t , 'preferred ' );
461+ $ html .= self ::showTaggedIdPs ($ t , 'social ' , true );
462+ return $ html ;
463+ }
464+
465+
466+ public static function showTaggedIdPs ($ t , $ tag , $ showSignInWith = false )
467+ {
468+ $ html = '' ;
469+ $ idps = $ t ->getIdPs ($ tag );
470+ $ idpCount = count ($ idps );
471+ $ counter = 0 ;
472+
473+ $ fullRowCount = floor ($ idpCount / 3 );
474+ for ($ i = 0 ; $ i < $ fullRowCount ; $ i ++) {
475+ $ html .= '<div class="row"> ' ;
476+ for ($ j = 0 ; $ j < 3 ; $ j ++) {
477+ $ html .= '<div class="col-md-4"> ' ;
478+ $ html .= '<div class="metalist list-group"> ' ;
479+ $ html .= self ::showTaggedEntry ($ t , $ idps [array_keys ($ idps )[$ counter ]], $ showSignInWith );
480+ $ html .= '</div> ' ;
481+ $ html .= '</div> ' ;
482+ $ counter ++;
483+ }
484+ $ html .= '</div> ' ;
485+ }
486+ if (($ idpCount % 3 ) !== 0 ) {
487+ $ html .= '<div class="row"> ' ;
488+ for ($ i = 0 ; $ i < $ idpCount % 3 ; $ i ++) {
489+ $ html .= '<div class="col-md- ' . (12 / ($ idpCount % 3 )) . '"> ' ;
490+ $ html .= '<div class="metalist list-group"> ' ;
491+ $ html .= showTaggedEntry ($ t , $ idps [array_keys ($ idps )[$ counter ]], $ showSignInWith );
492+ $ html .= '</div> ' ;
493+ $ html .= '</div> ' ;
494+ $ counter ++;
495+ }
496+ $ html .= '</div> ' ;
497+ }
498+
499+ return $ html ;
500+ }
501+
502+ public static function showEntriesScript ()
503+ {
504+ $ script = '<script type="text/javascript">
505+ $(document).ready(function() {
506+ $("#showEntries").click(function() {
507+ $("#entries").show();
508+ $("#showEntries").hide();
509+ });
510+ });
511+ </script> ' ;
512+ return $ script ;
513+ }
514+
515+ public static function searchScript ()
516+ {
517+
518+ $ script = '<script type="text/javascript">
519+
520+ $(document).ready(function() {
521+ $("#query").liveUpdate("#list");
522+ });
523+
524+ </script> ' ;
525+
526+ return $ script ;
527+ }
528+
529+ public static function setFocus ()
530+ {
531+ $ script = '<script type="text/javascript">
532+
533+ $(document).ready(function() {
534+ if ($("#last-used-idp")) {
535+ $("#last-used-idp .metaentry").focus();
536+ }
537+ });
538+
539+ </script> ' ;
540+
541+ return $ script ;
542+ }
376543}
0 commit comments