xref: /webtrees/resources/views/individual-page-menu.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Auth;
6use Fisharebest\Webtrees\Fact;
7use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
8use Fisharebest\Webtrees\Http\RequestHandlers\DeleteRecord;
9use Fisharebest\Webtrees\Http\RequestHandlers\EditFactPage;
10use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordPage;
11use Fisharebest\Webtrees\Http\RequestHandlers\ReorderFamiliesPage;
12use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaPage;
13use Fisharebest\Webtrees\Http\RequestHandlers\ReorderNamesPage;
14use Fisharebest\Webtrees\I18N;
15use Fisharebest\Webtrees\Individual;
16use Illuminate\Support\Collection;
17
18/**
19 * @var bool                   $can_upload_media
20 * @var Collection<int,Fact>   $clipboard_facts
21 * @var Individual             $record
22 * @var Collection<int,string> $shares
23 */
24
25?>
26
27<div class="dropdown wt-page-menu">
28    <button class="btn btn-primary dropdown-toggle wt-page-menu-button" type="button" id="page-menu" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
29        <?= view('icons/menu') ?>
30        <?= I18N::translate('edit') ?>
31    </button>
32
33    <div class="dropdown-menu dropdown-menu-end wt-page-menu-items" aria-labelledby="page-menu">
34        <?php if ($shares->isNotEmpty()) : ?>
35            <button class="dropdown-item"  data-bs-toggle="modal" data-bs-target="#wt-shares-modal">
36                <?= view('icons/share') ?>
37                <?= I18N::translate('Share') ?>
38            </button>
39
40            <hr>
41        <?php endif ?>
42
43        <a class="dropdown-item" href="<?= e(route(AddNewFact::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref(), 'fact' => 'NAME'])) ?>">
44            <?= view('icons/add') ?>
45            <?= I18N::translate('Add a name') ?>
46        </a>
47
48        <?php if ($record->facts(['NAME'], false, null, true)->count() > 1) : ?>
49            <a class="dropdown-item" href="<?= e(route(ReorderNamesPage::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
50                <?= view('icons/reorder') ?>
51                <?= I18N::translate('Re-order names') ?>
52            </a>
53        <?php else : ?>
54            <div class="dropdown-item disabled">
55                <?= view('icons/spacer') ?>
56                <?= I18N::translate('Re-order names') ?>
57            </div>
58        <?php endif ?>
59
60        <div class="dropdown-divider"></div>
61
62        <?php if ($record->facts(['SEX'], false, null, true)->isEmpty()) : ?>
63            <a class="dropdown-item" href="<?= e(route(AddNewFact::class, ['fact' => 'SEX', 'tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
64                <?= view('icons/edit') ?>
65                <?= I18N::translate('Edit the gender') ?>
66            </a>
67        <?php endif ?>
68
69        <?php foreach ($record->facts(['SEX'], false, null, true) as $fact) : ?>
70            <?php if ($fact->canEdit()) : ?>
71                <a class="dropdown-item" href="<?= e(route(EditFactPage::class, ['xref' => $record->xref(), 'fact_id' => $fact->id(), 'tree' => $record->tree()->name()])) ?>">
72                    <?= view('icons/edit') ?>
73                    <?= I18N::translate('Edit the gender') ?>
74                </a>
75            <?php endif ?>
76        <?php endforeach ?>
77
78        <div class="dropdown-divider"></div>
79
80        <?php if ($record->spouseFamilies()->count() > 1 || $record->childFamilies()->count() > 1) : ?>
81            <a class="dropdown-item" href="<?= e(route(ReorderFamiliesPage::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
82                <?= view('icons/reorder') ?>
83                <?= I18N::translate('Re-order families') ?>
84            </a>
85        <?php else : ?>
86            <div class="dropdown-item disabled">
87                <?= view('icons/spacer') ?>
88                <?= I18N::translate('Re-order families') ?>
89            </div>
90        <?php endif ?>
91
92        <div class="dropdown-divider"></div>
93
94        <?php if ($can_upload_media) : ?>
95            <a class="dropdown-item" href="<?= e(route(AddNewFact::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref(), 'fact' => 'OBJE'])) ?>">
96                <?= view('icons/add') ?>
97                <?= I18N::translate('Add a media object') ?>
98            </a>
99        <?php endif ?>
100
101        <?php if ($record->facts(['OBJE'], false, null, true)->count() > 1) : ?>
102            <a class="dropdown-item" href="<?= e(route(ReorderMediaPage::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
103                <?= view('icons/reorder') ?>
104                <?= I18N::translate('Re-order media') ?>
105            </a>
106        <?php else : ?>
107            <div class="dropdown-item disabled">
108                <?= view('icons/spacer') ?>
109                <?= I18N::translate('Re-order media') ?>
110            </div>
111        <?php endif ?>
112
113        <?php if ($clipboard_facts->isNotEmpty()) : ?>
114            <div class="dropdown-divider"></div>
115
116            <?= view('record-page-menu-clipboard', ['clipboard_facts' => $clipboard_facts, 'record' => $record]) ?>
117        <?php endif ?>
118
119        <div class="dropdown-divider"></div>
120
121        <a class="dropdown-item" href="#" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', strip_tags($record->fullName())) ?>" data-wt-post-url="<?= e(route(DeleteRecord::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
122            <?= view('icons/delete') ?>
123            <?= I18N::translate('Delete') ?>
124        </a>
125
126        <?php if (Auth::isAdmin() || $record->tree()->getPreference('SHOW_GEDCOM_RECORD') === '1') : ?>
127            <a class="dropdown-item" href="<?= e(route(EditRawRecordPage::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>">
128                <?= view('icons/edit') ?>
129                <?= I18N::translate('Edit the raw GEDCOM') ?>
130            </a>
131        <?php endif ?>
132    </div>
133</div>
134