handle licence in video page

This commit is contained in:
2025-04-10 08:10:06 +04:00
parent e62f62a57b
commit d80ba9031e
2 changed files with 124 additions and 15 deletions
+57 -1
View File
@@ -32,7 +32,8 @@ if (empty($videoData) || isset($videoData['error'])) {
'views' => $videoData['views'],
'likes' => $videoData['likes'],
'date' => $videoData['publishedAt'],
'tags' => $videoData['tags'] ?? []
'tags' => $videoData['tags'] ?? [],
'licence' => $videoData['licence'] ?? null
];
// Récupérer l'image de la chaîne
@@ -182,6 +183,61 @@ if (empty($videoData) || isset($videoData['error'])) {
</button>
</div>
</div>
<?php if (!empty($video['licence'])): ?>
<div class="video-licence">
<h4 class="licence-title">Licence</h4>
<?php
$licenceLabels = [
1 => "Attribution",
2 => "Attribution - Share Alike",
3 => "Attribution - No Derivatives",
4 => "Attribution - Non Commercial",
5 => "Attribution - Non Commercial - Share Alike",
6 => "Attribution - Non Commercial - No Derivatives",
7 => "Public Domain Dedication"
];
$licenceUrls = [
1 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by.png",
2 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by-sa.png",
3 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by-nd.png",
4 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by-nc.png",
5 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by-nc-sa.png",
6 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/by-nc-nd.png",
7 => "https://mirrors.creativecommons.org/presskit/buttons/88x31/png/cc-zero.png"
];
$licenceInfoUrls = [
1 => "https://creativecommons.org/licenses/by/4.0/deed.fr",
2 => "https://creativecommons.org/licenses/by-sa/4.0/deed.fr",
3 => "https://creativecommons.org/licenses/by-nd/4.0/deed.fr",
4 => "https://creativecommons.org/licenses/by-nc/4.0/deed.fr",
5 => "https://creativecommons.org/licenses/by-nc-sa/4.0/deed.fr",
6 => "https://creativecommons.org/licenses/by-nc-nd/4.0/deed.fr",
7 => "https://creativecommons.org/publicdomain/zero/1.0/deed.fr"
];
$licenceId = $video['licence']['id'];
$licenceLabel = isset($licenceLabels[$licenceId]) ? $licenceLabels[$licenceId] : "Licence inconnue";
$licenceUrl = isset($licenceUrls[$licenceId]) ? $licenceUrls[$licenceId] : "";
$licenceInfoUrl = isset($licenceInfoUrls[$licenceId]) ? $licenceInfoUrls[$licenceId] : "";
?>
<div class="licence-info">
<?php if (!empty($licenceUrl) && !empty($licenceInfoUrl)): ?>
<a href="<?php echo $licenceInfoUrl; ?>" target="_blank" rel="noopener noreferrer" class="licence-link" title="En savoir plus sur cette licence">
<img src="<?php echo $licenceUrl; ?>" alt="<?php echo $licenceLabel; ?>" class="licence-logo">
<span class="licence-label"><?php echo $licenceLabel; ?></span>
</a>
<?php else: ?>
<?php if (!empty($licenceUrl)): ?>
<img src="<?php echo $licenceUrl; ?>" alt="<?php echo $licenceLabel; ?>" class="licence-logo">
<?php endif; ?>
<span class="licence-label"><?php echo $licenceLabel; ?></span>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="video-secondary-info">