feat: add next live announcement with multi-timezone display
This commit is contained in:
@@ -142,14 +142,111 @@ setSecurityHeaders();
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
// Aucun direct en cours
|
||||
?>
|
||||
<div class="hero-no-live">
|
||||
<i class="fas fa-tv"></i>
|
||||
<h2>Aucun direct en cours</h2>
|
||||
<p>Revenez plus tard pour découvrir nos prochaines diffusions en direct.</p>
|
||||
</div>
|
||||
<?php
|
||||
// Aucun direct en cours - vérifier s'il y a une annonce configurée
|
||||
$showNextLiveAnnouncement = defined('NEXT_LIVE_ENABLED') && NEXT_LIVE_ENABLED === true;
|
||||
|
||||
if ($showNextLiveAnnouncement) {
|
||||
// Afficher l'annonce du prochain live
|
||||
?>
|
||||
<div class="hero-next-live">
|
||||
<?php if (!empty(NEXT_LIVE_IMAGE) && file_exists(NEXT_LIVE_IMAGE)): ?>
|
||||
<div class="hero-next-live-image-container">
|
||||
<img src="<?php echo htmlspecialchars(NEXT_LIVE_IMAGE); ?>"
|
||||
alt="<?php echo htmlspecialchars(NEXT_LIVE_TITLE); ?>"
|
||||
class="hero-next-live-image">
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="hero-next-live-content">
|
||||
<i class="fas fa-calendar-alt"></i>
|
||||
<?php
|
||||
if (!empty(NEXT_LIVE_DATE)) {
|
||||
$liveDate = new DateTime(NEXT_LIVE_DATE, new DateTimeZone('Indian/Reunion'));
|
||||
$dayFormatter = new IntlDateFormatter(
|
||||
'fr_FR',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::NONE,
|
||||
'Indian/Reunion',
|
||||
IntlDateFormatter::GREGORIAN,
|
||||
'EEEE d MMMM'
|
||||
);
|
||||
$formattedDay = $dayFormatter->format($liveDate);
|
||||
$formattedDay = ucfirst($formattedDay);
|
||||
$dynamicTitle = NEXT_LIVE_TITLE . ' - ' . $formattedDay;
|
||||
} else {
|
||||
$dynamicTitle = NEXT_LIVE_TITLE;
|
||||
}
|
||||
?>
|
||||
<h2><?php echo htmlspecialchars($dynamicTitle); ?></h2>
|
||||
<?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="hero-next-live-datetime">
|
||||
<p class="hero-next-live-date">
|
||||
<i class="fas fa-clock"></i>
|
||||
<?php
|
||||
$formatter = new IntlDateFormatter(
|
||||
'fr_FR',
|
||||
IntlDateFormatter::FULL,
|
||||
IntlDateFormatter::SHORT,
|
||||
'Indian/Reunion'
|
||||
);
|
||||
echo $formatter->format($liveDate);
|
||||
|
||||
$offset = $liveDate->format('P');
|
||||
echo ' <span class="utc-offset">(UTC' . $offset . ')</span>';
|
||||
?>
|
||||
</p>
|
||||
|
||||
<!-- Autres fuseaux horaires -->
|
||||
<div class="hero-next-live-timezones">
|
||||
<?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));
|
||||
$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="hero-timezone-item">
|
||||
<strong><?php echo $name; ?> :</strong> <?php echo $liveDateLocal->format('H\hi'); ?><?php echo $dayIndicator; ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="hero-no-live">
|
||||
<i class="fas fa-tv"></i>
|
||||
<h2>Aucun direct en cours</h2>
|
||||
<p>Revenez plus tard pour découvrir nos prochaines diffusions en direct.</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user