12c3dad18SGreg Roach<?php 2852ede8cSGreg Roach 32c3dad18SGreg Roachuse Fisharebest\Webtrees\Auth; 42917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 522e73debSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord; 622e73debSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord; 72c3dad18SGreg Roachuse Fisharebest\Webtrees\I18N; 82c3dad18SGreg Roachuse Fisharebest\Webtrees\Individual; 9054771e9SGreg Roachuse Fisharebest\Webtrees\Tree; 102c3dad18SGreg Roachuse Fisharebest\Webtrees\View; 112c3dad18SGreg Roachuse Illuminate\Support\Collection; 122c3dad18SGreg Roach 132c3dad18SGreg Roach/** 14054771e9SGreg Roach * @var string $age 152c3dad18SGreg Roach * @var Individual $individual 162c3dad18SGreg Roach * @var string $user_link 172c3dad18SGreg Roach * @var Collection $sidebars 188e64ca84SGreg Roach * @var Collection $individual_media 192c3dad18SGreg Roach * @var Collection $name_records 202c3dad18SGreg Roach * @var Collection $sex_records 212c3dad18SGreg Roach * @var Collection $tabs 22054771e9SGreg Roach * @var Tree $tree 232c3dad18SGreg Roach */ 242c3dad18SGreg Roach?> 25dd6b2bfcSGreg Roach 26dd6b2bfcSGreg Roach<?php if ($individual->isPendingDeletion()) : ?> 27f4afa648SGreg Roach <?php if (Auth::isModerator($individual->tree())) : ?> 28dd6b2bfcSGreg Roach <?= view('components/alert-warning-dismissible', [ 29dd6b2bfcSGreg Roach 'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ 300973b4d2SGreg 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" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['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(PendingChangesRejectRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes']), 31dd6b2bfcSGreg Roach ]) ?> 32f4afa648SGreg Roach <?php elseif (Auth::isEditor($individual->tree())) : ?> 330973b4d2SGreg Roach <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 34dd6b2bfcSGreg Roach <?php endif ?> 35dd6b2bfcSGreg Roach<?php elseif ($individual->isPendingAddition()) : ?> 36f4afa648SGreg Roach <?php if (Auth::isModerator($individual->tree())) : ?> 37dd6b2bfcSGreg Roach <?= view('components/alert-warning-dismissible', [ 38dd6b2bfcSGreg Roach 'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ 390973b4d2SGreg 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" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['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(PendingChangesRejectRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes']), 40dd6b2bfcSGreg Roach ]) ?> 41f4afa648SGreg Roach <?php elseif (Auth::isEditor($individual->tree())) : ?> 420973b4d2SGreg Roach <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been edited. The changes need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 43dd6b2bfcSGreg Roach <?php endif ?> 44dd6b2bfcSGreg Roach<?php endif ?> 45dd6b2bfcSGreg Roach 46dd6b2bfcSGreg Roach<div class="d-flex mb-4"> 47dd6b2bfcSGreg Roach <h2 class="wt-page-title mx-auto"> 485e6816beSGreg Roach <?= $individual->fullName() ?><?= $user_link ?>, <?= $individual->lifespan() ?> <?= $age ?> 49dd6b2bfcSGreg Roach </h2> 501450f098SGreg Roach <?php if ($individual->canEdit()) : ?> 517bb122d6SGreg Roach <?= view('individual-page-menu', ['individual' => $individual, 'tree' => $tree]) ?> 52dd6b2bfcSGreg Roach <?php endif ?> 53dd6b2bfcSGreg Roach</div> 54dd6b2bfcSGreg Roach 55dd6b2bfcSGreg Roach<div class="row"> 568d38dd5aSGreg Roach <div class="<?= $sidebars->isEmpty() ? 'col-sm-12' : 'col-sm-8' ?>"> 57dd6b2bfcSGreg Roach <div class="row mb-4"> 58dd6b2bfcSGreg Roach <!-- Individual images --> 598e64ca84SGreg Roach <?php if ($individual_media->isNotEmpty() || $tree->getPreference('USE_SILHOUETTE') === '1') : ?> 60dd6b2bfcSGreg Roach <div class="col-sm-3"> 618e64ca84SGreg Roach <?php if ($individual_media->isEmpty()) : ?> 628e64ca84SGreg Roach <div class="img-thumbnail"> 6339ca88baSGreg Roach <i class="wt-individual-silhouette wt-individual-silhouette-<?= strtolower($individual->sex()) ?>"></i> 648e64ca84SGreg Roach </div> 658e64ca84SGreg Roach <?php elseif ($individual_media->count() === 1) : ?> 668e64ca84SGreg Roach <?= $individual_media->first()->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?> 67dd6b2bfcSGreg Roach <?php else : ?> 68dd6b2bfcSGreg Roach <div id="individual-images" class="carousel slide" data-ride="carousel" data-interval="false"> 69dd6b2bfcSGreg Roach <div class="carousel-inner"> 70dd6b2bfcSGreg Roach <?php foreach ($individual_media as $n => $media_file) : ?> 71dd6b2bfcSGreg Roach <div class="carousel-item <?= $n === 0 ? 'active' : '' ?>"> 72dd6b2bfcSGreg Roach <?= $media_file->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?> 73dd6b2bfcSGreg Roach </div> 74dd6b2bfcSGreg Roach <?php endforeach ?> 75dd6b2bfcSGreg Roach </div> 76dd6b2bfcSGreg Roach <a class="carousel-control-prev" href="#individual-images" role="button" data-slide="prev"> 77dd6b2bfcSGreg Roach <span class="carousel-control-prev-icon" aria-hidden="true"></span> 78dd6b2bfcSGreg Roach <span class="sr-only"><?= I18N::translate('previous') ?></span> 79dd6b2bfcSGreg Roach </a> 80dd6b2bfcSGreg Roach <a class="carousel-control-next" href="#individual-images" role="button" data-slide="next"> 81dd6b2bfcSGreg Roach <span class="carousel-control-next-icon" aria-hidden="true"></span> 82dd6b2bfcSGreg Roach <span class="sr-only"><?= I18N::translate('next') ?></span> 83dd6b2bfcSGreg Roach </a> 84dd6b2bfcSGreg Roach </div> 85dd6b2bfcSGreg Roach <?php endif ?> 86dd6b2bfcSGreg Roach 87f4afa648SGreg Roach <?php if (Auth::isEditor($individual->tree())) : ?> 888e64ca84SGreg Roach <div class="text-center"> 892917771cSGreg Roach <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'OBJE'])) ?>"> 90dd6b2bfcSGreg Roach <?= I18N::translate('Add a media object') ?> 91dd6b2bfcSGreg Roach </a> 92dd6b2bfcSGreg Roach </div> 93dd6b2bfcSGreg Roach <?php endif ?> 94dd6b2bfcSGreg Roach </div> 958e64ca84SGreg Roach <?php endif ?> 96dd6b2bfcSGreg Roach 97dd6b2bfcSGreg Roach <!-- Name accordion --> 98c15fb5e7SGreg Roach <div class="col-sm accordion" id="individual-names"> 99dd6b2bfcSGreg Roach <?php foreach ($name_records as $name_record) : ?> 100dd6b2bfcSGreg Roach <?= $name_record ?> 101dd6b2bfcSGreg Roach <?php endforeach ?> 102dd6b2bfcSGreg Roach 103dd6b2bfcSGreg Roach <?php foreach ($sex_records as $sex_record) : ?> 104dd6b2bfcSGreg Roach <?= $sex_record ?> 105dd6b2bfcSGreg Roach <?php endforeach ?> 106dd6b2bfcSGreg Roach </div> 107dd6b2bfcSGreg Roach </div> 108dd6b2bfcSGreg Roach 1094a2590a5SGreg Roach <div class="wt-tabs-individual" id="individual-tabs"> 1106a4003b9SGreg Roach <ul class="nav nav-tabs flex-wrap" role="tablist"> 111dd6b2bfcSGreg Roach <?php foreach ($tabs as $tab) : ?> 1126a4003b9SGreg Roach <li class="nav-item" role="presentation"> 113852ede8cSGreg Roach <a class="nav-link<?= $tab->isGrayedOut($individual) ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" data-href="<?= e(route('module', ['module' => $tab->name(), 'action' => 'Tab', 'tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>" href="#<?= $tab->name() ?>"> 114defb8071SRichard Cissée <?= $tab->tabTitle() ?> 115dd6b2bfcSGreg Roach </a> 116dd6b2bfcSGreg Roach </li> 117dd6b2bfcSGreg Roach <?php endforeach ?> 118dd6b2bfcSGreg Roach </ul> 1196a4003b9SGreg Roach 120dd6b2bfcSGreg Roach <div class="tab-content"> 121dd6b2bfcSGreg Roach <?php foreach ($tabs as $tab) : ?> 122677aaceaSGreg Roach <div id="<?= $tab->name() ?>" class="tab-pane fade wt-ajax-load" role="tabpanel"><?php if (!$tab->canLoadAjax()) : 123d70512abSGreg Roach ?><?= $tab->getTabContent($individual) ?><?php 124d70512abSGreg Roach endif ?></div> 125dd6b2bfcSGreg Roach <?php endforeach ?> 126dd6b2bfcSGreg Roach </div> 127dd6b2bfcSGreg Roach </div> 128dd6b2bfcSGreg Roach </div> 129c72fc94cSGreg Roach <?php if ($sidebars->isNotEmpty()) : ?> 130336be01cSGreg Roach <div class="col-sm-4 accordion" id="sidebar"> 131dd6b2bfcSGreg Roach <?php foreach ($sidebars as $sidebar) : ?> 132dd6b2bfcSGreg Roach <div class="card"> 133677aaceaSGreg Roach <div class="card-header" role="tab" id="sidebar-header-<?= $sidebar->name() ?>"> 134dd6b2bfcSGreg Roach <div class="card-title mb-0"> 135336be01cSGreg Roach <a data-toggle="collapse" href="#sidebar-content-<?= $sidebar->name() ?>" aria-expanded="<?= $sidebar->name() === 'family_nav' ? 'true' : 'false' ?>" aria-controls="sidebar-content-<?= $sidebar->name() ?>"> 136c15fb5e7SGreg Roach <?= view('icons/expand') ?> 137c15fb5e7SGreg Roach <?= view('icons/collapse') ?> 138defb8071SRichard Cissée <?= $sidebar->sidebarTitle() ?> 139dd6b2bfcSGreg Roach </a> 140dd6b2bfcSGreg Roach </div> 141dd6b2bfcSGreg Roach </div> 1426a4003b9SGreg Roach 143336be01cSGreg Roach <div id="sidebar-content-<?= $sidebar->name() ?>" class="collapse<?= $sidebar->name() === 'family_nav' ? ' show' : '' ?>" data-parent="#sidebar" aria-labelledby="sidebar-header-<?= $sidebar->name() ?>"> 144dd6b2bfcSGreg Roach <div class="card-body"> 1457d70e4a7SGreg Roach <?= $sidebar->getSidebarContent($individual) ?> 1467d70e4a7SGreg Roach </div> 147dd6b2bfcSGreg Roach </div> 148dd6b2bfcSGreg Roach </div> 149dd6b2bfcSGreg Roach <?php endforeach ?> 150dd6b2bfcSGreg Roach </div> 151c72fc94cSGreg Roach <?php endif ?> 152dd6b2bfcSGreg Roach</div> 153dd6b2bfcSGreg Roach 154dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 155dd6b2bfcSGreg Roach<script> 156dd6b2bfcSGreg Roach "use strict"; 157dd6b2bfcSGreg Roach 158dd6b2bfcSGreg Roach // Bootstrap tabs - load content dynamically using AJAX 159dd6b2bfcSGreg Roach $('a[data-toggle="tab"][data-href]').on('show.bs.tab', function () { 1605675e46eSmiqrogroove let target = $(this.hash + ':empty'); 161*06b58f1dSGreg Roach if (target.length > 0) { 1625675e46eSmiqrogroove // Start the download immediately... 1635675e46eSmiqrogroove let download = fetch(this.dataset.href); 1645675e46eSmiqrogroove 1655675e46eSmiqrogroove // ...but don't insert it until the tab is ready. 1665675e46eSmiqrogroove $(this).one('shown.bs.tab', () => { 1675675e46eSmiqrogroove download 1685675e46eSmiqrogroove .then(data => data.text()) 1695675e46eSmiqrogroove .then(data => target.html(data)); 1705675e46eSmiqrogroove }); 1715675e46eSmiqrogroove } 172dd6b2bfcSGreg Roach }); 173dd6b2bfcSGreg Roach 174dd6b2bfcSGreg Roach // If the URL contains a fragment, then activate the corresponding tab. 175dd6b2bfcSGreg Roach // Use a prefix on the fragment, to prevent scrolling to the element. 176054771e9SGreg Roach let target = window.location.hash.replace("tab-", ""); 177054771e9SGreg Roach let tab = $("#individual-tabs .nav-link[href='" + target + "']"); 178dd6b2bfcSGreg Roach // If not, then activate the first tab. 179dd6b2bfcSGreg Roach if (tab.length === 0) { 180dd6b2bfcSGreg Roach tab = $("#individual-tabs .nav-link:first"); 181dd6b2bfcSGreg Roach } 182dd6b2bfcSGreg Roach tab.tab("show"); 183dd6b2bfcSGreg Roach 184dd6b2bfcSGreg Roach // If the user selects a tab, update the URL to reflect this 185dd6b2bfcSGreg Roach $('#individual-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 186dd6b2bfcSGreg Roach window.location.hash = "tab-" + e.target.href.substring(e.target.href.indexOf('#') + 1); 187dd6b2bfcSGreg Roach }); 188dd6b2bfcSGreg Roach</script> 189dd6b2bfcSGreg Roach<?php View::endpush() ?> 190dd6b2bfcSGreg Roach 191dd6b2bfcSGreg Roach<?= view('modals/ajax') ?> 192