mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
style: unify recap+edit file figure styling — two-column grid dl, vertical spacing, admin-back-btn sizing, standardise file display and delete-to-trash SVG icons
This commit is contained in:
@@ -16,6 +16,21 @@
|
||||
*/
|
||||
|
||||
require_once APP_ROOT . '/src/PeerTubeService.php';
|
||||
|
||||
if (!function_exists('formatFileSize')) {
|
||||
function formatFileSize($bytes) {
|
||||
if ($bytes >= 1073741824) {
|
||||
return number_format($bytes / 1073741824, 2) . ' GB';
|
||||
} elseif ($bytes >= 1048576) {
|
||||
return number_format($bytes / 1048576, 2) . ' MB';
|
||||
} elseif ($bytes >= 1024) {
|
||||
return number_format($bytes / 1024, 2) . ' KB';
|
||||
} else {
|
||||
return $bytes . ' bytes';
|
||||
}
|
||||
}
|
||||
} // if (!function_exists('formatFileSize'))
|
||||
|
||||
$_ptDb = Database::getInstance();
|
||||
$peerTubeEnabled = PeerTubeService::isEnabled($_ptDb);
|
||||
$peerTubeSettings = PeerTubeService::getSettings($_ptDb);
|
||||
@@ -103,16 +118,22 @@ $websiteLabel = htmlspecialchars($_POST['website_label'] ?? '');
|
||||
foreach ($_thesisFilesList as $_f):
|
||||
$_fPath = $_f["file_path"] ?? "";
|
||||
$_fIsPeerTube = str_starts_with($_fPath, "peertube_ids:");
|
||||
$_fMime = $_f["mime_type"] ?? "";
|
||||
$_fExt = strtolower(pathinfo($_fPath, PATHINFO_EXTENSION));
|
||||
$_fType = $_f["file_type"] ?? "other";
|
||||
$_fLabel = $_f["display_label"] ?? "";
|
||||
$_fIsImage = str_starts_with($_fMime, "image/") || in_array($_fExt, ["jpg","jpeg","png","gif","webp"]);
|
||||
$_fIcon = match (true) {
|
||||
$_fIsPeerTube && $_fType === "video" => "🎬",
|
||||
$_fIsPeerTube && $_fType === "audio" => "🔊",
|
||||
$_fType === "main" || $_fExt === "pdf" => "📄",
|
||||
in_array($_fExt, ["jpg","jpeg","png","gif","webp"]) => "🖼️",
|
||||
$_fType === "video" || in_array($_fExt, ["mp4","webm","mov","ogv"]) => "🎬",
|
||||
$_fType === "audio" || in_array($_fExt, ["mp3","ogg","wav","flac","aac","m4a"]) => "🔊",
|
||||
$_fType === "cover" => "🖼️",
|
||||
$_fType === "note_intention" => "📝",
|
||||
$_fType === "main" || $_fMime === "application/pdf" || $_fExt === "pdf" => "📄",
|
||||
$_fType === "video" || str_starts_with($_fMime, "video/") || in_array($_fExt, ["mp4","webm","mov","ogv"]) => "🎬",
|
||||
$_fType === "audio" || str_starts_with($_fMime, "audio/") || in_array($_fExt, ["mp3","ogg","wav","flac","aac","m4a"]) => "🔊",
|
||||
$_fIsImage => "🖼️",
|
||||
$_fType === "caption" || $_fExt === "vtt" => "💬",
|
||||
$_fType === "annex" => "📎",
|
||||
$_fType === "website" => "🌐",
|
||||
default => "📎",
|
||||
};
|
||||
@@ -122,7 +143,11 @@ $websiteLabel = htmlspecialchars($_POST['website_label'] ?? '');
|
||||
<li class="admin-file-list-item" data-file-id="<?= (int)$_f["id"] ?>">
|
||||
<input type="hidden" name="file_sort_order[]" value="<?= (int)$_f["id"] ?>">
|
||||
<figure class="admin-file-figure">
|
||||
<?php if ($_fIsImage && !$_fIsPeerTube): ?>
|
||||
<img src="/media?path=<?= urlencode($_fPath) ?>" alt="<?= htmlspecialchars($_f["file_name"] ?? basename($_f["file_path"])) ?>" class="admin-file-thumb" loading="lazy">
|
||||
<?php else: ?>
|
||||
<span class="admin-file-icon"><?= $_fIcon ?></span>
|
||||
<?php endif; ?>
|
||||
<figcaption class="admin-file-caption">
|
||||
<div class="admin-file-name-row">
|
||||
<a href="<?= $_fLinkHref ?>" target="_blank" rel="noopener" class="admin-file-name">
|
||||
@@ -132,10 +157,16 @@ $websiteLabel = htmlspecialchars($_POST['website_label'] ?? '');
|
||||
<?php if ($_fIsPeerTube): ?>
|
||||
<span class="admin-file-peertube-id">ID : <?= htmlspecialchars(substr($_fPath, strlen("peertube_ids:"))) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ($_fLabel): ?>
|
||||
<span class="admin-file-label"><?= htmlspecialchars($_fLabel) ?></span>
|
||||
<?php endif; ?>
|
||||
<span class="admin-file-meta-row">
|
||||
<span class="admin-file-type-badge"><?= htmlspecialchars($_fType) ?></span>
|
||||
<span class="admin-file-meta"><?= htmlspecialchars($_fType) ?></span>
|
||||
<?php if (!empty($_f["file_size"]) && $_f["file_size"] > 0): ?>
|
||||
<span class="admin-file-size"><?= number_format($_f["file_size"] / 1024 / 1024, 2) ?> MB</span>
|
||||
<span class="admin-file-meta"><?= formatFileSize($_f["file_size"]) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($_f["uploaded_at"])): ?>
|
||||
<span class="admin-file-meta"><?= date('d/m/Y H:i', strtotime($_f["uploaded_at"])) ?></span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</figcaption>
|
||||
|
||||
Reference in New Issue
Block a user