xref: /webtrees/resources/views/modules/ancestors-chart/tree.phtml (revision 2cb444b0f4cd71b5090651edb1f8cfe241405064)
1<?php
2
3use Fisharebest\Webtrees\Family;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Individual;
6
7/**
8 * @var Individual|null $individual
9 * @var Family|null     $parents
10 * @var int             $generations
11 * @var int             $sosa
12 */
13
14?>
15
16<div class="d-flex">
17    <?= view('chart-box', ['individual' => $individual]) ?>
18    <div class="wt-sosa-number align-self-center p-1 mx-2 d-none d-md-block" title="<?= I18N::translate('Sosa-Stradonitz number') ?>">
19        <?= I18N::number($sosa) ?>
20    </div>
21</div>
22
23<?php if ($generations > 1 && $parents instanceof Family) : ?>
24    <div class="d-flex">
25        <span class="wt-chart-horizontal-spacer d-inline-block"></span>
26        <button class="btn btn-link px-0 py-1 wt-chart-expansion-control" data-toggle="collapse" data-target="#fam-<?= e($parents->xref()) ?>" aria-controls="fam-<?= e($parents->xref()) ?>" aria-expanded="true">
27            <span class="chart-expand">
28                <?= view('icons/expand') ?>
29            </span>
30            <span class="chart-collapse">
31                <?= view('icons/collapse') ?>
32            </span>
33            <?= I18N::translate('Parents') ?>
34            <?php foreach ($parents->facts(['MARR', 'DIV', '_NMR'], true) as $fact) : ?>
3536                <?= $fact->label() ?>
37                <?php if ($fact->date()->isOK()) : ?>
38                    <?= strip_tags($fact->date()->display()) ?>
39                <?php endif ?>
40            <?php endforeach ?>
4142            <?= I18N::plural('%s child', '%s children', $parents->children()->count(), I18N::number($parents->children()->count())) ?>
43        </button>
44    </div>
45    <div id="fam-<?= e($parents->xref()) ?>" class="collapse show mb-4">
46        <?php foreach ($parents->spouses() as $n => $spouse) : ?>
47            <div class="d-flex">
48                <div class="wt-chart-horizontal-indent position-relative">
49                    <?php if ($n + 1 === $parents->spouses()->count()) : ?>
50                        <div class="wt-chart-vertical-last-child-line position-absolute"></div>
51                    <?php else : ?>
52                        <div class="wt-chart-vertical-line position-absolute"></div>
53                        <div class="wt-chart-vertical-child-line position-absolute"></div>
54                    <?php endif ?>
55                </div>
56                <div>
57                    <?= view('modules/ancestors-chart/tree', ['individual' => $spouse, 'parents' => $spouse->childFamilies()->first(), 'generations' => $generations - 1, 'sosa' => $sosa * 2 + ($spouse->sex() === 'F' ? 1 : 0)]) ?>
58                </div>
59            </div>
60        <?php endforeach ?>
61    </div>
62<?php endif ?>
63