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