xref: /webtrees/resources/views/note-page.phtml (revision 455a30fe529581f1d53045f9c38a0674472d498f)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Fact;
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\Functions\FunctionsPrint;
7use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
8use Fisharebest\Webtrees\Http\RequestHandlers\EditNotePage;
9use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord;
10use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord;
11use Fisharebest\Webtrees\I18N;
12use Fisharebest\Webtrees\Individual;
13use Fisharebest\Webtrees\Media;
14use Fisharebest\Webtrees\Note;
15use Fisharebest\Webtrees\Source;
16use Fisharebest\Webtrees\Tree;
17use Illuminate\Support\Collection;
18
19/**
20 * @var Note                   $note
21 * @var Collection<Fact>       $clipboard_facts
22 * @var Collection<Fact>       $facts
23 * @var Collection<Family>     $families
24 * @var Collection<Individual> $individuals
25 * @var Collection<Media>      $media_objects
26 * @var Collection<Source>     $sources
27 * @var string                 $text
28 * @var Tree                   $tree
29 */
30
31?>
32
33<?php if ($note->isPendingDeletion()) : ?>
34    <?php if (Auth::isModerator($note->tree())) : ?>
35        <?= view('components/alert-warning-dismissible', ['alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate('This note has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $note->tree()->name(), 'xref' => $note->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $note->tree()->name(), 'xref' => $note->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?>
36    <?php elseif (Auth::isEditor($note->tree())) : ?>
37        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This note has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?>
38    <?php endif ?>
39<?php elseif ($note->isPendingAddition()) : ?>
40    <?php if (Auth::isModerator($note->tree())) : ?>
41        <?= view('components/alert-warning-dismissible', ['alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate('This note has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $note->tree()->name(), 'xref' => $note->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $note->tree()->name(), 'xref' => $note->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?>
42    <?php elseif (Auth::isEditor($note->tree())) : ?>
43        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This note has been edited. The changes need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?>
44    <?php endif ?>
45<?php endif ?>
46
47<div class="d-flex mb-4">
48    <h2 class="wt-page-title mx-auto">
49        <?= $note->fullName() ?>
50    </h2>
51    <?php if ($note->canEdit()) : ?>
52        <?= view('note-page-menu', ['record' => $note]) ?>
53    <?php endif ?>
54</div>
55
56<div class="wt-page-content">
57    <ul class="nav nav-tabs" role="tablist">
58        <li class="nav-item" role="presentation">
59            <a class="nav-link active" data-toggle="tab" role="tab" href="#details">
60                <?= I18N::translate('Details') ?>
61            </a>
62        </li>
63
64        <li class="nav-item" role="presentation">
65            <a class="nav-link<?= $individuals->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#individuals">
66                <?= I18N::translate('Individuals') ?>
67                <?= view('components/badge', ['count' => count($individuals)]) ?>
68            </a>
69        </li>
70
71        <li class="nav-item" role="presentation">
72            <a class="nav-link<?= $families->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#families">
73                <?= I18N::translate('Families') ?>
74                <?= view('components/badge', ['count' => count($families)]) ?>
75            </a>
76        </li>
77
78        <li class="nav-item" role="presentation">
79            <a class="nav-link<?= $media_objects->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#media">
80                <?= I18N::translate('Media objects') ?>
81                <?= view('components/badge', ['count' => count($media_objects)]) ?>
82            </a>
83        </li>
84
85        <li class="nav-item" role="presentation">
86            <a class="nav-link<?= $sources->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#sources">
87                <?= I18N::translate('Sources') ?>
88                <?= view('components/badge', ['count' => count($sources)]) ?>
89            </a>
90        </li>
91    </ul>
92
93    <div class="tab-content">
94        <div class="tab-pane active fade show" role="tabpanel" id="details">
95            <table class="table wt-facts-table">
96                <tr>
97                    <th scope="row">
98                        <?= I18N::translate('Shared note') ?>
99                        <?php if (Auth::isEditor($note->tree())) : ?>
100                            <div class="editfacts nowrap">
101                                <a class="btn btn-link" href="<?= e(route(EditNotePage::class, ['xref' => $note->xref(), 'tree' => $note->tree()->name()])) ?>" title="<?= I18N::translate('Edit') ?>">
102                                    <?= view('icons/edit') ?>
103                                    <span class="sr-only">
104                                        <?= I18N::translate('Edit') ?>
105                                    </span>
106                                </a>
107                            </div>
108                        <?php endif ?>
109                    </th>
110                    <td><?= $text ?></td>
111                </tr>
112                <?php foreach ($facts as $fact) : ?>
113                    <?php FunctionsPrintFacts::printFact($fact, $note) ?>
114                <?php endforeach ?>
115
116                <?php if ($note->canEdit()) : ?>
117                    <?= view('edit/paste-fact-row', ['record' => $note, 'facts' => $clipboard_facts]) ?>
118
119                    <?php FunctionsPrint::printAddNewFact($note, $facts, Note::RECORD_TYPE) ?>
120                <?php endif ?>
121            </table>
122        </div>
123
124        <div class="tab-pane fade" role="tabpanel" id="individuals">
125            <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?>
126        </div>
127
128        <div class="tab-pane fade" role="tabpanel" id="families">
129            <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?>
130        </div>
131
132        <div class="tab-pane fade" role="tabpanel" id="media">
133            <?= view('lists/media-table', ['media_objects' => $media_objects, 'tree' => $tree]) ?>
134        </div>
135
136        <div class="tab-pane fade" role="tabpanel" id="sources">
137            <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?>
138        </div>
139    </div>
140</div>
141
142<?= view('modals/ajax') ?>
143