{% if errorMessage %}
  {{ include('@templates/alert-message.twig',{type:'danger',message:errorMessage}) }}
{% endif %}

{{ include_javascript('javascripts/vendor/datatables-full/jquery.dataTables.min.js') }}
{{ include_css('styles/vendor/datatables-full/dataTables.bootstrap.min.css') }}
<form method="post" action="{{ url({params:{}}) }}">

  <p>{{ _t('GERERTHEMES_HINT') }}</p>
  <div class="table-responsive">
    <table class="table table-striped table-condensed gerer-theme">
      <thead>
        <tr>
          <th class="prevent-sorting">
            <label class="check-all-container">
              <input type="checkbox" name="id" value="tous" onclick="checkAll(this.checked)">
              <span></span>
            </label>
          </th>
          <th><div><b>{{ _t('GERERTHEMES_PAGE') }}</b></div></th>
          <th><div align="center"><b>{{ _t('TEMPLATE_THEME') }}</b></div></th>
          <th><div align="center"><b>{{ _t('TEMPLATE_SQUELETTE') }}</b></div></th>
          <th><div align="center"><b>{{ _t('TEMPLATE_STYLE') }}</b></div></th>
          <th><div align="center"><b>{{ _t('TEMPLATE_PRESET') }}</b></div></th>
        </tr>
      </thead>
      <tbody>
        {% for tag,metadata in pagesThemes %}
          {% set currentId = "selectpage[#{ tag }]" %}
          <tr>
            <td>
              <label for="{{ currentId }}">
                <input type="checkbox" name="{{ currentId }}"
                      value="{{ tag }}" class="selectpage"
                      id="{{ currentId }}">
                <span></span>
              </label>
            </td>
            <td><a href="{{ url({tag:tag}) }}">{{ tag }}</a></td>
            <td><div align="center">{{ metadata.theme|replace({' ':"\n"})|nl2br }}</div></td>
            <td><div align="center">{{ metadata.squelette|replace({' ':"\n"})|nl2br }}</div></td>
            <td><div align="center">{{ metadata.style|replace({' ':"\n"})|nl2br }}</div></td>
            <td><div align="center">{{ metadata.favorite_preset|replace({' ':"\n"})|nl2br }}</div></td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <p><b>{{ _t('GERERTHEMES_ACTIONS') }}</b></p>

  <p class="type-modif-container">
    <label for="typemajdefault">
      <input type=radio name="typemaj" value="reinitialiser" id="typemajdefault" checked
            onClick="$('.edit-theme-container').slideUp()">
      <span>{{ _t('GERERTHEMES_INIT_THEME_FOR_SELECTED_PAGES') }}</span>
    </label>
    <label for="typemajajouter">
      <input type=radio name="typemaj" value="modifier" id="typemajajouter"
            onClick="$('.edit-theme-container').slideDown()">
      <span>{{ _t('GERERTHEMES_MODIFY_THEME_FOR_SELECTED_PAGES') }}</span>
    </label>
  </p>

  <div class="edit-theme-container" style="display:none">
    {{ include('@templates/theme-selector.twig') }}
  </div>

  <p>
    <input
      name="theme_modifier" 
      type="submit" 
      value="Mettre à jour"
      class="btn btn-primary"
      onclick="this.form.action+='#gererthemes'; return true;"
      {% if hibernated -%}
      disabled data-toggle="tooltip" data-placement="bottom" title="{{ _t('WIKI_IN_HIBERNATION') }}"
      {%- endif %}
      />
  </p>

</form>