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