site-web-le-plus-beau-des-v.../index.php

102 lines
3.4 KiB
PHP
Raw Normal View History

<!DOCTYPE html>
<html lang="fr">
<head>
<!-- favicons -->
<link rel="apple-touch-icon" sizes="180x180"
href="assets/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32"
href="assets/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16"
href="assets/favicons/favicon-16x16.png">
<link rel="manifest" href="assets/favicons/site.webmanifest">
<link rel="mask-icon"
href="assets/favicons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<link rel="favicon" type="ico" href="assets/favicons/favicon.ico">
<!-- head data -->
<title>Le plus beau des voyages</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="scss/styles.css" />
2024-05-01 18:45:29 +02:00
</head>
<?php
$removeAcastBranding = function($text) {
return preg_replace(
"/<br \/>.+<\/p>/", "", $text
);
};
$formatDate = function($locale,$date) {
$fmt = new \IntlDateFormatter($locale, null, null);
$fmt->setPattern('d MMMM yyyy HH:mm');
$dateTimeCFF = DateTime::createFromFormat(
DateTime::RFC7231,
$date
);
return $fmt->format($dateTimeCFF);
};
$formatAudioData = function($rawAudioData) {
return "controls=true".
" src={$rawAudioData->url}".
" type={$rawAudioData->type}".
" length={$rawAudioData->length}";
};
$data = file_get_contents(
2024-05-01 16:42:21 +02:00
"https://feeds.acast.com/public/shows/le-plus-beau-des-voyages"
);
2024-05-01 18:45:29 +02:00
$xml = simplexml_load_string($data,'SimpleXMLElement', LIBXML_NOCDATA);
$podcast = (object) [
"title" => ucfirst(
strtolower($xml->channel->title)
),
"description" => $removeAcastBranding(
$xml->channel->description
),
"latestEpTitle" => $xml->channel->item[0]->title,
"latestEpPublicationDate" => $formatDate(
"fr_FR",$xml->channel->item[0]->pubDate
),
"latestEpDescription" => $removeAcastBranding(
$xml->channel->item[0]->description
),
"latestEpAudioData" => $formatAudioData($xml->channel->item[0]->enclosure->attributes())
];
2024-05-01 16:42:21 +02:00
?>
2024-05-01 18:45:29 +02:00
<body>
2024-05-02 18:49:34 +02:00
<div class="container">
<h1 class="cursive_font_bold text-center pt-3 pb-2"><?php echo $podcast->title ?></h1>
<div class="row">
<div class="col-sm"></div>
<div class="col-sm">
<p class="cursive_font fs-6 fw-lighter text-end">animé par Pauline</p>
</div>
<div class="col-sm"></div>
2024-05-01 18:45:29 +02:00
</div>
2024-05-02 18:49:34 +02:00
<p class="text-center"><?php echo $podcast->description ?></p>
<hr class="ms-2 me-2">
<!-- Episodes -->
2024-05-01 18:45:29 +02:00
<div>
2024-05-02 18:49:34 +02:00
2024-05-01 18:45:29 +02:00
</div>
</div>
</body>
2024-05-02 18:49:34 +02:00
</html>
<!--
<h1 class="cursive_font_bold"><?php echo $podcast->title ?></h1>
<p class="text-end">un podcast animé par Pauline</p>
<p><?php echo $podcast->description ?></p>
<h2>Épisodes :</h2>
<div>
<h3><?php echo $podcast->latestEpTitle ?></h3>
<p><?php echo $podcast->latestEpPublicationDate ?></p>
<div><?php echo $podcast->latestEpDescription ?></div>
<audio controls=true <?php echo $podcast->latestEpAudioData ?>>podcast audio</audio>
</div>
-->