xref: /webtrees/resources/views/individual-page.phtml (revision 1a218474113038005e50986fff24ebcbd58554ff)
1<?php
2use Fisharebest\Webtrees\Auth;
3use Fisharebest\Webtrees\Functions\FunctionsPrint;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Individual;
6use Fisharebest\Webtrees\View;
7use Illuminate\Support\Collection;
8
9/**
10 * @var Individual $individual
11 * @var string     $user_link
12 * @var int        $count_names
13 * @var Collection $sidebars
14 * @var Collection $individual_media
15 * @var Collection $name_records
16 * @var Collection $sex_records
17 * @var Collection $tabs
18 */
19?>
20
21<?php if ($individual->isPendingDeletion()) : ?>
22    <?php if (Auth::isModerator($individual->tree())) : ?>
23        <?= view('components/alert-warning-dismissible', [
24            'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */
25                I18N::translate('This individual has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" class="alert-link" data-post-url="' . e(route('accept-changes', ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route('reject-changes', ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes'),
26        ]) ?>
27    <?php elseif (Auth::isEditor($individual->tree())) : ?>
28        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
29    <?php endif ?>
30<?php elseif ($individual->isPendingAddition()) : ?>
31    <?php if (Auth::isModerator($individual->tree())) : ?>
32        <?= view('components/alert-warning-dismissible', [
33            'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */
34                I18N::translate('This individual has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" class="alert-link" data-post-url="' . e(route('accept-changes', ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route('reject-changes', ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes'),
35        ]) ?>
36    <?php elseif (Auth::isEditor($individual->tree())) : ?>
37        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
38    <?php endif ?>
39<?php endif ?>
40
41<div class="d-flex mb-4">
42    <h2 class="wt-page-title mx-auto">
43        <?= $individual->fullName() ?><?= $user_link ?>, <?= $individual->getLifeSpan() ?> <?= $age ?>
44    </h2>
45    <?php if ($individual->canEdit()) : ?>
46        <?= view('individual-page-menu', ['individual' => $individual, 'count_names' => $count_names, 'count_sex' => $count_sex]) ?>
47    <?php endif ?>
48</div>
49
50<div class="row">
51    <div class="<?= $sidebars->isEmpty() ? 'col-sm-12' : 'col-sm-8' ?>">
52        <div class="row mb-4">
53            <!-- Individual images -->
54            <?php if ($individual_media->isNotEmpty() || $tree->getPreference('USE_SILHOUETTE') === '1') : ?>
55                <div class="col-sm-3">
56                    <?php if ($individual_media->isEmpty()) : ?>
57                        <div class="img-thumbnail">
58                            <i class="wt-individual-silhouette wt-individual-silhouette-<?= strtolower($individual->sex()) ?>"></i>
59                        </div>
60                    <?php elseif ($individual_media->count() === 1) : ?>
61                        <?= $individual_media->first()->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?>
62                    <?php else : ?>
63                        <div id="individual-images" class="carousel slide" data-ride="carousel" data-interval="false">
64                            <div class="carousel-inner">
65                                <?php foreach ($individual_media as $n => $media_file) : ?>
66                                    <div class="carousel-item <?= $n === 0 ? 'active' : '' ?>">
67                                        <?= $media_file->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?>
68                                    </div>
69                                <?php endforeach ?>
70                            </div>
71                            <a class="carousel-control-prev" href="#individual-images" role="button" data-slide="prev">
72                                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
73                                <span class="sr-only"><?= I18N::translate('previous') ?></span>
74                            </a>
75                            <a class="carousel-control-next" href="#individual-images" role="button" data-slide="next">
76                                <span class="carousel-control-next-icon" aria-hidden="true"></span>
77                                <span class="sr-only"><?= I18N::translate('next') ?></span>
78                            </a>
79                        </div>
80                    <?php endif ?>
81
82                    <?php if (Auth::isEditor($individual->tree())) : ?>
83                        <div class="text-center">
84                            <a href="<?= e(route('add-fact', ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'OBJE'])) ?>">
85                                <?= I18N::translate('Add a media object') ?>
86                            </a>
87                        </div>
88                    <?php endif ?>
89                </div>
90            <?php endif ?>
91
92            <!-- Name accordion -->
93            <div class="col-sm" id="individual-names" role="tablist">
94                <?php foreach ($name_records as $name_record) : ?>
95                    <?= $name_record ?>
96                <?php endforeach ?>
97
98                <?php foreach ($sex_records as $sex_record) : ?>
99                    <?= $sex_record ?>
100                <?php endforeach ?>
101            </div>
102        </div>
103
104        <div class="wt-tabs-individual" id="individual-tabs">
105            <ul class="nav nav-tabs flex-wrap">
106                <?php foreach ($tabs as $tab) : ?>
107                    <li class="nav-item">
108                        <a class="nav-link<?= $tab->isGrayedOut($individual) ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" data-href="<?= e(route('individual-tab', ['xref' => $individual->xref(), 'tree' => $individual->tree()->name(), 'module' => $tab->name()])) ?>" href="#<?= $tab->name() ?>">
109                            <?= $tab->tabTitle() ?>
110                        </a>
111                    </li>
112                <?php endforeach ?>
113            </ul>
114            <div class="tab-content">
115                <?php foreach ($tabs as $tab) : ?>
116                    <div id="<?= $tab->name() ?>" class="tab-pane fade wt-ajax-load" role="tabpanel"><?php if (!$tab->canLoadAjax()) :
117                        ?><?= $tab->getTabContent($individual) ?><?php
118                             endif ?></div>
119                <?php endforeach ?>
120            </div>
121        </div>
122    </div>
123    <?php if ($sidebars->isNotEmpty()) : ?>
124    <div class="col-sm-4" id="sidebar" role="tablist">
125        <?php foreach ($sidebars as $sidebar) : ?>
126            <div class="card">
127                <div class="card-header" role="tab" id="sidebar-header-<?= $sidebar->name() ?>">
128                    <div class="card-title mb-0">
129                        <a data-toggle="collapse" data-parent="#sidebar" href="#sidebar-content-<?= $sidebar->name() ?>" aria-expanded="<?= $sidebar->name() === 'family_nav' ? 'true' : 'false' ?>" aria-controls="sidebar-content-<?= $sidebar->name() ?>">
130                            <?= $sidebar->sidebarTitle() ?>
131                        </a>
132                    </div>
133                </div>
134                <div id="sidebar-content-<?= $sidebar->name() ?>" class="collapse<?= $sidebar->name() === 'family_nav' ? ' show' : '' ?>" role="tabpanel" aria-labelledby="sidebar-header-<?= $sidebar->name() ?>">
135                    <div class="card-body">
136                        <?= $sidebar->getSidebarContent($individual) ?></div>
137                </div>
138            </div>
139        <?php endforeach ?>
140    </div>
141    <?php endif ?>
142</div>
143
144<?php View::push('javascript') ?>
145<script>
146  "use strict";
147
148  // Bootstrap tabs - load content dynamically using AJAX
149  $('a[data-toggle="tab"][data-href]').on('show.bs.tab', function () {
150    $(this.getAttribute('href') + ':empty').load($(this).data('href'));
151  });
152
153  // If the URL contains a fragment, then activate the corresponding tab.
154  // Use a prefix on the fragment, to prevent scrolling to the element.
155  var target = window.location.hash.replace("tab-", "");
156  var tab    = $("#individual-tabs .nav-link[href='" + target + "']");
157  // If not, then activate the first tab.
158  if (tab.length === 0) {
159    tab = $("#individual-tabs .nav-link:first");
160  }
161  tab.tab("show");
162
163  // If the user selects a tab, update the URL to reflect this
164  $('#individual-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
165    window.location.hash = "tab-" + e.target.href.substring(e.target.href.indexOf('#') + 1);
166  });
167</script>
168<?php View::endpush() ?>
169
170<?= view('modals/ajax') ?>
171