xref: /webtrees/resources/views/modules/family_nav/sidebar-family.phtml (revision f4c767fd89cdb62ee54edec032285924cd767af7)
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<?php
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-gender-<?= $spouse->sex() ?>">
27                <th class="align-middle wt-family-navigator-label" scope="row">
28                    <?php if ($spouse === $individual) : ?>
29                        <?= Functions::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-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
34                            <?= Functions::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->xref()) ?>">
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                        <?= Functions::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-gender-<?= $child->sex() ?>">
75                <th class="align-middle wt-family-navigator-label" scope="row">
76                    <?php if ($child === $individual) : ?>
77                        <?= Functions::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-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
82                                <?= Functions::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                        <?= Functions::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