134 lines
5.8 KiB
PHP
134 lines
5.8 KiB
PHP
<?php
|
|||
|
|
/**
|
||
|
|
* Partial : annonce du prochain live (constantes NEXT_LIVE_*).
|
||
|
|
*
|
||
|
|
* Factorise le bloc « prochain live » affiché par direct.php et
|
||
|
|
* includes/hero-section.php quand aucun direct n'est en cours (ARC-4).
|
||
|
|
* Prérequis : n'inclure ce partial que si NEXT_LIVE_ENABLED === true.
|
||
|
|
*
|
||
|
|
* Variable d'entrée :
|
||
|
|
* - $nextLiveVariant (string) : 'page' (direct.php, défaut) ou 'hero'
|
||
|
|
* (hero-section) — adapte les classes CSS, le niveau de titre et le
|
||
|
|
* lien « Retour à l'accueil ».
|
||
|
|
*/
|
||
|
|
|
||
|
|
$nextLiveVariant = $nextLiveVariant ?? 'page';
|
||
|
|
$isHeroVariant = $nextLiveVariant === 'hero';
|
||
|
|
|
||
|
|
// Classes CSS : le hero préfixe toutes ses classes par « hero-next-live »
|
||
|
|
$rootClass = $isHeroVariant ? 'hero-next-live' : 'next-live-announcement';
|
||
|
|
$imageContainerClass = $isHeroVariant ? 'hero-next-live-image-container' : 'next-live-image-container';
|
||
|
|
$imageClass = $isHeroVariant ? 'hero-next-live-image' : 'next-live-image';
|
||
|
|
$contentClass = $isHeroVariant ? 'hero-next-live-content' : 'next-live-content';
|
||
|
|
$datetimeClass = $isHeroVariant ? 'hero-next-live-datetime' : 'next-live-datetime';
|
||
|
|
$dateClass = $isHeroVariant ? 'hero-next-live-date' : 'next-live-date';
|
||
|
|
$timezonesClass = $isHeroVariant ? 'hero-next-live-timezones' : 'next-live-timezones';
|
||
|
|
$timezoneItemClass = $isHeroVariant ? 'hero-timezone-item' : 'timezone-item';
|
||
|
|
$headingTag = $isHeroVariant ? 'h2' : 'h1';
|
||
|
|
|
||
|
|
// Définir l'image de fond si disponible
|
||
|
|
$bgImageStyle = '';
|
||
|
|
if (!empty(NEXT_LIVE_IMAGE) && file_exists(NEXT_LIVE_IMAGE)) {
|
||
|
|
$bgImageStyle = 'background-image: url(\'' . htmlspecialchars(NEXT_LIVE_IMAGE) . '\');';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<?php if (!empty($bgImageStyle)): ?>
|
||
|
|
<style nonce="<?php echo getCspNonce(); ?>">
|
||
|
|
.<?php echo $rootClass; ?> { <?php echo $bgImageStyle; ?> }
|
||
|
|
</style>
|
||
|
|
<?php endif; ?>
|
||
|
|
<div class="<?php echo $rootClass; ?>">
|
||
|
|
<?php if (!empty(NEXT_LIVE_IMAGE) && file_exists(NEXT_LIVE_IMAGE)): ?>
|
||
|
|
<div class="<?php echo $imageContainerClass; ?>">
|
||
|
|
<img src="<?php echo htmlspecialchars(NEXT_LIVE_IMAGE); ?>"
|
||
|
|
alt="<?php echo htmlspecialchars(NEXT_LIVE_TITLE); ?>"
|
||
|
|
class="<?php echo $imageClass; ?>">
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<div class="<?php echo $contentClass; ?>">
|
||
|
|
<i class="fas fa-calendar-alt"></i>
|
||
|
|
<?php
|
||
|
|
if (!empty(NEXT_LIVE_DATE)) {
|
||
|
|
$liveDate = new DateTime(NEXT_LIVE_DATE, new DateTimeZone(DEFAULT_TIMEZONE));
|
||
|
|
$dayFormatter = new IntlDateFormatter(
|
||
|
|
'fr_FR',
|
||
|
|
IntlDateFormatter::FULL,
|
||
|
|
IntlDateFormatter::NONE,
|
||
|
|
DEFAULT_TIMEZONE,
|
||
|
|
IntlDateFormatter::GREGORIAN,
|
||
|
|
'EEEE d MMMM'
|
||
|
|
);
|
||
|
|
$formattedDay = $dayFormatter->format($liveDate);
|
||
|
|
$formattedDay = ucfirst($formattedDay);
|
||
|
|
$dynamicTitle = NEXT_LIVE_TITLE . ' - ' . $formattedDay;
|
||
|
|
} else {
|
||
|
|
$dynamicTitle = NEXT_LIVE_TITLE;
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<<?php echo $headingTag; ?>><?php echo htmlspecialchars($dynamicTitle); ?></<?php echo $headingTag; ?>>
|
||
|
|
<?php
|
||
|
|
if (!empty(NEXT_LIVE_DATE)) {
|
||
|
|
$liveHour = $liveDate->format('H\hi');
|
||
|
|
$dynamicDescription = 'Rejoignez-nous à ' . $liveHour . '. ' . NEXT_LIVE_DESCRIPTION;
|
||
|
|
} else {
|
||
|
|
$dynamicDescription = NEXT_LIVE_DESCRIPTION;
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<p><?php echo nl2br(htmlspecialchars($dynamicDescription)); ?></p>
|
||
|
|
<?php if (!empty(NEXT_LIVE_DATE)): ?>
|
||
|
|
<div class="<?php echo $datetimeClass; ?>">
|
||
|
|
<p class="<?php echo $dateClass; ?>">
|
||
|
|
<i class="fas fa-clock"></i>
|
||
|
|
<?php
|
||
|
|
$formatter = new IntlDateFormatter(
|
||
|
|
'fr_FR',
|
||
|
|
IntlDateFormatter::FULL,
|
||
|
|
IntlDateFormatter::SHORT,
|
||
|
|
DEFAULT_TIMEZONE
|
||
|
|
);
|
||
|
|
echo $formatter->format($liveDate);
|
||
|
|
|
||
|
|
$offset = $liveDate->format('P');
|
||
|
|
echo ' <span class="utc-offset">(UTC' . $offset . ')</span>';
|
||
|
|
?>
|
||
|
|
</p>
|
||
|
|
|
||
|
|
<!-- Autres fuseaux horaires -->
|
||
|
|
<div class="<?php echo $timezonesClass; ?>">
|
||
|
|
<?php
|
||
|
|
// Ordre croissant : du plus en retard au plus en avance
|
||
|
|
$timezones = [
|
||
|
|
'Ma\'ohi Nui' => 'Pacific/Tahiti',
|
||
|
|
'Martinique / Guadeloupe' => 'America/Martinique',
|
||
|
|
'Guyane' => 'America/Cayenne',
|
||
|
|
'France' => 'Europe/Paris',
|
||
|
|
'Kanaky' => 'Pacific/Noumea'
|
||
|
|
];
|
||
|
|
|
||
|
|
foreach($timezones as $name => $timezone):
|
||
|
|
$liveDateLocal = clone $liveDate;
|
||
|
|
$liveDateLocal->setTimezone(new DateTimeZone($timezone));
|
||
|
|
|
||
|
|
// Vérifier si c'est un jour différent
|
||
|
|
$dayDiff = $liveDateLocal->format('j') - $liveDate->format('j');
|
||
|
|
|
||
|
|
$dayIndicator = '';
|
||
|
|
if ($dayDiff > 0) {
|
||
|
|
$dayIndicator = ' <span class="day-shift">+1j</span>';
|
||
|
|
} elseif ($dayDiff < 0) {
|
||
|
|
$dayIndicator = ' <span class="day-shift">-1j</span>';
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<span class="<?php echo $timezoneItemClass; ?>">
|
||
|
|
<strong><?php echo $name; ?> :</strong> <?php echo $liveDateLocal->format('H\hi'); ?><?php echo $dayIndicator; ?>
|
||
|
|
</span>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if (!$isHeroVariant): ?>
|
||
|
|
<a href="index.php" class="btn-primary">Retour à l'accueil</a>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|