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