12917771cSGreg Roach<?php 22917771cSGreg Roach 3*b315f3e1SGreg Roachuse Fisharebest\Webtrees\Elements\SubmitterText; 47c2c99faSGreg Roachuse Fisharebest\Webtrees\Fact; 5*b315f3e1SGreg Roachuse Fisharebest\Webtrees\Gedcom; 62917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 72917771cSGreg Roachuse Fisharebest\Webtrees\I18N; 87c2c99faSGreg Roachuse Fisharebest\Webtrees\Individual; 9*b315f3e1SGreg Roachuse Fisharebest\Webtrees\Note; 10*b315f3e1SGreg Roachuse Fisharebest\Webtrees\Registry; 117c2c99faSGreg Roachuse Illuminate\Support\Collection; 127c2c99faSGreg Roach 137c2c99faSGreg Roach/** 147c2c99faSGreg Roach * @var bool $can_edit 157c2c99faSGreg Roach * @var Collection<Fact> $clipboard_facts 167c2c99faSGreg Roach * @var Collection<Fact> $facts 177c2c99faSGreg Roach * @var Individual $individual 187c2c99faSGreg Roach */ 192917771cSGreg Roach 202917771cSGreg Roach?> 21dd6b2bfcSGreg Roach 224a2590a5SGreg Roach<div class="wt-tan-notes py-4"> 23dd6b2bfcSGreg Roach <table class="table wt-facts-table"> 24dd6b2bfcSGreg Roach <tr> 25dd6b2bfcSGreg Roach <td colspan="2"> 26dd6b2bfcSGreg Roach <label> 272d8276baSGreg Roach <input id="show-level-2-notes" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-level-two-note" data-wt-persist="level-two-notes"> 28dd6b2bfcSGreg Roach <?= I18N::translate('Show all notes') ?> 29dd6b2bfcSGreg Roach </label> 30dd6b2bfcSGreg Roach </td> 31dd6b2bfcSGreg Roach </tr> 32dd6b2bfcSGreg Roach 33dd6b2bfcSGreg Roach <?php foreach ($facts as $fact) : ?> 34*b315f3e1SGreg Roach <?php if ($fact->tag() === 'INDI:NOTE' || $fact->tag() === 'FAM:NOTE') : ?> 35*b315f3e1SGreg Roach <?= view('fact', ['fact' => $fact, 'record' => $individual]) ?> 36*b315f3e1SGreg Roach <?php else : ?> 37*b315f3e1SGreg Roach <?php 38*b315f3e1SGreg Roach if ($fact->isPendingAddition()) { 39*b315f3e1SGreg Roach $styleadd = 'wt-new '; 40*b315f3e1SGreg Roach } elseif ($fact->isPendingDeletion()) { 41*b315f3e1SGreg Roach $styleadd = 'wt-old '; 42*b315f3e1SGreg Roach } else { 43*b315f3e1SGreg Roach $styleadd = ''; 44*b315f3e1SGreg Roach } 45*b315f3e1SGreg Roach ?> 46*b315f3e1SGreg Roach 47*b315f3e1SGreg Roach <tr class="wt-level-two-note collapse"> 48*b315f3e1SGreg Roach <th scope="row" class="rela <?= $styleadd ?>"> 49*b315f3e1SGreg Roach <?= $fact->label() ?> 50*b315f3e1SGreg Roach <?= view('fact-edit-links', ['fact' => $fact, 'url' => $fact->record()->url() . '#tab-notes']) ?> 51*b315f3e1SGreg Roach </th> 52*b315f3e1SGreg Roach 53*b315f3e1SGreg Roach <td class="<?= $styleadd ?>"> 54*b315f3e1SGreg Roach <?php preg_match_all("/\n[1-9] NOTE ?(.*(?:\n\d CONT.*)*)/", $fact->gedcom(), $matches, PREG_SET_ORDER) ?> 55*b315f3e1SGreg Roach <?php foreach ($matches as $match) : ?> 56*b315f3e1SGreg Roach <div class="mb-2"> 57*b315f3e1SGreg Roach <?php $text = preg_replace('/\n\d CONT ?/', "\n", $match[1]) ?> 58*b315f3e1SGreg Roach <?php if (preg_match('/^@' . Gedcom::REGEX_XREF . '@$/', $text)) : ?> 59*b315f3e1SGreg Roach <?php $note = Registry::noteFactory()->make(trim($text, '@'), $individual->tree()) ?> 60*b315f3e1SGreg Roach <?php if ($note instanceof Note) : ?> 61*b315f3e1SGreg Roach <?php if ($note->canShow()) : ?> 62*b315f3e1SGreg Roach <a href="<?= e($note->url()) ?>"> 63*b315f3e1SGreg Roach <?= I18N::translate('Shared note') ?> 64*b315f3e1SGreg Roach <?= view('icons/note') ?> 65*b315f3e1SGreg Roach </a> 66*b315f3e1SGreg Roach <?= (new SubmitterText(''))->value($note->getNote(), $individual->tree()) ?> 67*b315f3e1SGreg Roach <?php endif ?> 68*b315f3e1SGreg Roach <?php else : ?> 69*b315f3e1SGreg Roach <span class="error"><?= e($text) ?></span> 70*b315f3e1SGreg Roach <?php endif ?> 71*b315f3e1SGreg Roach <?php else : ?> 72*b315f3e1SGreg Roach <?= (new SubmitterText(''))->value($text, $individual->tree()) ?> 73*b315f3e1SGreg Roach <?php endif ?> 74*b315f3e1SGreg Roach </div> 75dd6b2bfcSGreg Roach <?php endforeach ?> 76*b315f3e1SGreg Roach <?php endif ?> 77*b315f3e1SGreg Roach <?php endforeach ?> 78*b315f3e1SGreg Roach </td> 79*b315f3e1SGreg Roach </tr> 80dd6b2bfcSGreg Roach 81075d1a05SGreg Roach <?php if ($facts->isEmpty()) : ?> 82dd6b2bfcSGreg Roach <tr> 83dd6b2bfcSGreg Roach <td colspan="2"> 84dd6b2bfcSGreg Roach <?= I18N::translate('There are no notes for this individual.') ?> 85dd6b2bfcSGreg Roach </td> 86dd6b2bfcSGreg Roach </tr> 87dd6b2bfcSGreg Roach <?php endif ?> 88dd6b2bfcSGreg Roach 89dd6b2bfcSGreg Roach <?php if ($can_edit) : ?> 90dd6b2bfcSGreg Roach <tr> 91dd6b2bfcSGreg Roach <th scope="row"> 92dd6b2bfcSGreg Roach <?= I18N::translate('Note') ?> 93dd6b2bfcSGreg Roach </th> 94dd6b2bfcSGreg Roach <td> 952917771cSGreg Roach <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'NOTE'])) ?>"> 96dd6b2bfcSGreg Roach <?= I18N::translate('Add a note') ?> 97dd6b2bfcSGreg Roach </a> 98dd6b2bfcSGreg Roach </td> 99dd6b2bfcSGreg Roach </tr> 100dd6b2bfcSGreg Roach <?php endif ?> 101dd6b2bfcSGreg Roach </table> 102dd6b2bfcSGreg Roach</div> 103