318 lines
13 KiB
PHP
318 lines
13 KiB
PHP
<?php snippet('header') ?>
|
|
<?php
|
|
$lang = kirby()->language();
|
|
$locale = $lang ? $lang->locale(LC_ALL) : 'fr_FR.UTF-8';
|
|
$dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
|
|
?>
|
|
<main>
|
|
|
|
<?php foreach ($page->sections()->toStructure() as $section):
|
|
|
|
$type = $section->contentType()->value();
|
|
$count = max(4, (int)$section->count()->value());
|
|
|
|
[$seeMoreLabel, $seeMoreUrl] = match($type) {
|
|
'investigations' => ['Voir toutes les enquêtes', page('enquetes')->url()],
|
|
'impacts' => ['Voir tous les impacts', page('impacts')->url()],
|
|
'packages' => ['Voir tous les dossiers', page('packages')->url()],
|
|
'projects' => ['Voir tous les projets', site()->find('laboratoire')->url()],
|
|
'news' => ['Voir toutes les brèves', page('news')->url()],
|
|
default => ['Voir tout', '/'],
|
|
};
|
|
?>
|
|
|
|
<section class="section--home" id="home__<?= esc($type) ?>">
|
|
<div class="section--inner">
|
|
|
|
<div class="col-left">
|
|
<?php if ($section->baseline()->isNotEmpty()): ?>
|
|
<p class="baseline-section"><?= $section->baseline() ?></p>
|
|
<?php endif ?>
|
|
|
|
<?php if ($section->buttonText()->isNotEmpty()): ?>
|
|
<button class="btn--bold-inline">
|
|
<a href="<?= $section->buttonLink()->esc() ?>">
|
|
<span class="text"><?= $section->buttonText()->esc() ?></span>
|
|
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
|
</a>
|
|
</button>
|
|
<?php endif ?>
|
|
</div><!-- .col-left -->
|
|
|
|
<div class="col-right">
|
|
|
|
<?php if ($type === 'investigations'): ?>
|
|
|
|
<?php
|
|
$enquetesPage = page('enquetes');
|
|
$superPin = $enquetesPage->superPinnedInvestigation()->toPage();
|
|
$pinned = $enquetesPage->pinnedInvestigations()->toPages();
|
|
if ($superPin) $pinned = $pinned->not($superPin);
|
|
|
|
$list = [];
|
|
$shownIds = [];
|
|
|
|
if ($superPin) {
|
|
$list[] = ['page' => $superPin, 'type' => 'super'];
|
|
$shownIds[] = $superPin->id();
|
|
}
|
|
|
|
foreach ($pinned as $p) {
|
|
if (count($list) >= $count) break;
|
|
$list[] = ['page' => $p, 'type' => 'pinned'];
|
|
$shownIds[] = $p->id();
|
|
}
|
|
|
|
if (count($list) < $count) {
|
|
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
|
|
->filter(fn($p) => !in_array($p->id(), $shownIds))
|
|
->limit($count - count($list));
|
|
foreach ($latest as $p) {
|
|
$list[] = ['page' => $p, 'type' => 'latest'];
|
|
}
|
|
}
|
|
?>
|
|
|
|
<?php foreach ($list as $item):
|
|
$investigation = $item['page'];
|
|
$itype = $item['type'];
|
|
$cover = $investigation->cover()->toFile();
|
|
?>
|
|
<article class="card--article<?= $itype === 'super' ? ' pinned-home' : ($itype === 'pinned' ? ' pinned' : '') ?>">
|
|
|
|
<?php if ($itype === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
|
|
<div class="video-extract">
|
|
<video class="vjs-tech" tabindex="-1" loop muted playsinline autoplay src="<?= $videoPreview->url() ?>"></video>
|
|
</div>
|
|
<?php elseif ($cover): ?>
|
|
<figure>
|
|
<img src="<?= $cover->url() ?>" alt="<?= $investigation->title()->esc() ?>">
|
|
</figure>
|
|
<?php endif ?>
|
|
|
|
<?php if ($itype === 'pinned'): ?>
|
|
<div class="pin"><?= svg('assets/icons/pin.svg') ?></div>
|
|
<?php endif ?>
|
|
|
|
<h4 class="title"><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></h4>
|
|
|
|
<?php if ($investigation->chapo()->isNotEmpty()): ?>
|
|
<p class="description"><?= $investigation->chapo()->excerpt(200) ?></p>
|
|
<?php endif ?>
|
|
|
|
<dl class="dl">
|
|
<?php if ($investigation->incidentDate()->isNotEmpty()): ?>
|
|
<div class="dl__group">
|
|
<dt>Date de l'incident</dt>
|
|
<dd><time datetime="<?= $investigation->incidentDate()->toDate('yyyy-MM-dd') ?>"><?= $investigation->incidentDate()->toDate('d MMMM yyyy', $dateLocale) ?></time></dd>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<?php if (($partners = $investigation->partners()->toStructure()) && $partners->isNotEmpty()): ?>
|
|
<div class="dl__group">
|
|
<dt>Partenaire(s)</dt>
|
|
<dd><?php $names = []; foreach ($partners as $partner) $names[] = $partner->name()->value(); echo implode(', ', $names) ?></dd>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<?php if ($investigation->incidentLocation()->isNotEmpty()): ?>
|
|
<div class="dl__group">
|
|
<dt>Lieu de l'incident</dt>
|
|
<dd><?= $investigation->incidentLocation()->esc() ?></dd>
|
|
</div>
|
|
<?php endif ?>
|
|
</dl>
|
|
|
|
<?php if ($keywords = $investigation->keywords()->split()): ?>
|
|
<div class="keywords-wrapper">
|
|
<ul class="keywords">
|
|
<?php foreach ($keywords as $keyword): ?>
|
|
<li><a href="#keyword" target="_blank"><?= esc($keyword) ?></a></li>
|
|
<?php endforeach ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<a class="link-block" href="<?= $investigation->url() ?>"></a>
|
|
</article>
|
|
<?php endforeach ?>
|
|
|
|
<?php elseif ($type === 'impacts'): ?>
|
|
|
|
<div class="grid-masonry">
|
|
<div class="grid-sizer"></div>
|
|
|
|
<?php foreach (page('impacts')->children()->listed()->sortBy('created', 'desc')->limit($count) as $impact):
|
|
$categories = $impact->category()->split();
|
|
$category = $categories[0] ?? '';
|
|
$cover = $impact->cover()->toFile();
|
|
$investigations = $impact->linkedInvestigations()->toPages();
|
|
?>
|
|
<div class="card--block has-link"
|
|
data-impact-type="<?= esc(Str::slug($category)) ?>"
|
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
|
data-date="<?= $impact->created()->isNotEmpty() ? $impact->created()->toDate('yyyy-MM-dd') : '' ?>">
|
|
|
|
<?php if ($cover): ?>
|
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
|
<?php endif ?>
|
|
|
|
<div class="group-top">
|
|
<p class="type">Impact</p>
|
|
<?php if ($category): ?>
|
|
<p class="category"><?= esc($category) ?></p>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<h3 class="title"><?= $impact->title()->esc() ?></h3>
|
|
|
|
<?php if ($impact->created()->isNotEmpty()): ?>
|
|
<p class="date"><time datetime="<?= $impact->created()->toDate('yyyy-MM-dd') ?>"><?= $impact->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
|
<?php endif ?>
|
|
|
|
<?php if ($investigations->isNotEmpty()): ?>
|
|
<ul class="investigations">
|
|
<?php foreach ($investigations as $investigation): ?>
|
|
<li><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></li>
|
|
<?php endforeach ?>
|
|
</ul>
|
|
<?php endif ?>
|
|
|
|
<a class="link-block" href="<?= $impact->url() ?>"></a>
|
|
</div>
|
|
<?php endforeach ?>
|
|
</div>
|
|
|
|
<?php elseif ($type === 'packages'): ?>
|
|
|
|
<div class="container-cards">
|
|
<?php foreach (page('packages')->children()->listed()->limit($count) as $package):
|
|
$cover = $package->cover()->toFile();
|
|
$investigationsCount = $package->linkedContent()->toPages()->count();
|
|
$impactsCount = $package->linkedImpacts()->toPages()->count();
|
|
?>
|
|
<article class="card--package">
|
|
<?php if ($cover): ?>
|
|
<figure>
|
|
<img src="<?= $cover->url() ?>" alt="<?= $package->title()->esc() ?>">
|
|
</figure>
|
|
<?php endif ?>
|
|
|
|
<div class="content">
|
|
<p class="type"><?= t('package.type') ?></p>
|
|
<h4 class="title">
|
|
<a href="<?= $package->url() ?>">
|
|
<span class="icon"><?= svg('assets/icons/package.svg') ?></span>
|
|
<?= $package->title()->esc() ?>
|
|
</a>
|
|
</h4>
|
|
|
|
<?php if ($investigationsCount > 0 || $impactsCount > 0): ?>
|
|
<ul class="details">
|
|
<?php if ($investigationsCount > 0): ?>
|
|
<li><?= $investigationsCount ?> enquête<?= $investigationsCount > 1 ? 's' : '' ?></li>
|
|
<?php endif ?>
|
|
<?php if ($impactsCount > 0): ?>
|
|
<li><?= $impactsCount ?> impact<?= $impactsCount > 1 ? 's' : '' ?></li>
|
|
<?php endif ?>
|
|
</ul>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<button class="btn--go-to"><a href="<?= $package->url() ?>"><?= svg('assets/icons/arrow-left.svg') ?></a></button>
|
|
<a class="link-block" href="<?= $package->url() ?>" aria-hidden="true"></a>
|
|
</article>
|
|
<?php endforeach ?>
|
|
</div>
|
|
|
|
<?php elseif ($type === 'projects'): ?>
|
|
|
|
<div class="grid-masonry">
|
|
<div class="grid-sizer"></div>
|
|
|
|
<?php foreach (site()->find('laboratoire')->children()->listed()->sortBy('created', 'desc')->limit($count) as $project):
|
|
$categories = $project->category()->split();
|
|
$category = $categories[0] ?? '';
|
|
$cover = $project->cover()->toFile();
|
|
?>
|
|
<div class="card--block has-link"
|
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
|
data-date="<?= $project->created()->isNotEmpty() ? $project->created()->toDate('yyyy-MM-dd') : '' ?>">
|
|
|
|
<?php if ($cover): ?>
|
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
|
<?php endif ?>
|
|
|
|
<div class="group-top">
|
|
<p class="type">Projet</p>
|
|
<?php if ($category): ?>
|
|
<p class="category"><?= esc($category) ?></p>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<h3 class="title"><?= $project->title()->esc() ?></h3>
|
|
|
|
<?php if ($project->created()->isNotEmpty()): ?>
|
|
<p class="date"><time datetime="<?= $project->created()->toDate('yyyy-MM-dd') ?>"><?= $project->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
|
<?php endif ?>
|
|
|
|
<a class="link-block" href="<?= $project->url() ?>"></a>
|
|
</div>
|
|
<?php endforeach ?>
|
|
</div>
|
|
|
|
<?php elseif ($type === 'news'): ?>
|
|
|
|
<div class="grid-masonry">
|
|
<div class="grid-sizer"></div>
|
|
|
|
<?php foreach (page('news')->children()->listed()->sortBy('created', 'desc')->limit($count) as $newsItem):
|
|
$categories = $newsItem->category()->split();
|
|
$category = $categories[0] ?? '';
|
|
$cover = $newsItem->cover()->toFile();
|
|
?>
|
|
<div class="card--block has-link"
|
|
data-filter="<?= esc(Str::slug($category)) ?>"
|
|
data-date="<?= $newsItem->created()->isNotEmpty() ? $newsItem->created()->toDate('yyyy-MM-dd') : '' ?>">
|
|
|
|
<?php if ($cover): ?>
|
|
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
|
|
<?php endif ?>
|
|
|
|
<div class="group-top">
|
|
<p class="type">Brève</p>
|
|
<?php if ($category): ?>
|
|
<p class="category"><?= esc($category) ?></p>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<h3 class="title"><?= $newsItem->title()->esc() ?></h3>
|
|
|
|
<?php if ($newsItem->created()->isNotEmpty()): ?>
|
|
<p class="date"><time datetime="<?= $newsItem->created()->toDate('yyyy-MM-dd') ?>"><?= $newsItem->created()->toDate('d MMMM yyyy', $dateLocale) ?></time></p>
|
|
<?php endif ?>
|
|
|
|
<a class="link-block" href="<?= $newsItem->url() ?>"></a>
|
|
</div>
|
|
<?php endforeach ?>
|
|
</div>
|
|
|
|
<?php endif ?>
|
|
|
|
<div class="see-more">
|
|
<button class="btn--bold-inline">
|
|
<a href="<?= esc($seeMoreUrl) ?>">
|
|
<span class="text"><?= esc($seeMoreLabel) ?></span>
|
|
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
|
|
</a>
|
|
</button>
|
|
</div>
|
|
|
|
</div><!-- .col-right -->
|
|
</div><!-- .section--inner -->
|
|
</section>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</main>
|
|
<?php snippet('footer') ?>
|