1b315f3e1SGreg Roach<?php 2b315f3e1SGreg Roach 3b315f3e1SGreg Roachuse Fisharebest\Webtrees\Auth; 4b315f3e1SGreg Roachuse Fisharebest\Webtrees\Elements\UnknownElement; 5b315f3e1SGreg Roachuse Fisharebest\Webtrees\Elements\XrefAssociate; 6b315f3e1SGreg Roachuse Fisharebest\Webtrees\Fact; 7b315f3e1SGreg Roachuse Fisharebest\Webtrees\Family; 8b315f3e1SGreg Roachuse Fisharebest\Webtrees\Gedcom; 9b315f3e1SGreg Roachuse Fisharebest\Webtrees\GedcomRecord; 10b315f3e1SGreg Roachuse Fisharebest\Webtrees\I18N; 11b315f3e1SGreg Roachuse Fisharebest\Webtrees\Individual; 12b315f3e1SGreg Roachuse Fisharebest\Webtrees\Media; 13b315f3e1SGreg Roachuse Fisharebest\Webtrees\Module\ModuleChartInterface; 14b315f3e1SGreg Roachuse Fisharebest\Webtrees\Module\ModuleInterface; 15b315f3e1SGreg Roachuse Fisharebest\Webtrees\Module\RelationshipsChartModule; 16b315f3e1SGreg Roachuse Fisharebest\Webtrees\Registry; 17b315f3e1SGreg Roachuse Fisharebest\Webtrees\Services\ModuleService; 18b315f3e1SGreg Roachuse Fisharebest\Webtrees\Services\RelationshipService; 19b315f3e1SGreg Roach 20b315f3e1SGreg Roach/** 21b315f3e1SGreg Roach * @var Fact $fact 22b315f3e1SGreg Roach * @var GedcomRecord $record 23b315f3e1SGreg Roach */ 24b315f3e1SGreg Roach 25b315f3e1SGreg Roach$parent = $fact->record(); 26b315f3e1SGreg Roach$tree = $parent->tree(); 27b315f3e1SGreg Roach[, $tag] = explode(':', $fact->tag()); 28b315f3e1SGreg Roach$label = $fact->label(); 29b315f3e1SGreg Roach$value = $fact->value(); 30b315f3e1SGreg Roach$type = $fact->attribute('TYPE'); 31b315f3e1SGreg Roach$id = $fact->id(); 32b315f3e1SGreg Roach 33b315f3e1SGreg Roach$element = Registry::elementFactory()->make($fact->tag()); 34b315f3e1SGreg Roach 35b315f3e1SGreg Roach// New or deleted facts need different styling 36b315f3e1SGreg Roach$styles = []; 37b315f3e1SGreg Roachif ($fact->isPendingAddition()) { 38b315f3e1SGreg Roach $styles[] = 'wt-new'; 39b315f3e1SGreg Roach} 40b315f3e1SGreg Roachif ($fact->isPendingDeletion()) { 41b315f3e1SGreg Roach $styles[] = 'wt-old'; 42b315f3e1SGreg Roach} 43b315f3e1SGreg Roach 44b315f3e1SGreg Roach// Event of close relative 45b315f3e1SGreg Roachif ($tag === 'EVEN' && $value === 'CLOSE_RELATIVE') { 46b315f3e1SGreg Roach $value = ''; 47b315f3e1SGreg Roach $styles[] = 'wt-relation-fact collapse'; 48b315f3e1SGreg Roach} 49b315f3e1SGreg Roach 50b315f3e1SGreg Roach// Event of close associates 51b315f3e1SGreg Roachif ($id === 'asso') { 52b315f3e1SGreg Roach $styles[] = 'wt-associate-fact collapse'; 53b315f3e1SGreg Roach} 54b315f3e1SGreg Roach 55b315f3e1SGreg Roachif ($element instanceof UnknownElement && $tree->getPreference('HIDE_GEDCOM_ERRORS') === '0') { 56b315f3e1SGreg Roach $styles[] = 'd-none'; 57b315f3e1SGreg Roach} 58b315f3e1SGreg Roach 59b315f3e1SGreg Roach 60b315f3e1SGreg Roach// historical facts 61b315f3e1SGreg Roachif ($id === 'histo') { 62b315f3e1SGreg Roach $styles[] = 'wt-historic-fact collapse'; 63b315f3e1SGreg Roach} 64b315f3e1SGreg Roach 65b315f3e1SGreg Roach// Use marriage type as the label. e.g. "Civil partnership" 66b315f3e1SGreg Roachif ($tag === 'MARR') { 67b315f3e1SGreg Roach $label = $fact->label(); 68b315f3e1SGreg Roach $type = ''; 69b315f3e1SGreg Roach} 70b315f3e1SGreg Roach 71b315f3e1SGreg Roach?> 72b315f3e1SGreg Roach<tr class="<?= implode(' ', $styles) ?>"> 73b315f3e1SGreg Roach <th scope="row"> 74b315f3e1SGreg Roach <div class="wt-fact-label"><?= $label?></div> 75b315f3e1SGreg Roach 76b315f3e1SGreg Roach <?php if ($id !== 'histo' && $id !== 'asso' && $fact->canEdit() && !in_array($tag, ['HUSB', 'WIFE', 'CHIL', 'FAMC', 'FAMS'], true)) : ?> 77b315f3e1SGreg Roach <?= view('fact-edit-links', ['fact' => $fact, 'url' => $record->url()]) ?> 78b315f3e1SGreg Roach <?php endif ?> 79b315f3e1SGreg Roach 80b315f3e1SGreg Roach <?php if ($tree->getPreference('SHOW_FACT_ICONS')) : ?> 81b315f3e1SGreg Roach <span class="wt-fact-icon wt-fact-icon-<?= e($tag) ?>" title="<?= strip_tags($label) ?>"></span> 82b315f3e1SGreg Roach <?php endif ?> 83b315f3e1SGreg Roach </th> 84b315f3e1SGreg Roach 85b315f3e1SGreg Roach <td> 86b315f3e1SGreg Roach <?php if ($fact->target() instanceof Media) : ?> 87*8c19bf42SGreg Roach <div class="d-flex flex-wrap"> 88b315f3e1SGreg Roach <?php foreach ($fact->target()->mediaFiles() as $media_file) : ?> 89*8c19bf42SGreg Roach <div class="me-1 mb-1"> 90b315f3e1SGreg Roach <?= $media_file->displayImage(100, 100, 'contain', []) ?> 91*8c19bf42SGreg Roach </div> 92b315f3e1SGreg Roach <?php endforeach ?> 93b315f3e1SGreg Roach </div> 94b315f3e1SGreg Roach 95b315f3e1SGreg Roach <a href="<?= e($fact->target()->url()) ?>"><?= $fact->target()->fullName() ?></a> 96b315f3e1SGreg Roach 97b315f3e1SGreg Roach <?php foreach ($fact->target()->facts(['NOTE']) as $note) : ?> 98b315f3e1SGreg Roach <?= view('fact-gedcom-fields', ['gedcom' => $note->gedcom(), 'parent' => $fact->target()->tag(), 'tree' => $fact->record()->tree()]) ?> 99b315f3e1SGreg Roach <?php endforeach ?> 100b315f3e1SGreg Roach <?php else : ?> 101b315f3e1SGreg Roach <div class="wt-fact-main-attributes"> 102b315f3e1SGreg Roach <?php if ($parent !== $record) : ?> 103b315f3e1SGreg Roach <div class="wt-fact-record"> 104b315f3e1SGreg Roach <?php if ($parent instanceof Family) : ?> 105b315f3e1SGreg Roach <?php foreach ($parent->spouses()->filter(static fn ($individual): bool => $individual !== $record) as $spouse) : ?> 106b315f3e1SGreg Roach <a href="<?= e($spouse->url()) ?>"><?= $spouse->fullName() ?></a> — 107b315f3e1SGreg Roach <?php endforeach ?> 108b315f3e1SGreg Roach <a href="<?= e($parent->url()) ?>"><?= I18N::translate('View this family') ?></a> 109b315f3e1SGreg Roach <?php elseif ($parent instanceof Individual) : ?> 110b315f3e1SGreg Roach <a href="<?= e($parent->url()) ?>"><?= $parent->fullName() ?></a> 111b315f3e1SGreg Roach <?php endif ?> 112b315f3e1SGreg Roach </div> 113b315f3e1SGreg Roach <?php endif ?> 114b315f3e1SGreg Roach 115b315f3e1SGreg Roach <div class="wt-fact-value"> 116b315f3e1SGreg Roach <?= $element->value($value, $tree) ?> 117b315f3e1SGreg Roach <?php if ($element instanceof XrefAssociate && $fact->target() instanceof Individual) : ?> 118b315f3e1SGreg Roach <?php 119b315f3e1SGreg Roach $module = app(ModuleService::class)->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) 120b315f3e1SGreg Roach ->first(static fn (ModuleInterface $module):bool => $module instanceof RelationshipsChartModule) 121b315f3e1SGreg Roach ?> 122b315f3e1SGreg Roach 123b61651baSGreg Roach <?php if ($module instanceof RelationshipsChartModule && $record instanceof Individual) : ?> 124b315f3e1SGreg Roach — <a href="<?= $module->chartUrl($fact->target(), ['xref2' => $record->xref()]) ?>" rel="nofollow"> 125b315f3e1SGreg Roach <?= app(RelationshipService::class)->getCloseRelationshipName($fact->target(), $record) ?> 126b315f3e1SGreg Roach </a> 127b315f3e1SGreg Roach <?php endif ?> 128b315f3e1SGreg Roach <?php endif ?> 129b315f3e1SGreg Roach </div> 130b315f3e1SGreg Roach 131b315f3e1SGreg Roach <!-- Type of this fact/event (allow user-translations) --> 132b315f3e1SGreg Roach <?php if ($type !== '' && $tag !== 'EVEN' && $tag !== 'FACT') : ?> 133b315f3e1SGreg Roach <div class="wt-fact-type"> 134b315f3e1SGreg Roach <?= Registry::elementFactory()->make($fact->tag() . ':TYPE')->labelValue(I18N::translate($type), $tree) ?> 135b315f3e1SGreg Roach </div> 136b315f3e1SGreg Roach <?php endif ?> 137b315f3e1SGreg Roach 138b315f3e1SGreg Roach <?= view('fact-date', ['cal_link' => 'true', 'fact' => $fact, 'record' => $record, 'time' => true]) ?> 139b315f3e1SGreg Roach <?= view('fact-place', ['fact' => $fact, 'record' => $record]) ?> 140b315f3e1SGreg Roach </div> 141b315f3e1SGreg Roach 142b315f3e1SGreg Roach <div class="wt-fact-other-attributes mt-2"> 1439926a509SGreg Roach <?php preg_match_all('/\n2 (' . Gedcom::REGEX_TAG . ')( .*)?((\n[3-9].*)*)/', $fact->gedcom(), $matches, PREG_SET_ORDER) ?> 144b315f3e1SGreg Roach <?php foreach ($matches as $match) : ?> 1459926a509SGreg Roach <?php if (!in_array($match[1], ['DATE', 'AGE', 'HUSB', 'WIFE', 'PLAC', 'ASSO', '_ASSO', 'STAT', 'TEMP', 'TYPE', 'CONT', 'NOTE', 'OBJE', 'SOUR'], true)) : ?> 146b315f3e1SGreg Roach <?= view('fact-gedcom-fields', ['gedcom' => $match[0], 'parent' => $fact->tag() . ':' . $match[1], 'tree' => $tree]) ?> 147b315f3e1SGreg Roach <?php endif ?> 148b315f3e1SGreg Roach <?php endforeach; ?> 149b315f3e1SGreg Roach </div> 150b315f3e1SGreg Roach 151b315f3e1SGreg Roach <?php if ($id !== 'asso') : ?> 152b315f3e1SGreg Roach <?= view('fact-associates', ['fact' => $fact]) ?> 153b315f3e1SGreg Roach <?php endif ?> 154b315f3e1SGreg Roach 155b315f3e1SGreg Roach <?= view('fact-sources', ['fact' => $fact]) ?> 156b315f3e1SGreg Roach <?= view('fact-notes', ['fact' => $fact]) ?> 157b315f3e1SGreg Roach <?= view('fact-media', ['fact' => $fact]) ?> 158b315f3e1SGreg Roach <?php endif ?> 159b315f3e1SGreg Roach </td> 160b315f3e1SGreg Roach</tr> 161