Skip to content
Snippets Groups Projects
index.php 2.17 KiB
<?php
// ======================================================================
//
// AAI LOGIN WITH SHIBBOLETH HANDLING MULTIPLE ORGANIZATIONS
// 
// Boxes for all organizations with an input field for filter
//
// License: GNU GPL 3.0
// Source: https://git-repo.iml.unibe.ch/iml-open-source/login-aai
// ======================================================================

if (is_array($aIdplist) && count($aIdplist)) {
    $sOut = '';

    $sDomainFilter = '';
    $aTld = [];

    foreach ($aIdplist as $aEntry) {
        $aTld[$aEntry['_tld']] = 1;
        $sOut .= '
                    <a href="' . $aEntry['_url'] . '" 
                        class="idp"
                        title="' . strip_tags($aEntry['_description']) . '"
                        >
                        <span>' . htmlentities($aEntry['_label']) . '</span><br>
                        <span class="hidden">#' . $aEntry['_tld'] . '</span>
                        <img src="' . $aEntry['_image'] . '"><br>
                    </a>
                '
        ;
    }

    // Generate a list of TLDs to filter by it.
    if (count($aTld) > 1) {
        ksort($aTld);
        foreach (array_keys($aTld) as $sTld) {
            $sId = 'filterbtn-dot-' . str_replace('.', '', $sTld);
            $sDomainFilter .= '<a href="#" id="' . $sId . '" class="filterbutton" onclick="setFilter(\'#' . $sTld . ' \'); return false;">.' . $sTld . '</a> ';
        }
        // $sDomainFilter = '<div id="filterByDomain" class="hidden showForLogin">'. $sDomainFilter . '</div>';
    }

    echo '<div id="filterbox" class="hidden showForLogin">
            <input type="text" id="filter" placeholder="' . $L->t('filter-idps-placeholder') . '" onchange="applyfilter()" onkeydown="applyfilter()" onkeyup="applyfilter()" value=""/>'
        . $sDomainFilter
        . '<a href="#" id="resetfilter" onclick="resetFilter(); return false;" title="' . $L->t('resetfilter-title') . '"> X </a>
            <span id="filterCounter"></span>
        </div>'
        . '<div class="boxes showForLogin">
            ' . $sOut . '
            </div><div style="clear:both"></div>';

} else {
    echo '<div class="msg error">No IDPs found in Discovery Feed.</div>';
}