{#
 # This file is part of the CRUDlex package.
 #
 # (c) Philip Lehmann-Böhm <philip@philiplb.de>
 #
 # For the full copyright and license information, please view the LICENSE
 # file that was distributed with this source code.
 #}
<!DOCTYPE html>

{% set rtlLanguages = ['ar'] %}
{% set locale = crudlex_sessionGet('locale', 'en') %}
{% set localeToFlag = {'en': 'gb', 'de': 'de', 'el': 'gr', 'fr': 'fr'} %}
{% set localeDir = locale in rtlLanguages ? ' dir="rtl" ' : '' %}

<html{{ localeDir|raw }}>
    <head>
        <title>CRUDlex</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        {% include crud.getTemplate('template', 'header', crudEntity) %}

        <style type="text/css">
            body {
                padding-top: 70px;
            }
            .btn-crudlex {
                margin: 5px 5px 5px 5px;
            }
            .tooltip-crudlex {
                cursor: pointer;
            }
            .select2-container {
                width: 100% !important;
                padding: 0;
            }

            .flag {
                background: url('{{ crud.generateURL('crudStatic', {file: 'images/flags/flags.png'}) }}') no-repeat;
            }

            @font-face {
              font-family: 'Glyphicons Halflings';

              src: url('{{ crud.generateURL('crudStatic', {file: 'fonts/vendor/bootstrap/glyphicons-halflings-regular.eot'}) }}');
              src: url('{{ crud.generateURL('crudStatic', {file: 'fonts/vendor/bootstrap/glyphicons-halflings-regular.eot?'}) }}#iefix') format('embedded-opentype'), url('{{ crud.generateURL('crudStatic', {file: 'fonts/vendor/bootstrap/glyphicons-halflings-regular.woff'}) }}') format('woff'), url('{{ crud.generateURL('crudStatic', {file: 'fonts/vendor/bootstrap/glyphicons-halflings-regular.ttf'}) }}') format('truetype'), url('{{ crud.generateURL('crudStatic', {file: 'fonts/vendor/bootstrap/glyphicons-halflings-regular.svg'}) }}#glyphicons_halflingsregular') format('svg');
            }
        </style>

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
        </head>
    <body>
      <div id="crudPage{{ crudEntity is defined ? crudEntity : '' }}">

            {% set flashTypeAvailable = [ 'success', 'danger'] %}
            {% for flashType in flashTypeAvailable %}
                {% for flash in crudlex_sessionFlashBagGet(flashType) %}
                  <div class="alert alert-{{ flashType }}" >
                      <button class="close" data-dismiss="alert">×</button>
                      {{ flash }}
                  </div>
                {% endfor %}
            {% endfor %}

            <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
                <div class="container">
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav navbar-right">
                            {% for entity, navBarGroup in crud.getEntitiesNavBar() %}
                                {% if navBarGroup == 'main' %}
                                    <li {% if crudEntity == entity %} class="active" {% endif%}><a href="{{ crud.generateURL('crudList', {'entity': entity}) }}">{{ crud.getData(entity).getDefinition().getLabel() }}</a></li>
                                {% else %}
                                  <li class="dropdown {% if crudEntity in navBarGroup %} active {% endif%}" >
                                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{ entity }}
                                    <span class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                      {% for subentity in navBarGroup %}
                                          <li {% if crudEntity == subentity %} class="active" {% endif%}><a href="{{ crud.generateURL('crudList', {'entity': subentity}) }}">{{ crud.getData(subentity).getDefinition().getLabel() }}</a></li>
                                      {% endfor %}
                                    </ul>
                                  </li>
                                {% endif %}
                            {% endfor %}
                        </ul>
                    </div>
                </div>
            </nav>

            <div class="container">
                {% block content %}{% endblock %}

                {% if crud.isManageI18n() %}
                    <div dir="ltr">
                      <small{{ localeDir|raw }}>{{ 'crudlex.chooseLanguage'|trans }}</small>
                      <div class="dropdown">
                          <a id="drop4" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" role="button" data-toggle="dropdown" href="#">
                              <img src="{{ crud.generateURL('crudStatic', {file: 'images/blank.gif'}) }}" class="flag flag-{{ localeToFlag[locale] }}" alt="{{ locale|crudlex_languageName }}" /> {{ locale|crudlex_languageName }}
                          <span class="caret"></a>
                          <ul class="dropdown-menu" aria-labelledby="dLabel">
                              {% for locale in crud.getLocales() %}
                                  <li>
                                      <a href="{{ crud.generateURL('crudSetLocale', {'locale': locale, 'redirect': crudlex_getCurrentUri()}) }}">
                                          <img src="{{ crud.generateURL('crudStatic', {file: 'images/blank.gif'}) }}" class="flag flag-{{ localeToFlag[locale] }}" alt="{{ locale|crudlex_languageName }}" /> {{ locale|crudlex_languageName }}
                                      </a>
                                  </li>
                              {% endfor %}
                          </ul>
                      </div>
                    </div>
                {% endif %}
            </div>

            {% include crud.getTemplate('template', 'footer', crudEntity) %}

            <script type="text/javascript">
                {% block js %}{% endblock %}
            </script>
        </div>
    </body>
</html>
