59 lines
2.3 KiB
PHP
59 lines
2.3 KiB
PHP
<?php
|
|||
|
|
/**
|
||
|
|
* Partial de rendu d'une carte vidéo.
|
||
|
|
*
|
||
|
|
* Centralise le balisage des cartes vidéo (accueil, catégories, recherche,
|
||
|
|
* endpoint AJAX « Voir plus ») afin de garantir un échappement systématique
|
||
|
|
* des données issues de l'API PeerTube (titres, chaînes, vignettes, avatars).
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Génère le HTML d'une carte vidéo, entièrement échappé.
|
||
|
|
*
|
||
|
|
* @param array $video Données formatées de la vidéo (voir formatVideosData())
|
||
|
|
* @return string HTML de la carte
|
||
|
|
*/
|
||
|
|
function renderVideoCard(array $video) {
|
||
|
|
$id = e($video['id'] ?? '');
|
||
|
|
$title = e($video['title'] ?? '');
|
||
|
|
$thumbnail = e($video['thumbnail'] ?? '');
|
||
|
|
$duration = e(formatDuration($video['duration'] ?? 0));
|
||
|
|
$channel = e($video['channel'] ?? '');
|
||
|
|
$channelAvatar = (string) ($video['channelAvatar'] ?? '');
|
||
|
|
$views = e(formatViewCount($video['views'] ?? 0));
|
||
|
|
$date = e(formatDate($video['date'] ?? ''));
|
||
|
|
|
||
|
|
ob_start();
|
||
|
|
?>
|
||
|
|
<article class="video-card" data-video-id="<?php echo $id; ?>">
|
||
|
|
<div class="video-thumbnail">
|
||
|
|
<img src="<?php echo $thumbnail; ?>" alt="<?php echo $title; ?>">
|
||
|
|
<div class="video-play-icon" aria-hidden="true">
|
||
|
|
<i class="fas fa-play-circle"></i>
|
||
|
|
</div>
|
||
|
|
<div class="video-duration"><?php echo $duration; ?></div>
|
||
|
|
</div>
|
||
|
|
<div class="video-info">
|
||
|
|
<h3 class="video-title"><?php echo $title; ?></h3>
|
||
|
|
<div class="video-channel">
|
||
|
|
<?php if ($channelAvatar === '' || strpos($channelAvatar, 'default-avatar') !== false): ?>
|
||
|
|
<div class="channel-avatar-placeholder">
|
||
|
|
<i class="fas fa-user-circle"></i>
|
||
|
|
</div>
|
||
|
|
<?php else: ?>
|
||
|
|
<img src="<?php echo e($channelAvatar); ?>" alt="<?php echo $channel; ?>" class="channel-avatar">
|
||
|
|
<?php endif; ?>
|
||
|
|
<span class="channel-name"><?php echo $channel; ?></span>
|
||
|
|
</div>
|
||
|
|
<div class="video-metadata">
|
||
|
|
<?php if (defined('SHOW_VIDEO_VIEWS') && SHOW_VIDEO_VIEWS): ?>
|
||
|
|
<span class="video-views"><i class="fas fa-eye"></i> <?php echo $views; ?> vues</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
<span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo $date; ?></span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</article>
|
||
|
|
<?php
|
||
|
|
return ob_get_clean();
|
||
|
|
}
|