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