{%- set themeLight = themeLight ?? false -%}
<!DOCTYPE html>
<html lang="{{ app.request.locale|replace({'_':'-'}) }}">
    <head>
        <meta charset="utf-8">
        <title>{{ metatitle is defined and metatitle ? metatitle ~ '- Administration Cgénial' : 'CGénial - Administration' }}</title>

        {# Favicons #}
        {# @see http://realfavicongenerator.net/ #}
        <link rel="shortcut icon" href="{{ asset('favicon.ico') }}?v=2017" />
        <link rel="apple-touch-icon" sizes="180x180" href="{{ asset('apple-touch-icon.png') }}?v=2017">
        <link rel="icon" type="image/png" href="{{ asset('favicon-32x32.png') }}?v=2017" sizes="32x32">
        <link rel="icon" type="image/png" href="{{ asset('favicon-16x16.png') }}?v=2017" sizes="16x16">
        <link rel="manifest" href="{{ asset('manifest.json') }}?v=2017">
        <link rel="mask-icon" href="{{ asset('safari-pinned-tab.svg') }}?v=2017" color="#5bbad5">
        <meta name="theme-color" content="#ffffff">
        
        {# CSS files #}
        <link media="all" href="{{ asset('admin/scripts/jquery-ui-1.12.1.custom/jquery-ui.min.css') }}" rel="stylesheet" />
        <link media="all" href="{{ asset('admin/scripts/fancybox/jquery.fancybox.css') }}" rel="stylesheet" />
        <link media="all" href="{{ asset('admin/styles/main.css'|asset_rev) }}" rel="stylesheet">
        {% block stylesheets %}{% endblock %}
    </head>

    {% set fancybox_load_urls = [] %}
    {% for label, message in app.flashes('fancybox-load') %}
        {% set fancybox_load_urls = fancybox_load_urls|merge([message]) %}
    {% endfor %}
    <body
        class="theme{{ themeLight ? '-light' : '' }}"
        data-styles-front="{{ asset('front/styles/main.css'|asset_rev) }}"
        {% if fancybox_load_urls is not empty %}data-fancybox-load="{{ fancybox_load_urls|join(' ') }}"{% endif %}
    >
        {% spaceless %}
            {# Inclusion des icônes SVG #}
            {{ include('Admin/Default/icons.html.twig') }}

            {% if not themeLight %}
                <div class="header">
                    {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
                        <ul class="connection">
                            <li class="connection-user">
                                <span title="{{ app.user.username }}">{{ app.user.username }}</span>
                            </li>
                            <li class="connection-logout">
                                <a href="{{ path('fos_user_security_logout') }}" title="Se déconnecter">
                                    <svg class="icon icon-logout"><use xlink:href="#icon-logout"></use></svg>
                                </a>
                            </li>
                        </ul>
                    {% else %}
                        <a href="{{ path('fos_user_security_login') }}">Connexion</a>
                    {% endif %}

                    {{ knp_menu_render('main') }}

                    <div id="copyright">
                        <p>&copy; Astrolab {{ date()|date("Y") }}</p>
                    </div>
                </div>
            {% endif %}

            <main class="container" role="main">
                {% for label, messages in app.flashes(['info', 'error', 'success', 'warning']) %}
                    {% if loop.first %}
                        <ul class="notices">
                    {% endif %}

                        {% for message in messages %}
                            <li class="notice notice-{{ label }}">{{ message }}</li>
                        {% endfor %}

                    {% if loop.last %}
                        </ul>
                    {% endif %}
                {% endfor %}

                {% block body %}{% endblock %}
            </main>

            <script src="{{ asset('admin/scripts/jquery-ui-1.12.1.custom/external/jquery/jquery.js') }}"></script>
            <script src="{{ asset('admin/scripts/jquery-ui-1.12.1.custom/jquery-ui.min.js') }}"></script>
            <script src="{{ asset('admin/scripts/jquery-ui-1.12.1.custom/datepicker-fr.js') }}"></script>
            <script src="{{ asset('admin/scripts/tinymce/js/tinymce/tinymce.min.js') }}"></script>
            <script src="{{ asset('admin/scripts/main.js'|asset_rev) }}"></script>
            <script src="{{ asset('admin/scripts/fancybox/jquery.fancybox.js') }}"></script>
            {% block javascripts %}{% endblock %}
        {% endspaceless %}
    </body>
</html>
