tfe.php: afficher CC2r + licence, formater contact court, supprimer download PDF

This commit is contained in:
Pontoporeia
2026-06-08 11:35:53 +02:00
parent 24b753a992
commit cee3345ea3
3 changed files with 27 additions and 8 deletions

View File

@@ -164,10 +164,13 @@
</p>
<?php endif; ?>
<?php if (!empty($data["license_type"])): ?>
<?php
$_cc2r = !empty($data["cc2r"]);
$_lic = !empty($data["license_type"]) ? $data["license_type"] : ($data["license_custom"] ?? null);
if ($_cc2r || $_lic): ?>
<p class="tfe-meta-item">
<span class="tfe-meta-label">Licence :</span>
<?= htmlspecialchars($data["license_type"]) ?>
<?= htmlspecialchars(implode(", ", array_filter([$_cc2r ? "CC2r" : null, $_lic]))) ?>
</p>
<?php endif; ?>
@@ -185,9 +188,22 @@
$_contact = $data["contact_interne"];
$_isUrl = filter_var($_contact, FILTER_VALIDATE_URL) !== false;
$_isEmail = !$_isUrl && str_contains($_contact, "@");
if ($_isUrl): ?>
if ($_isUrl):
$_host = parse_url($_contact, PHP_URL_HOST);
$_path = parse_url($_contact, PHP_URL_PATH) ?? '';
$_isInstagram = $_host && str_contains($_host, 'instagram.com');
$_isMastodon = $_path && str_contains($_path, '/@');
if ($_isInstagram):
$_username = trim($_path, '/');
$_display = $_username ? '@' . $_username : preg_replace("#^https?://(www\.)?#i", "", rtrim($_contact, "/"));
elseif ($_isMastodon):
$_username = trim($_path, '/@');
$_display = $_username ? '@' . $_username : preg_replace("#^https?://(www\.)?#i", "", rtrim($_contact, "/"));
else:
$_display = preg_replace("#^https?://(www\.)?#i", "", rtrim($_contact, "/"));
endif; ?>
<a href="<?= htmlspecialchars($_contact) ?>" target="_blank" rel="noopener">
<?= htmlspecialchars(preg_replace("#^https?://#i", "", rtrim($_contact, "/"))) ?>
<?= htmlspecialchars($_display) ?>
<span class="sr-only">(ouvre dans un nouvel onglet)</span>
</a>
<?php elseif ($_isEmail): ?>
@@ -201,7 +217,7 @@
<?php if (!empty($data["baiu_link"])): ?>
<?php
$_baiuHref = htmlspecialchars($data["baiu_link"]);
$_baiuLabel = preg_replace("#^https?://#i", "", rtrim($data["baiu_link"], "/"));
$_baiuLabel = preg_replace("#^https?://(www\\.)?#i", "", rtrim($data["baiu_link"], "/"));
?>
<p class="tfe-meta-item">
<span class="tfe-meta-label">Lien :</span>
@@ -326,9 +342,6 @@
style="border:none"
title="<?= $fileName ?>">
</iframe>
<p class="tfe-pdf-fallback">
<a href="<?= $mediaUrl ?>&download=1">Télécharger le PDF</a>
</p>
<?php elseif ($isWebsite): ?>
<iframe src="<?= $mediaUrl ?>"
width="100%" height="700px"