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