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 <div> 42 <?= $fake_individual->fullName() ?> 43 <?php if ($fact->attribute('TYPE') !== '') : ?> 44 — 45 <?= Registry::elementFactory()->make($fact->tag() . ':TYPE')->value($fact->attribute('TYPE'), $tree) ?> 46 <?php endif ?> 47 </div> 48 </button> 49 </div> 50 51 <div id="name-content-<?= $fact->id() ?>" class="accordion-collapse collapse" data-bs-parent="#individual-names" aria-labelledby="name-header-<?= $fact->id() ?>"> 52 <div class="accordion-body"> 53 <dl class="row mb-0"> 54 <dt class="col-md-4 col-lg-3"><?= I18N::translate('Name') ?></dt> 55 <dd class="col-md-8 col-lg-9"><bdi><?= e($fact->value()) ?></bdi></dd> 56 57 <?php preg_match_all('/\n2 (\w+) (.+)/', $fact->gedcom(), $matches, PREG_SET_ORDER) ?> 58 <?php foreach ($matches as $key => $match) : ?> 59 <?php [, $tag, $value] = $match ?> 60 <?php $element = Registry::elementFactory()->make($fact->tag() . ':' . $tag) ?> 61 <?php if ($tag !== 'SOUR' && $tag !== 'NOTE') : ?> 62 <dt class="col-md-4 col-lg-3"> 63 <?= $element->label() ?> 64 </dt> 65 <dd class="col-md-8 col-lg-9"> 66 <?= $element->value($value, $fact->record()->tree()) ?> 67 </dd> 68 <?php endif ?> 69 <?php endforeach ?> 70 </dl> 71 72 <?= view('fact-sources', ['fact' => $fact]) ?> 73 <?= view('fact-notes', ['fact' => $fact]) ?> 74 75 <?php if ($fact->canEdit()) : ?> 76 <div class="d-flex"> 77 <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') ?>"> 78 <?= view('icons/edit') ?> 79 <span class="visually-hidden"><?= I18N::translate('Edit the name') ?></span> 80 </a> 81 82 <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') ?>"> 83 <?= view('icons/copy') ?> 84 <span class="visually-hidden"><?= I18N::translate('Copy') ?></span> 85 </a> 86 87 <a class="btn btn-link" href="#" 88 data-wt-confirm="<?= I18N::translate('Are you sure you want to delete this fact?') ?>" 89 data-wt-post-url="<?= e(route(DeleteFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact_id' => $fact->id()])) ?>" 90 title="<?= I18N::translate('Delete this name') ?>"> 91 <?= view('icons/delete') ?> 92 <span class="visually-hidden"><?= I18N::translate('Delete this name') ?></span> 93 </a> 94 </div> 95 <?php endif ?> 96 </div> 97 </div> 98</div> 99