xref: /webtrees/resources/views/modules/lifespans-chart/chart.phtml (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Gedcom;
6
7/**
8 * @var string        $dir
9 * @var int           $end_year
10 * @var array<object> $lifespans
11 * @var int           $max_rows
12 * @var int           $start_year
13 * @var string        $subtitle
14 */
15
16?>
17
18<p class="wt-lifespans-subtitle">
19    <?= $subtitle ?>
20</p>
21
22<div class="wt-lifespans-scale">
23    <?php for ($year = $start_year; $year < $end_year; $year += 10) :
24        ?><div class="wt-lifespans-decade"><?= $year ?></div><?php
25    endfor ?>
26</div>
27
28<div class="wt-lifespans-individuals position-relative" style="height: <?= (5 + $max_rows) * 1.5 ?>rem; width: <?= ($end_year - $start_year) * 7 ?>px;">
29    <?php foreach ($lifespans as $lifespan) : ?>
30    <a href="#" data-bs-toggle="collapse" data-bs-target="#<?= e($lifespan->id) ?>" aria-expanded="false" aria-controls="<?= e($lifespan->id) ?>">
31        <div class="wt-lifespans-individual position-absolute text-nowrap text-truncate" dir="auto" style="background: <?= $lifespan->background ?>; <?= $dir === 'ltr' ? 'left' : 'right' ?>:<?= ($lifespan->birth_year - $start_year) * 7 ?>px; top:<?= $lifespan->row * 1.5 ?>rem; width:<?= ($lifespan->death_year - $lifespan->birth_year) * 7 + 5 ?>px;">
32            <?= $lifespan->individual->fullName() ?>
33            <?= strip_tags($lifespan->individual->lifespan()) ?>
34        </div>
35    </a>
36
37    <div class="wt-lifespans-summary collapse position-absolute" id="<?= e($lifespan->id) ?>" style="<?= $dir === 'ltr' ? 'left' : 'right' ?>:<?= (min($lifespan->birth_year, $end_year - 50) - $start_year) * 7 ?>px; top:<?= ($lifespan->row + 1) * 1.5 ?>rem; width:350px;">
38        <a class="wt-lifespans-summary-link" href="<?= e($lifespan->individual->url()) ?>">
39            <?= $lifespan->individual->fullName() ?>
40        </a>
41
42        <?php foreach ($lifespan->individual->facts(array_merge(Gedcom::BIRTH_EVENTS, Gedcom::DEATH_EVENTS), true) as $fact) : ?>
43            <?= $fact->summary() ?>
44        <?php endforeach ?>
45    </div>
46    <?php endforeach ?>
47</div>
48
49