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