1a72fff1fSGreg Roach<?php 2a72fff1fSGreg Roach 3a72fff1fSGreg Roachuse Fisharebest\Webtrees\Fact; 4a72fff1fSGreg Roachuse Fisharebest\Webtrees\Registry; 5a72fff1fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\CopyFact; 6a72fff1fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact; 7a72fff1fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditFactPage; 8a72fff1fSGreg Roachuse Fisharebest\Webtrees\I18N; 9a72fff1fSGreg Roach 10a72fff1fSGreg Roach/** 11a72fff1fSGreg Roach * @var Fact $fact 12a72fff1fSGreg Roach */ 13a72fff1fSGreg Roach 14a72fff1fSGreg Roach$individual = $fact->record(); 15a72fff1fSGreg Roach$tree = $individual->tree(); 16a72fff1fSGreg Roach 17a72fff1fSGreg Roach// Create a fake record, so we can extract the formatted NAME value from it. 18a72fff1fSGreg Roach$fake_individual = Registry::individualFactory()->new( 19a72fff1fSGreg Roach 'xref', 20a72fff1fSGreg Roach "0 @xref@ INDI\n1 DEAT Y\n" . $fact->gedcom(), 21a72fff1fSGreg Roach null, 22a72fff1fSGreg Roach $tree 23a72fff1fSGreg Roach); 24a72fff1fSGreg Roach$fake_individual->setPrimaryName(0); // Make sure we use the name from "1 NAME" 25a72fff1fSGreg Roach 26a72fff1fSGreg Roach$container_class = ''; 27a72fff1fSGreg Roach 28a72fff1fSGreg Roachif ($fact->isPendingDeletion()) { 29a72fff1fSGreg Roach $container_class = 'wt-old'; 30a72fff1fSGreg Roach} elseif ($fact->isPendingAddition()) { 31a72fff1fSGreg Roach $container_class = 'wt-new'; 32a72fff1fSGreg Roach} 33a72fff1fSGreg Roach 34a72fff1fSGreg Roach?> 35a72fff1fSGreg Roach<div class="accordion-item <?= $container_class ?>"> 36a72fff1fSGreg Roach <div class="accordion-header" id="name-header-<?= $fact->id() ?>"> 37a72fff1fSGreg Roach <button class="accordion-button collapsed gap-1" type="button" data-bs-toggle="collapse" data-bs-target="#name-content-<?= $fact->id() ?>" aria-expanded="false" aria-controls="name-content-<?= $fact->id() ?>"> 38a72fff1fSGreg Roach <?= view('icons/expand') ?> 39a72fff1fSGreg Roach <?= view('icons/collapse') ?> 40a72fff1fSGreg Roach <span class="label"><?= I18N::translate('Name') ?></span> 41*6894de64SGreg Roach <div> 42a72fff1fSGreg Roach <?= $fake_individual->fullName() ?> 43a72fff1fSGreg Roach <?php if ($fact->attribute('TYPE') !== '') : ?> 44a72fff1fSGreg Roach — 45a72fff1fSGreg Roach <?= Registry::elementFactory()->make($fact->tag() . ':TYPE')->value($fact->attribute('TYPE'), $tree) ?> 46a72fff1fSGreg Roach <?php endif ?> 47*6894de64SGreg Roach </div> 48a72fff1fSGreg Roach </button> 49a72fff1fSGreg Roach </div> 50a72fff1fSGreg Roach 51a72fff1fSGreg Roach <div id="name-content-<?= $fact->id() ?>" class="accordion-collapse collapse" data-bs-parent="#individual-names" aria-labelledby="name-header-<?= $fact->id() ?>"> 52a72fff1fSGreg Roach <div class="accordion-body"> 53a72fff1fSGreg Roach <dl class="row mb-0"> 54a72fff1fSGreg Roach <dt class="col-md-4 col-lg-3"><?= I18N::translate('Name') ?></dt> 55a72fff1fSGreg Roach <dd class="col-md-8 col-lg-9"><bdi><?= e($fact->value()) ?></bdi></dd> 56a72fff1fSGreg Roach 57a72fff1fSGreg Roach <?php preg_match_all('/\n2 (\w+) (.+)/', $fact->gedcom(), $matches, PREG_SET_ORDER) ?> 58a72fff1fSGreg Roach <?php foreach ($matches as $key => $match) : ?> 59a72fff1fSGreg Roach <?php [, $tag, $value] = $match ?> 60a72fff1fSGreg Roach <?php $element = Registry::elementFactory()->make($fact->tag() . ':' . $tag) ?> 61a72fff1fSGreg Roach <?php if ($tag !== 'SOUR' && $tag !== 'NOTE') : ?> 62a72fff1fSGreg Roach <dt class="col-md-4 col-lg-3"> 63a72fff1fSGreg Roach <?= $element->label() ?> 64a72fff1fSGreg Roach </dt> 65a72fff1fSGreg Roach <dd class="col-md-8 col-lg-9"> 66a72fff1fSGreg Roach <?= $element->value($value, $fact->record()->tree()) ?> 67a72fff1fSGreg Roach </dd> 68a72fff1fSGreg Roach <?php endif ?> 69a72fff1fSGreg Roach <?php endforeach ?> 70a72fff1fSGreg Roach </dl> 71a72fff1fSGreg Roach 72a72fff1fSGreg Roach <?= view('fact-sources', ['fact' => $fact]) ?> 73a72fff1fSGreg Roach <?= view('fact-notes', ['fact' => $fact]) ?> 74a72fff1fSGreg Roach 75a72fff1fSGreg Roach <?php if ($fact->canEdit()) : ?> 76a72fff1fSGreg Roach <div class="d-flex"> 77a72fff1fSGreg Roach <a class="btn btn-link ms-auto" href="<?= e(route(EditFactPage::class, ['xref' => $individual->xref(), 'fact_id' => $fact->id(), 'tree' => $individual->tree()->name()])) ?>" title="<?= I18N::translate('Edit the name') ?>"> 78a72fff1fSGreg Roach <?= view('icons/edit') ?> 79a72fff1fSGreg Roach <span class="visually-hidden"><?= I18N::translate('Edit the name') ?></span> 80a72fff1fSGreg Roach </a> 81a72fff1fSGreg Roach 82a72fff1fSGreg Roach <a class="btn btn-link" href="#" data-wt-post-url="<?= e(route(CopyFact::class, ['tree' => $fact->record()->tree()->name(), 'xref' => $fact->record()->xref(), 'fact_id' => $fact->id()])) ?>" title="<?= I18N::translate('Copy') ?>"> 83a72fff1fSGreg Roach <?= view('icons/copy') ?> 84a72fff1fSGreg Roach <span class="visually-hidden"><?= I18N::translate('Copy') ?></span> 85a72fff1fSGreg Roach </a> 86a72fff1fSGreg Roach 87a72fff1fSGreg Roach <a class="btn btn-link" href="#" 88a72fff1fSGreg Roach data-wt-confirm="<?= I18N::translate('Are you sure you want to delete this fact?') ?>" 89a72fff1fSGreg Roach data-wt-post-url="<?= e(route(DeleteFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact_id' => $fact->id()])) ?>" 90a72fff1fSGreg Roach title="<?= I18N::translate('Delete this name') ?>"> 91a72fff1fSGreg Roach <?= view('icons/delete') ?> 92a72fff1fSGreg Roach <span class="visually-hidden"><?= I18N::translate('Delete this name') ?></span> 93a72fff1fSGreg Roach </a> 94a72fff1fSGreg Roach </div> 95a72fff1fSGreg Roach <?php endif ?> 96a72fff1fSGreg Roach </div> 97a72fff1fSGreg Roach </div> 98a72fff1fSGreg Roach</div> 99