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