index-main/site/templates/home.php

229 lines
7 KiB
PHP
Raw Normal View History

2025-10-07 16:21:26 +02:00
<?php snippet('header') ?>
2026-01-06 11:19:25 +01:00
<main>
2026-01-13 12:13:02 +01:00
2026-01-27 19:09:56 +01:00
2026-01-13 12:18:22 +01:00
<section class="section--home" id="home__investigations">
2026-01-13 12:13:02 +01:00
<div class="section--inner">
2026-01-27 19:09:56 +01:00
<div class="col-left">
2026-02-11 14:52:16 +01:00
<p class="baseline-section"><?= $page->mainBaseline() ?></p>
2026-02-09 21:12:58 +01:00
<button class="btn--bold-inline">
<a href="#">
<span class="text">En savoir plus</span>
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
</a>
</button>
</div>
<div class="col-right">
2026-01-27 19:09:56 +01:00
2026-02-19 16:25:44 +01:00
<?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) >= 5) break;
$list[] = ['page' => $p, 'type' => 'pinned'];
$shownIds[] = $p->id();
}
if (count($list) < 5) {
$latest = $enquetesPage->children()->listed()->sortBy('created', 'desc')
->filter(fn($p) => !in_array($p->id(), $shownIds))
->limit(5 - count($list));
foreach ($latest as $p) {
$list[] = ['page' => $p, 'type' => 'latest'];
}
}
?>
<?php foreach ($list as $item):
$investigation = $item['page'];
$type = $item['type'];
$cover = $investigation->cover()->toFile();
?>
<article class="card--article<?= $type === 'super' ? ' pinned-home' : ($type === 'pinned' ? ' pinned' : '') ?>">
<?php if ($type === 'super' && ($videoPreview = $investigation->videoPreview()->toFile())): ?>
<div class="video-extract">
<video class="vjs-tech" id="player-element_html5_api" tabindex="-1" loop="" muted="muted" playsinline="playsinline" autoplay="" src="<?= $videoPreview->url() ?>"></video>
</div>
<?php elseif ($cover): ?>
<figure>
<img src="<?= $cover->url() ?>" alt="<?= $investigation->title()->esc() ?>">
</figure>
<?php endif ?>
<?php if ($type === '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', 'fr_FR') ?></time></dd>
</div>
<?php endif ?>
<?php if ($partners = $investigation->partners()->toStructure()): ?>
<?php if ($partners->isNotEmpty()): ?>
<div class="dl__group">
<dt>Partenaire(s)</dt>
<dd>
<?php $partnerNames = [] ?>
<?php foreach ($partners as $partner): ?>
<?php $partnerNames[] = $partner->name()->value() ?>
<?php endforeach ?>
<?= implode(', ', $partnerNames) ?>
</dd>
</div>
<?php endif ?>
<?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 ?>
2026-02-09 21:12:58 +01:00
2026-02-09 21:15:36 +01:00
2026-01-27 19:58:53 +01:00
2026-01-27 19:09:56 +01:00
2026-02-09 21:12:58 +01:00
<div class="see-more">
<button class="btn--bold-inline">
<a href="/enquetes">
<span class="text">Voir toutes les enquêtes</span>
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
</a>
</button>
</div>
2026-01-27 19:09:56 +01:00
2026-02-09 21:12:58 +01:00
</div> <!-- col-right-->
2026-01-27 19:09:56 +01:00
</div>
</section>
<section class="section--home" id="home__impacts">
<div class="section--inner">
<div class="col-left">
2026-02-09 21:12:58 +01:00
2026-02-11 14:52:16 +01:00
<p class="baseline-section"><?= $page->impactsBaseline() ?></p>
2026-02-09 21:12:58 +01:00
<button class="btn--bold-inline">
2026-01-27 23:06:29 +01:00
<a href="/impacts">
2026-02-09 21:12:58 +01:00
<span class="text">En savoir plus</span>
2026-01-27 19:09:56 +01:00
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
</a>
2026-02-09 21:12:58 +01:00
</button>
2026-01-27 19:09:56 +01:00
</div>
2026-02-09 21:12:58 +01:00
<div class="col-right">
<div class="grid-masonry">
2026-01-27 19:58:53 +01:00
2026-02-09 15:15:27 +01:00
<div class="grid-sizer"></div>
2026-01-30 12:27:44 +01:00
2026-02-26 15:03:52 +01:00
<?php
$impactsPage = page('impacts');
foreach ($impactsPage->children()->listed()->sortBy('created', 'desc')->limit(8) as $impact):
$categories = $impact->category()->split();
$category = $categories[0] ?? '';
$cover = $impact->cover()->toFile();
$investigations = $impact->linkedInvestigations()->toPages();
?>
<div class="card--block has-link">
2026-01-27 19:58:53 +01:00
2026-02-26 15:03:52 +01:00
<?php if ($cover): ?>
<figure><?php snippet('picture', ['file' => $cover]) ?></figure>
<?php endif ?>
2026-01-30 12:27:44 +01:00
2026-02-26 15:03:52 +01:00
<div class="group-top">
<p class="type">Impact</p>
<?php if ($category): ?>
<p class="category"><?= esc($category) ?></p>
<?php endif ?>
2026-01-27 19:58:53 +01:00
</div>
2026-02-26 15:03:52 +01:00
<h3 class="title"><?= $impact->title()->esc() ?></h3>
2026-01-30 12:27:44 +01:00
2026-02-26 15:03:52 +01:00
<?php if ($impact->created()->isNotEmpty()): ?>
<p class="date"><?= $impact->created()->toDate('d MMMM yyyy', 'fr_FR') ?></p>
<?php endif ?>
2026-01-27 19:58:53 +01:00
2026-02-26 15:03:52 +01:00
<?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 ?>
2026-01-27 19:58:53 +01:00
2026-02-26 15:03:52 +01:00
<a class="link-block" href="<?= $impact->url() ?>"></a>
2026-02-09 15:15:27 +01:00
</div>
2026-02-26 15:03:52 +01:00
<?php endforeach ?>
2026-01-27 19:58:53 +01:00
2026-02-09 21:12:58 +01:00
</div> <!-- end masonry -->
2026-01-27 19:58:53 +01:00
2026-02-09 21:12:58 +01:00
<div class="see-more">
<button class="btn--bold-inline">
<a href="/impacts">
<span class="text">Voir tout</span>
<span class="icon"><?= svg('assets/icons/arrow-left.svg') ?></span>
</a>
</button>
</div>
2026-01-27 19:58:53 +01:00
2026-02-09 15:15:27 +01:00
</div>
2026-01-27 19:58:53 +01:00
2026-02-09 15:15:27 +01:00
</section>
2026-01-27 19:58:53 +01:00
2026-01-13 12:13:02 +01:00
2026-01-27 19:58:53 +01:00
2026-01-06 11:19:25 +01:00
</main>
2025-10-07 16:21:26 +02:00
<?php snippet('footer') ?>