Files
FWS-Website/p/paquets/detail.php
T
BlackAngelTV ae472fe30a fix(pages): make page URLs and assets base-aware
Root-absolute asset paths and ?p= links broke when the site is
served from a subfolder (WAMP). Screenshots from the database and
avatars from creators.json go through fws_url() as well.
2026-09-16 14:35:33 +02:00

112 lines
5.0 KiB
PHP

<?php
/**
* FWS Linux — page détail « /?p/paquets/N/ » (rendu serveur).
* Le paquet N en grand : badge, tagline, description, dernière release,
* historique, captures, liens. Pas de navigation précédent/suivant.
*/
declare(strict_types=1);
if (!defined('FWS_PAGE_SHELL')) {
/* Accès direct : /p/paquets/detail.php n'est pas une URL publique. */
http_response_code(404);
exit('Page introuvable.');
}
/* Le paquet N est identifié par son id en base ; repli sur la position. */
$pkg = null;
foreach ($packages as $i => $p) {
if ((int) ($p['dbId'] ?? 0) === $detailId || ($p['dbId'] ?? 0) === 0 && ($i + 1) === $detailId) {
$pkg = $p;
break;
}
}
if ($pkg === null) {
http_response_code(404);
$title = 'Paquet introuvable | FWS Linux';
echo '<section class="paquet-detail-page">'
. '<p class="paquet-empty">Ce paquet n\'existe pas (il y en a ' . count($packages) . ').</p>'
. '<a class="paquet-detail-back" href="' . e(fws_url('/?p/paquets/')) . '">&larr; Tous les paquets</a>'
. '</section>';
return;
}
$title = $pkg['name'] . ' | FWS Linux';
$description = (string) ($pkg['tagline'] ?? '') !== '' ? (string) $pkg['tagline'] : (string) ($pkg['description'] ?? '');
$extraJs[] = fws_url('/p/assets/js/packages-ui.js');
$latest = $pkg['latest'] ?? null;
?>
<section class="paquet-detail-page">
<a class="paquet-detail-back" href="<?= e(fws_url('/?p/paquets/')) ?>">&larr; Tous les paquets</a>
<div class="paquet-detail-hero">
<span class="paquet-since" title="<?= !empty($pkg['since']) ? e('Depuis le ' . fws_format_date((string) $pkg['since'])) : '' ?>"><?= e($pkg['sinceLabel'] !== '' ? $pkg['sinceLabel'] : 'FWS') ?></span>
<h1><?= e($pkg['name']) ?></h1>
<?php if (!empty($pkg['tagline'])): ?><p class="paquet-tagline"><?= e($pkg['tagline']) ?></p><?php endif; ?>
<?php if (!empty($pkg['description'])): ?><p class="paquet-description"><?= e($pkg['description']) ?></p><?php endif; ?>
<div class="paquet-detail-latest<?php if ($latest === null || ($latest['name'] ?? '') === ''): ?> paquet-detail-latest-empty<?php endif; ?>">
<?php if ($latest !== null && ($latest['name'] ?? '') !== ''): ?>
<span class="paquet-detail-version"><?= e((string) $latest['name']) ?></span>
<?php if (!empty($latest['date'])): ?>
<span class="paquet-detail-date">Publiée le <?= e(fws_format_date((string) $latest['date'])) ?></span>
<?php endif; ?>
<?php else: ?>
Aucune release publiée pour le moment.
<?php endif; ?>
</div>
</div>
<div class="paquet-detail-body">
<?php if (empty($pkg['changelog'])): ?>
<div class="paquet-changelog"><h3>Historique</h3><p class="paquet-empty">Historique en cours de rédaction.</p></div>
<?php else: ?>
<div class="paquet-changelog"><h3>Historique</h3>
<ol class="paquet-timeline">
<?php foreach ($pkg['changelog'] as $entry): ?>
<li class="paquet-timeline-item">
<strong class="paquet-timeline-version"><?= e((string) ($entry['version'] ?? '—')) ?></strong>
<time class="paquet-timeline-date"<?= !empty($entry['date']) ? ' datetime="' . e((string) $entry['date']) . '"' : '' ?>><?= e(fws_format_date(isset($entry['date']) ? (string) $entry['date'] : null)) ?></time>
<?php if (!empty($entry['notes'])): ?>
<span class="paquet-timeline-notes"><?= e((string) $entry['notes']) ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
</div>
<?php endif; ?>
<?php if (empty($pkg['screens'])): ?>
<div class="paquet-screens"><h3>Captures d'écran</h3><p class="paquet-empty">Captures d'écran à venir.</p></div>
<?php else: ?>
<div class="paquet-screens"><h3>Captures d'écran</h3>
<div class="paquet-screens-grid">
<?php foreach ($pkg['screens'] as $screen): ?>
<figure>
<img src="<?= e(fws_url((string) ($screen['src'] ?? ''))) ?>" alt="<?= e((string) ($screen['alt'] ?? $pkg['name'])) ?>" loading="lazy" data-zoom<?php if (!empty($screen['caption'])): ?> data-caption="<?= e((string) $screen['caption']) ?>"<?php endif; ?>>
<?php if (!empty($screen['caption'])): ?>
<figcaption><?= e((string) $screen['caption']) ?> <span class="paquet-zoom-hint">— cliquez pour agrandir</span></figcaption>
<?php else: ?>
<figcaption><span class="paquet-zoom-hint">Cliquez pour agrandir</span></figcaption>
<?php endif; ?>
</figure>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="paquet-links">
<h3>Liens utiles</h3>
<?php if (empty($pkg['links'])): ?>
<p class="paquet-empty">Aucun lien pour le moment.</p>
<?php else: ?>
<?php foreach ($pkg['links'] as $link): ?>
<?php $url = (string) ($link['url'] ?? ''); $external = (bool) preg_match('/^https?:\/\//i', $url); ?>
<a class="button button-secondary" href="<?= e($url) ?>"<?= $external ? ' target="_blank" rel="noopener noreferrer"' : '' ?>><?= e((string) ($link['label'] ?? '') !== '' ? (string) $link['label'] : $url) ?></a>
<?php endforeach; ?>
<?php endif; ?>
</div>
</section>