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