xref: /webtrees/resources/views/modules/family_nav/sidebar-family.phtml (revision 15c4f62c40de0c794536302daf7d5ec0548a1973)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Fisharebest\Webtrees\Registry;
9use Fisharebest\Webtrees\Services\RelationshipService;
10
11/**
12 * @var Individual $individual
13 * @var Family     $family
14 * @var string     $title
15 */
16
17?>
18
19<table class="table table-sm wt-facts-table wt-family-navigator-family">
20    <caption class="text-center wt-family-navigator-family-heading">
21        <a href="<?= e($family->url()) ?>">
22            <?= $title ?>
23        </a>
24    </caption>
25    <tbody>
26        <?php foreach ($family->spouses() as $spouse) : ?>
27            <tr class="text-center wt-family-navigator-parent wt-sex-<?= strtolower($spouse->sex()) ?>">
28                <th class="align-middle wt-family-navigator-label" scope="row">
29                    <?php if ($spouse === $individual) : ?>
30                        <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $spouse) ?>
31                        <i class="icon-selected"></i>
32                    <?php elseif ($spouse->childFamilies()->isNotEmpty()) : ?>
33                    <div class="dropdown">
34                        <a class="dropdown-toggle" href="#" role="button" id="dropdown-<?= e($spouse->xref()) ?>" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
35                            <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $spouse) ?>
36                        </a>
37
38                        <div class="dropdown-menu wt-family-navigator-dropdown">
39                            <?php foreach ($spouse->childFamilies() as $n => $spouse_child_family) : ?>
40                                <?php if ($n > 0) : ?>
41                                    <div class="dropdown-divider"></div>
42                                <?php endif ?>
43                                <a class="dropdown-header wt-family-navigator-dropdown-heading" href="<?= e($spouse_child_family->url()) ?>">
44                                    <?= I18N::translate('Parents') ?>
45                                </a>
46                                <?php foreach ($spouse_child_family->spouses() as $parent) : ?>
47                                    <a class="dropdown-item" href="<?= e($parent->url()) ?>">
48                                        <?= $parent->fullName() ?>
49                                    </a>
50                                <?php endforeach ?>
51                            <?php endforeach ?>
52                        </div>
53                    </div>
54                    <?php else : ?>
55                        <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $spouse) ?>
56                    <?php endif ?>
57                </th>
58
59                <td class="wt-family-navigator-name">
60                    <?php if ($spouse->canShow()) : ?>
61                        <a href="<?= e($spouse->url()) ?>">
62                            <?= $spouse->fullName() ?>
63                        </a>
64                        <div class="small">
65                            <?= $spouse->lifespan() ?>
66                        </div>
67                    <?php else : ?>
68                        <?= $spouse->fullName() ?>
69                    <?php endif ?>
70                </td>
71            </tr>
72        <?php endforeach ?>
73
74        <?php foreach ($family->children() as $child) : ?>
75            <tr class="text-center wt-family-navigator-child wt-sex-<?= strtolower($child->sex()) ?>">
76                <th class="align-middle wt-family-navigator-label" scope="row">
77                    <?php if ($child === $individual) : ?>
78                        <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $child) ?>
79                        <i class="icon-selected"></i>
80                    <?php elseif ($child->spouseFamilies()->isNotEmpty()) : ?>
81                        <div class="dropdown">
82                            <a class="dropdown-toggle" href="#" role="button" id="dropdown-<?= e($child->xref()) ?>" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
83                                <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $child) ?>
84                            </a>
85
86                            <div class="dropdown-menu">
87                                <?php foreach ($child->spouseFamilies() as $n => $in_laws) : ?>
88                                    <?php if ($n > 0) : ?>
89                                        <div class="dropdown-divider"></div>
90                                    <?php endif ?>
91                                    <a class="dropdown-header wt-family-navigator-dropdown-heading" href="<?= e($in_laws->url()) ?>">
92                                        <?= I18N::translate('Family') ?>
93                                    </a>
94
95                                    <?php foreach ($in_laws->spouses() as $sibling_in_law) : ?>
96                                        <?php if ($sibling_in_law !== $child) : ?>
97                                            <a class="dropdown-item" href="<?= e($sibling_in_law->url()) ?>">
98                                                <?= $sibling_in_law->fullName() ?>
99                                            </a>
100                                        <?php endif ?>
101                                    <?php endforeach ?>
102
103                                <ul>
104                                    <?php foreach ($in_laws->children() as $child_in_law) : ?>
105                                    <li>
106                                        <a class="dropdown-item" href="<?= e($child_in_law->url()) ?>">
107                                            <?= $child_in_law->fullName() ?>
108                                        </a>
109                                    </li>
110                                    <?php endforeach ?>
111                                </ul>
112                                <?php endforeach ?>
113                            </div>
114                        </div>
115                    <?php else : ?>
116                        <?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($individual, $child) ?>
117                    <?php endif ?>
118                </th>
119
120                <td>
121                    <?php if ($child->canShow()) : ?>
122                        <a  href="<?= e($child->url()) ?>">
123                            <?= $child->fullName() ?>
124                        </a>
125                        <div class="small">
126                            <?= $child->lifespan() ?>
127                        </div>
128                    <?php else : ?>
129                        <?= $child->fullName() ?>
130                    <?php endif ?>
131                </td>
132            </tr>
133        <?php endforeach ?>
134    </tbody>
135</table>
136