1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\Elements\SubmitterText; 6use Fisharebest\Webtrees\Fact; 7use Fisharebest\Webtrees\Gedcom; 8use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 9use Fisharebest\Webtrees\I18N; 10use Fisharebest\Webtrees\Individual; 11use Fisharebest\Webtrees\Note; 12use Fisharebest\Webtrees\Registry; 13use Illuminate\Support\Collection; 14 15/** 16 * @var bool $can_edit 17 * @var Collection<int,Fact> $clipboard_facts 18 * @var Collection<int,Fact> $facts 19 * @var Individual $individual 20 */ 21 22?> 23 24<div class="wt-tan-notes py-4"> 25 <table class="table wt-facts-table"> 26 <tr> 27 <td colspan="2"> 28 <label> 29 <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" autocomplete="off"> 30 <?= I18N::translate('Show all notes') ?> 31 </label> 32 </td> 33 </tr> 34 35 <?php foreach ($facts as $fact) : ?> 36 <?php if ($fact->tag() === 'INDI:NOTE' || $fact->tag() === 'FAM:NOTE') : ?> 37 <?= view('fact', ['fact' => $fact, 'record' => $individual]) ?> 38 <?php else : ?> 39 <?php 40 if ($fact->isPendingAddition()) { 41 $styleadd = 'wt-new '; 42 } elseif ($fact->isPendingDeletion()) { 43 $styleadd = 'wt-old '; 44 } else { 45 $styleadd = ''; 46 } 47 ?> 48 49 <tr class="wt-level-two-note collapse"> 50 <th scope="row" class="rela <?= $styleadd ?>"> 51 <?= $fact->label() ?> 52 <?= view('fact-edit-links', ['fact' => $fact, 'url' => $fact->record()->url() . '#tab-notes']) ?> 53 </th> 54 55 <td class="<?= $styleadd ?>"> 56 <?php preg_match_all("/\n[1-9] NOTE ?(.*(?:\n\d CONT.*)*)/", $fact->gedcom(), $matches, PREG_SET_ORDER) ?> 57 <?php foreach ($matches as $match) : ?> 58 <div class="mb-2"> 59 <?php $text = preg_replace('/\n\d CONT ?/', "\n", $match[1]) ?> 60 <?php if (preg_match('/^@' . Gedcom::REGEX_XREF . '@$/', $text) === 1) : ?> 61 <?php $note = Registry::noteFactory()->make(trim($text, '@'), $individual->tree()) ?> 62 <?php if ($note instanceof Note) : ?> 63 <?php if ($note->canShow()) : ?> 64 <a href="<?= e($note->url()) ?>"> 65 <?= I18N::translate('Shared note') ?> 66 <?= view('icons/note') ?> 67 </a> 68 <?= (new SubmitterText(''))->value($note->getNote(), $individual->tree()) ?> 69 <?php endif ?> 70 <?php else : ?> 71 <span class="error"><?= e($text) ?></span> 72 <?php endif ?> 73 <?php else : ?> 74 <?= (new SubmitterText(''))->value($text, $individual->tree()) ?> 75 <?php endif ?> 76 </div> 77 <?php endforeach ?> 78 </td> 79 </tr> 80 <?php endif ?> 81 <?php endforeach ?> 82 83 <?php if ($facts->isEmpty()) : ?> 84 <tr> 85 <td colspan="2"> 86 <?= I18N::translate('There are no notes for this individual.') ?> 87 </td> 88 </tr> 89 <?php endif ?> 90 91 <?php if ($can_edit) : ?> 92 <tr> 93 <th scope="row"> 94 <?= I18N::translate('Note') ?> 95 </th> 96 <td> 97 <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'NOTE'])) ?>"> 98 <?= I18N::translate('Add a note') ?> 99 </a> 100 </td> 101 </tr> 102 <?php endif ?> 103 </table> 104</div> 105