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