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