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