<?php
/*
    ======================================================================

    AAI LOGIN WITH SHIBBOLETH HANDLING MULTIPLE ORGANIZATIONS

    ----------------------------------------------------------------------

    Institute for Medical Education; University of Bern
    License: GNU GPL 3.0
    Source: https://git-repo.iml.unibe.ch/iml-open-source/login-aai
    ----------------------------------------------------------------------
    2024-09-13    Initial version
    ======================================================================
*/

    require 'inc_functions.php';

    $aAbout = [
        'title' => 'AAI Login',
        'author' => 'Axel Hahn, Institute for Medical Education, University of Bern',
        'source' => 'https://git-repo.iml.unibe.ch/iml-open-source/login-aai',
        'license' => 'GNU GPL 3.0',
        'version' => '0.3',
    ];

?><!DOCTYPE html>
<html lang="" dir="">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title><?php echo $aConfig['title'] ?? 'AAI Login'; ?></title>

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="login_aai.css" media="screen" />

</head>

<body>

    <div id="head">
        <h1><?php echo $aConfig['title'] ?? 'AAI Login'; ?></h1>
    </div>

    <div class="content">

        <?php

            // --- set language for js script
            echo '<input type="hidden" id="lang" value="'.($aConfig['lang'] ?? 'en').'">';
            
            // --- messages
            echo $SELFURL ? '' : showMessage('error', 'SELFURL is not set. $_SERVER[\'SERVER_NAME\'] is not available.');
            echo $aConfig['text-info'] ? showMessage('info', $aConfig['text-info']) : ''; 

            // --- id "errorbox" is used for javascript error messages
            echo '<div id="errorbox" class="msg error hidden"></div>';

            // --- text block if the user is logged in already
            echo '<div id="shib-check-logged-in" class="hidden">
            <h2>'.$L->t('logged-in-already-title').'</h2>
            <p>
                '.$L->t('logged-in-already-text').'<br>
                <a href="/">'.$L->t('home').'</a>
            </p>
            </div>';

            echo '<div id="shib-select-idp">';

                // --- Text before
                echo $aConfig['text-before'] ?? '' ; 

                // --- show possible logins
                include "inc_mode_".$aConfig['mode'].".php";

            echo '</div>';

            // --- finishing text
            echo $aConfig['text-after'] ?? '';

        ?>

    </div>
    <script type="text/javascript" defer src="functions.js"></script>

    <footer>
        <strong><?php echo $aConfig['title'] ?? 'AAI Login'; ?></strong><br>
        <?php echo $aAbout['title'].' v' .$aAbout['version']; ?> - 
        <a href="<?php echo $aAbout['source']; ?>">Source</a>
    </footer>
</body>

</html>