fix: masquer le bloc "Durée" sur la page TFE quand aucune durée n'est encodée

This commit is contained in:
Pontoporeia
2026-07-10 11:56:27 +02:00
parent b0925d9cfa
commit 28c0efe755
2 changed files with 12 additions and 9 deletions
+11 -9
View File
@@ -46,20 +46,22 @@
<?php
$_hasPages = isset($data["duration_pages"]) && $data["duration_pages"] !== null && $data["duration_pages"] !== '';
$_hasMins = isset($data["duration_minutes"]) && $data["duration_minutes"] !== null && $data["duration_minutes"] !== '';
$_parts = [];
if ($_hasPages) $_parts[] = $data['duration_pages'] . ' pages';
if ($_hasMins) {
$_h = (int)floor((int)$data['duration_minutes'] / 60);
$_m = (int)$data['duration_minutes'] % 60;
$_parts[] = $_h . 'h' . str_pad((string)$_m, 2, '0', STR_PAD_LEFT);
}
$_duree = $_parts ? htmlspecialchars(implode(', ', $_parts)) : '';
unset($_hasPages, $_hasMins, $_parts, $_h, $_m);
if ($_hasPages || $_hasMins):
$_parts = [];
if ($_hasPages) $_parts[] = $data['duration_pages'] . ' pages';
if ($_hasMins) {
$_h = (int)floor((int)$data['duration_minutes'] / 60);
$_m = (int)$data['duration_minutes'] % 60;
$_parts[] = $_h . 'h' . str_pad((string)$_m, 2, '0', STR_PAD_LEFT);
}
$_duree = htmlspecialchars(implode(', ', $_parts));
unset($_h, $_m);
?>
<p class="tfe-meta-item">
<span class="tfe-meta-label">Durée :</span>
<?= $_duree ?>
</p>
<?php endif; unset($_hasPages, $_hasMins, $_parts, $_duree); ?>
<?php if (!empty($data["languages"])): ?>
<p class="tfe-meta-item">