{% if error %}
  <div class="form-error">{{ "error"|lang }}: {{ error }}</div>
{% endif %}

{{ bc([
  {text: "admin_title"|lang, url: '/admin/'},
  {text: "blog_uploads"|lang}
]) }}

<div class="blog-upload-form">
  <form action="/admin/uploads/" method="post" enctype="multipart/form-data" class="form-layout-h">
    <input type="hidden" name="token" value="{{ form_token }}" />

    <div class="form-field-wrap clearfix">
      <div class="form-field-label">{{ "blog_upload_form_file"|lang }}:</div>
      <div class="form-field">
        <input type="file" name="files[]" multiple>
      </div>
    </div>

    <div class="form-field-wrap clearfix">
      <div class="form-field-label">{{ "blog_upload_form_custom_name"|lang }}:</div>
      <div class="form-field">
        <input type="text" name="name">
      </div>
    </div>

    {% for l in langs %}
      <div class="form-field-wrap clearfix">
        <div class="form-field-label">{{ "blog_upload_form_note"|lang }} ({{ ("lang_"~l)|lang }}):</div>
        <div class="form-field">
          <input type="text" name="note_{{ l }}" size="55">
        </div>
      </div>
    {% endfor %}

    <div class="form-field-wrap clearfix">
      <div class="form-field-label"></div>
      <div class="form-field">
        <input type="submit" value="Upload">
      </div>
    </div>
  </form>
</div>

<div class="blog-upload-list">
  {% for item in uploads %}
    <div class="blog-upload-item">
      <div class="blog-upload-item-actions">
        <a href="javascript:void(0)" onclick="var mdel = ge('upload{{ item.id }}_md'); mdel.style.display = (mdel.style.display === 'none' ? 'block' : 'none')">{{ "blog_upload_show_md"|lang }}</a>
        | <a href="javascript:void(0)" onclick='BlogUploadList.submitNoteEdit("/admin/uploads/edit_note/{{ item.id }}/?lang=ru&token={{ csrf('editupl'~post.id) }}", prompt("Note (Ru):", {{ item.getJSONEncodedHtmlSafeNote('ru')|raw }}))'>Edit note Ru</a>
        | <a href="javascript:void(0)" onclick='BlogUploadList.submitNoteEdit("/admin/uploads/edit_note/{{ item.id }}/?lang=en&token={{ csrf('editupl'~post.id) }}", prompt("Note (En):", {{ item.getJSONEncodedHtmlSafeNote('en')|raw }}))'>Edit note En</a>
        | <a href="/admin/uploads/delete/{{ post.id }}/?token={{ csrf('delupl'~post.id) }}" onclick="return confirm('{{ "blog_upload_delete_confirmation"|lang }}')">{{ "blog_upload_delete"|lang }}</a>
      </div>

      <div class="blog-upload-item-name"><a href="{{ item.getDirectUrl() }}">{{ item.name }}</a></div>
      <div class="blog-upload-item-info">{{ item.getSize() }}</div>

      {% if item.noteEn %}
        <div class="blog-upload-item-note"><span>En</span>{{ item.noteEn }}</div>
      {% endif %}

      {% if item.noteRu %}
        <div class="blog-upload-item-note"><span>Ru</span>{{ item.noteRu }}</div>
      {% endif %}

      <div class="blog-upload-item-md" id="upload{{ item.id }}_md" style="display: none">
        <input type="text" value="{{ item.getMarkdown() }}" onclick="this.select()" readonly style="width: 100%">
      </div>
    </div>
  {% endfor %}
</div>