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