xref: /webtrees/resources/views/modules/hourglass-chart/children.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Individual;
7use Illuminate\Support\Collection;
8
9/**
10 * @var Collection<int,Individual> $children
11 * @var int                        $generations
12 * @var bool                       $spouses
13 */
14
15?>
16<div class="align-self-center">
17    <?php foreach ($children as $n => $child) : ?>
18        <?php $grandchildren = $child->spouseFamilies()->map(static function (Family $family): Collection {
19    return $family->children();
20        })->flatten() ?>
21        <div class="d-flex justify-content-end">
22            <?php if ($grandchildren->isNotEmpty()) : ?>
23                <?php if ($generations > 1) : ?>
24                    <?= view('modules/hourglass-chart/children', ['children' => $grandchildren, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
25                <?php else : ?>
26                    <div class="d-flex align-self-center">
27                        <div class="hourglass-arrow" data-wt-chart-xref="<?= route('module', ['module' => 'hourglass_chart', 'action' => 'Descendants', 'xref' => $child->xref(), 'tree' => $child->tree()->name(), 'spouses' => $spouses]) ?>">
28                            <?= view('icons/arrow-left') ?>
29                        </div>
30                    </div>
31                <?php endif ?>
32            <?php endif ?>
33            <div class="align-self-center">
34                <?php if ($spouses) : ?>
35                    <div>&nbsp;</div>
36                <?php endif ?>
37                <?= view('chart-box', ['individual' => $child]) ?>
38                <?php if ($spouses) : ?>
39                    <?php foreach ($child->spouseFamilies() as $spouse_family) : ?>
40                        <?= view('chart-box', ['individual' => $spouse_family->spouse($child)]) ?>
41                    <?php endforeach ?>
42                    <div>&nbsp;</div>
43                <?php endif ?>
44            </div>
45            <div class="wt-chart-horizontal-spacer">
46                <?php if ($children->count() === 1) : ?>
47                    <div class="wt-chart-horizontal-line"></div>
48                <?php elseif ($n === 0) : ?>
49                    <div class="wt-chart-horizontal-first-child"></div>
50                <?php elseif ($n + 1 === $children->count()) : ?>
51                    <div class="wt-chart-horizontal-last-child"></div>
52                <?php else : ?>
53                    <div class="wt-chart-horizontal-middle-child">
54                        <div class="wt-chart-horizontal-line"></div>
55                    </div>
56                <?php endif ?>
57            </div>
58        </div>
59    <?php endforeach ?>
60</div>
61
62<?php if ($children->count() > 0) : ?>
63    <div class="wt-chart-horizontal-spacer">
64        <div class="wt-chart-horizontal-line"></div>
65    </div>
66<?php endif ?>
67