leilukin-tumbleblog/admin/pages/manage_uploads.twig

100 lines
3.8 KiB
Twig

{% extends "layouts" ~ DIR ~ "default.twig" %}
{% block title %}{{ "Manage Uploads" | translate }}{% endblock %}
{% block content %}
<form class="filters" action="{{ url('manage_uploads') }}" method="post" accept-charset="UTF-8" role="search">
<fieldset role="presentation">
<label for="search">{{ "Search&hellip;" | translate }}</label>
<input class="text filter_text" type="text" name="search" value="{{ GET.search is defined ? GET.search | fix(true, true) : '' }}" id="search">
<button type="submit">{{ "Search" | translate }}</button>
{% if visitor.group.can("import_content") %}
<a href="{{ url('import') }}" class="button yay">
{{ icon_img("add.svg") }}{{ "Add Files" | translate }}
</a>
{% endif %}
</fieldset>
</form>
<h2>{{ GET.search is defined ? "Search Results" | translate : "Uploads" | translate }}</h2>
<table class="interactive{{ uploads.paginated is empty ? ' empty' : '' }}">
<thead>
<tr class="head">
<th class="uploads_name filename main">{{ "Name" | translate }}</th>
<th class="uploads_modified date">{{ "Last Modified" | translate }}</th>
<th class="uploads_size value">{{ "Size" | translate }}</th>
<th class="uploads_type value">{{ "Type" | translate }}</th>
{{ trigger.call("manage_uploads_column_header") }}
<th class="controls" colspan="2">{{ "Controls" | translate }}</th>
</tr>
</thead>
<tbody>
{% for upload in uploads.paginated %}
<tr id="uploads_{{ loop.index }}" class="uploads">
<td class="uploads_name filename main">
{% if ["jpg", "jpeg", "png", "webp", "gif"] | contains(upload.type) %}
{{ upload.name | thumbnail("", false, ["max_width=70", "quality=60", "square=1"], "70px") }}
{% elseif ["avif", "tif", "tiff", "heif", "bmp"] | contains(upload.type) %}
{{ icon_img("image.svg", "", "placeholder") }}
{% elseif ["mp3", "m4a", "oga", "ogg", "mka", "flac", "wav", "aiff"] | contains(upload.type) %}
{{ icon_img("audio.svg", "", "placeholder") }}
{% elseif ["mpg", "mpeg", "mp2", "mp4", "m4v", "ogv", "mkv", "mov", "avi", "webm", "3gp", "ts"] | contains(upload.type) %}
{{ icon_img("video.svg", "", "placeholder") }}
{% elseif ["zip", "tar", "rar", "gz", "bz2", "7z", "dmg", "cab", "iso", "udf"] | contains(upload.type) %}
{{ icon_img("archive.svg", "", "placeholder") }}
{% else %}
{{ icon_img("file.svg", "", "placeholder") }}
{% endif %}
<a target="_blank" href="{{ upload.name | uploaded }}">{{ upload.name | fix }}</a>
</td>
<td class="uploads_modified value">
{{ upload.modified | time("Y-m-d H:i:s") }}
</td>
<td class="uploads_size value">
{{ upload.size | filesizeformat }}
</td>
<td class="uploads_type value">
{{ upload.type | upper }}
</td>
{{ trigger.call("manage_uploads_column", upload) }}
<td class="controls">
<a class="emblem" href="{{ upload.name | download }}">
{{- icon_img("download.svg", "download" | translate) -}}
</a>
</td>
<td class="controls">
<a class="upload_delete_link delete_link emblem" href="{{ url('delete_upload/file/' ~ (upload.name | url_encode)) }}">
{{- icon_img("delete.svg", "delete" | translate) -}}
</a>
</td>
</tr>
{% else %}
<tr>
<td class="placeholder">
{{ icon_img("failure.svg", "", "emblem") }} {{ "No results" | translate }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="controls">
<form action="{{ self_url() }}" method="post" accept-charset="UTF-8">
<label for="uploads_sort">{{ "Sort results by:" | translate }}</label>
<select name="sort" id="uploads_sort">
{% for value, label in uploads_columns %}
<option value="{{ value }}"{{ value | selected(uploads_sort) }}>
{{ label }}
</option>
{% endfor %}
</select>
<button type="submit">{{ "Sort Results" | translate }}</button>
</form>
</div>
{% if uploads.paginated is not empty and uploads.pages > 1 %}
<div class="pagination">
<span class="pages">{{ "Page %d of %s" | translate | format(uploads.page, uploads.final_link(uploads.pages)) }}</span>
{{ uploads.prev_link }}
{{ uploads.next_link }}
</div>
{% endif %}
{% endblock %}