File: disco.tpl.php

package info (click to toggle)
simplesamlphp 1.19.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 42,920 kB
  • sloc: php: 202,044; javascript: 14,867; xml: 2,700; sh: 225; perl: 82; makefile: 70; python: 5
file content (141 lines) | stat: -rw-r--r-- 5,939 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

$this->data['header'] = $this->t('selectidp');

$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/css/uitheme1.12.1/jquery-ui.min.css').'" />';
$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/css/disco.css').'" />';

if (!empty($this->data['faventry'])) {
    $this->data['autofocus'] = 'favouritesubmit';
}

$this->includeAtTemplateBase('includes/header.php');

$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery-1.12.4.min.js').'"></script>'."\n";
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery-ui-1.12.1.min.js').'"></script>'."\n";
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/js/jquery.livesearch.js').'"></script>'."\n";
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/js/'.$this->data['score'].'.js').'"></script>'."\n";
$this->data['htmlinject']['htmlContentPost'][] = '<script type="text/javascript" src="'.
    SimpleSAML\Module::getModuleURL('discopower/assets/js/tablist.js').'"></script>'."\n";


function showEntry($t, $metadata, $favourite = false)
{
    $basequerystring = '?'.
        'entityID='.urlencode($t->data['entityID']).'&amp;'.
        'return='.urlencode($t->data['return']).'&amp;'.
        'returnIDParam='.urlencode($t->data['returnIDParam']).'&amp;idpentityid=';

    $extra = ($favourite ? ' favourite' : '');
    $html = '<a class="metaentry'.$extra.'" href="'.$basequerystring.urlencode($metadata['entityid']).'">';

    $html .= htmlspecialchars(getTranslatedName($t, $metadata)).'';

    if (array_key_exists('icon', $metadata) && $metadata['icon'] !== null) {
        $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($metadata['icon']);
        $html .= '<img alt="Icon for identity provider" class="entryicon" src="'.htmlspecialchars($iconUrl).'" />';
    }

    $html .= '</a>';
    return $html;
}

function getTranslatedName($t, $metadata)
{
    if (isset($metadata['UIInfo']['DisplayName'])) {
        $displayName = $metadata['UIInfo']['DisplayName'];
        assert(is_array($displayName)); // Should always be an array of language code -> translation
        if (!empty($displayName)) {
            return $t->getTranslator()->getPreferredTranslation($displayName);
        }
    }

    if (array_key_exists('name', $metadata)) {
        if (is_array($metadata['name'])) {
            return $t->getTranslator()->getPreferredTranslation($metadata['name']);
        } else {
            return $metadata['name'];
        }
    }
    return $metadata['entityid'];
}

if (!empty($this->data['faventry'])) {
    echo '<div class="favourite">' ;
    echo $this->t('previous_auth');
    echo ' <strong>'.htmlspecialchars(getTranslatedName($this, $this->data['faventry'])).'</strong>';
    echo '<form id="idpselectform" method="get" action="'.$this->data['urlpattern'].
        '"><input type="hidden" name="entityID" value="'.htmlspecialchars($this->data['entityID']).
        '" /><input type="hidden" name="return" value="'.htmlspecialchars($this->data['return']).
        '" /><input type="hidden" name="returnIDParam" value="'.htmlspecialchars($this->data['returnIDParam']).
        '" /><input type="hidden" name="idpentityid" value="'.htmlspecialchars($this->data['faventry']['entityid']).
        '" /><input type="submit" name="formsubmit" id="favouritesubmit" value="'.$this->t('login_at').' '.
        htmlspecialchars(getTranslatedName($this, $this->data['faventry'])).'" /></form>';
    echo '</div>';
}
?>

<div id="tabdiv">
    <ul class="tabset_tabs">
        <?php
        $tabs = array_keys($this->data['idplist']);
        $i = 1;
        foreach ($tabs as $tab) {
            if (!empty($this->data['idplist'][$tab])) {
                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++;
            }
        }
        ?>
    </ul>

<?php

foreach ($this->data['idplist'] as $tab => $slist) {
    $first = array_keys($this->data['idplist']);
    if ($first[0] === $tab) {
        echo '<div id="'.$tab.'" class="tabset_content current">';
    } else {
        echo '<div id="'.$tab.'" class="tabset_content">';
    }
    if (!empty($slist)) {
        echo '<div class="inlinesearch">';
        echo '<p>'.htmlspecialchars($this->t('{discopower:tabs:incremental_search}')).'</p>';
        echo '<form id="idpselectform" action="?" method="get">';
        echo '<input class="inlinesearch" type="text" value="" name="query_'.$tab.'" id="query_'.$tab.'" /></form>';
        echo '</div>';

        echo '<div class="metalist" id="list_'.$tab .'">';
        if (!empty($this->data['preferredidp']) && array_key_exists($this->data['preferredidp'], $slist)) {
            $idpentry = $slist[$this->data['preferredidp']];
            echo showEntry($this, $idpentry, true);
        }

        foreach ($slist as $idpentry) {
            if ($idpentry['entityid'] != $this->data['preferredidp']) {
                echo showEntry($this, $idpentry);
            }
        }
        echo '</div>';
    }
    echo '</div>';
}

?>

</div>

<?php
$this->includeAtTemplateBase('includes/footer.php');