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