{% extends "login/layout/sidebar-layout.html.twig" %}

{% import "common/macro_captcha.html.twig" as macro_captcha %}
{% import "login/common/macros.html.twig" as auth_macro %}

{% block main_title %}
    {{ instance_title|default('Phraseanet') }}
{% endblock %}

{% block header_rss %}
 {% for feed in feeds %}
        {% set link = app['feed.user-link-generator'].generatePublic(feed, 'rss') %}
        <link rel="alternate" type="{{ link.getMimetype() }}" title="{{ link.getTitle() }}" href="{{ link.getURI() }}" />
        {% set link = app['feed.user-link-generator'].generatePublic(feed, 'atom') %}
        <link rel="alternate" type="{{ link.getMimetype() }}" title="{{ link.getTitle() }}" href="{{ link.getURI() }}" />
    {% endfor %}
{% endblock %}

{% block sidebar %}
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 authentication-sidebar-title">
                <div class="text-title">
                    {{ "Connection" | trans }}
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div class="span12">
                {{ auth_macro.flashes() }}

                {% if unlock_usr_id is not empty %}
                <div class="row-fluid">
                    <div class="span12">
                        {{ 'Your account is locked, please follow the following link to unlock it' | trans }}<br/>
                        <a href="{{ path('login_send_mail', { 'usr_id' : unlock_usr_id }) }}" target ="_self">
                            {{ 'login:: Envoyer a nouveau le mail de confirmation' | trans }}
                        </a>
                    </div>
                </div>
                {% endif %}

                <form
                    novalidate
                    name="loginForm"
                    method="POST"
                    action="{{ path("login_authenticate") }}"
                >
                    {% if form.vars.errors|length > 0 %}
                        <div class="row-fluid">
                            <div class="span12">
                                {{ form_errors(form) }}
                            </div>
                        </div>
                    {% endif %}

                    <div class="row-fluid">
                        <div class="span12">
                            {{ auth_macro.fieldInput(form.login, "loginForm", 'fa fa-envelope') }}
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            {{ auth_macro.fieldInput(form.password, "loginForm", 'fa fa-lock') }}
                        </div>
                    </div>
                    <div class="text-right">
                        <a class="forget-password-link" href="{{ path("login_forgot_password") }}">
                            {{ "Forgot password?" | trans }}
                        </a>
                    </div>

                    {% if recaptcha_display %}
                        <div class="row-fluid">
                            <div class="span12">
                                {{ macro_captcha.captcha() }}
                            </div>
                        </div>
                    {% endif %}

                    <div class="row-fluid">
                        <div class="span12">
                            <button type="submit" class="btn btn-success btn-trigger">
                                {{ "Connection" | trans }}
                            </button>
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            {{ auth_macro.checkboxInput(form['remember-me']) }}
                        </div>
                    </div>
                    {{ form_rest(form) }}
                </form>
            </div>
        </div>
    </div><!-- /sidebar block -->
    {% if authentication_providers | count > 0 %}
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 text-center">
                {{ "Or login with" | trans }}
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12 text-center">
                {{ auth_macro.providerList() }}
            </div>
        </div>
    </div>
    {% endif %}

    {% include "login/include/register-link-block.html.twig" %}
    {% include "login/include/guest-access-block.html.twig" with {"guest_allowed": guest_allowed} %}
{% endblock %}

{% block left_content %}
    {{ parent() }}

    {% if display_layout == 'DISPLAYx1' %}
        {% include 'login/include/x1-content.html.twig' %}
    {% elseif display_layout == "COOLIRIS" %}
        {% include 'login/include/cooliris-content.html.twig' %}
    {% elseif display_layout == "SCROLL" %}
        {% include 'login/include/scroll-content.html.twig' %}
    {% elseif display_layout == "CAROUSEL" %}
        {% include 'login/include/carousel.html.twig' %}
    {% elseif display_layout == "GALLERIA" %}
        {% include 'login/include/galleria.html.twig' %}
    {% endif %}
{% endblock %}

{% block header_stylesheet %}
    {{  parent() }}

    {% if display_layout == "CAROUSEL" %}
        <style type="text/css">
            #carousel {
               height: 400px;
            }

            #carousel .item img {
               margin: 0 auto;
               max-height: 400px;
            }
        </style>
    {% elseif display_layout == "GALLERIA" %}
        <style type="text/css">
            #galleria {
                height: 400px;
            }
        </style>
    {%  endif %}
{% endblock %}

{% block scripts %}
    {{ parent() }}
    <script>
        authenticateApp.bootstrap({
            state: 'login'
        });
    </script>
{% endblock %}
