<?php
/**
 * Login page for CORETransitions.
 *
 * Displays the sign-in form where users enter their username and password.
 * Shows any relevant messages (e.g. "You've been logged out") and provides
 * links to register, reset a forgotten password, or request a one-time
 * login link. WIP WIP
 */

use Cake\Core\Configure;

$this->extend('/layout/TwitterBootstrap/signin');
$this->Html->css('login', ['block' => true]);

?>

<div class="login-container form-signin"> 
    <div class="login-header">
        <h1>CORETransitions</h1>
        <p>Social Portal</p>
    </div>

    <div class="login-flash">
        <?= $this->Flash->render() ?>
        <?= $this->Flash->render('auth') ?>
    </div>

    <div class="users form">
        <?= $this->Form->create() ?>
        <fieldset>
            <legend><?= __d('cake_d_c/users', 'Please enter your username and password') ?></legend>
            <?= $this->Form->control('username', ['label' => __d('cake_d_c/users', 'Username'), 'required' => true, 'autofocus' => 'autofocus']) ?>
            <?= $this->Form->control('password', ['label' => __d('cake_d_c/users', 'Password'), 'required' => true]) ?>
            <?php
            if (Configure::read('Users.reCaptcha.login')) {
                echo $this->User->addReCaptcha();
            }
            if (Configure::read('Users.RememberMe.active')) {
                echo '<div class="remember-me">';
                echo $this->Form->control(Configure::read('Users.Key.Data.rememberMe'), [
                    'type' => 'checkbox',
                    'label' => __d('cake_d_c/users', 'Remember me'),
                    'checked' => Configure::read('Users.RememberMe.checked')
                ]);
                echo '</div>';
            }
            ?>
            <div class="login-links">
                <?php
                $registrationActive = Configure::read('Users.Registration.active');
                if ($registrationActive) {
                    echo $this->Html->link(__d('cake_d_c/users', 'Register'), ['action' => 'register']);
                }
                if (Configure::read('Users.Email.required')) {
                    if ($registrationActive) {
                        echo ' | ';
                    }
                    echo $this->Html->link(__d('cake_d_c/users', 'Reset Password'), ['action' => 'requestResetPassword']);
                    if (Configure::read('OneTimeLogin.enabled')) {
                        echo ' | ';
                        echo $this->Html->link(__d('cake_d_c/users', 'Send me a login link'), ['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'requestLoginLink'], ['allowed' => true, 'escape' => false]);
                    }
                }
                ?>
            </div>
        </fieldset>
        <?= implode(' ', $this->User->socialLoginList()); ?>
        <?= $this->User->button(__d('cake_d_c/users', 'Login')); ?>
        <?= $this->Form->end() ?>
    </div>
</div>
