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