xref: /webtrees/resources/views/media-page-menu.phtml (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Auth;
6use Fisharebest\Webtrees\Fact;
7use Fisharebest\Webtrees\Http\RequestHandlers\AddMediaFileModal;
8use Fisharebest\Webtrees\Http\RequestHandlers\DeleteRecord;
9use Fisharebest\Webtrees\Http\RequestHandlers\EditRecordPage;
10use Fisharebest\Webtrees\Http\RequestHandlers\LinkMediaToFamilyModal;
11use Fisharebest\Webtrees\Http\RequestHandlers\LinkMediaToIndividualModal;
12use Fisharebest\Webtrees\Http\RequestHandlers\LinkMediaToSourceModal;
13use Fisharebest\Webtrees\Http\RequestHandlers\ReorderMediaFilesPage;
14use Fisharebest\Webtrees\I18N;
15use Fisharebest\Webtrees\Media;
16use Illuminate\Support\Collection;
17
18/**
19 * @var Collection<int,Fact> $clipboard_facts
20 * @var Media                $record
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        <a class="dropdown-item" href="#" data-wt-href="<?= e(route(AddMediaFileModal::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-bs-target="#wt-ajax-modal" data-bs-toggle="modal" data-bs-backdrop="static">
33            <?= view('icons/add') ?>
34            <?= I18N::translate('Add a media file') ?>
35        </a>
36
37        <?php if ($record->mediaFiles()->count() >= 2) : ?>
38            <a class="dropdown-item" href="<?= route(ReorderMediaFilesPage::class, ['xref' => $record->xref(), 'tree' => $record->tree()->name()]) ?>">
39                <?= view('icons/reorder') ?>
40                <?= I18N::translate('Re-order media files') ?>
41            </a>
42        <?php endif ?>
43
44        <?php if ($record->missingFacts() !== []) : ?>
45            <div class="dropdown-divider"></div>
46
47            <?= view('record-page-menu-facts', ['record' => $record]) ?>
48        <?php endif ?>
49
50        <?php if ($clipboard_facts->isNotEmpty()) : ?>
51            <div class="dropdown-divider"></div>
52
53            <?= view('record-page-menu-clipboard', ['clipboard_facts' => $clipboard_facts, 'record' => $record]) ?>
54        <?php endif ?>
55
56        <div class="dropdown-divider"></div>
57
58        <a class="dropdown-item" href="#" data-wt-href="<?= e(route(LinkMediaToIndividualModal::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-bs-target="#wt-ajax-modal" data-bs-toggle="modal" data-bs-backdrop="static">
59            <?= view('icons/link') ?>
60            <?= I18N::translate('Link this media object to an individual') ?>
61        </a>
62
63        <a class="dropdown-item" href="#" data-wt-href="<?= e(route(LinkMediaToFamilyModal::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-bs-target="#wt-ajax-modal" data-bs-toggle="modal" data-bs-backdrop="static">
64            <?= view('icons/link') ?>
65            <?= I18N::translate('Link this media object to a family') ?>
66        </a>
67
68        <a class="dropdown-item" href="#" data-wt-href="<?= e(route(LinkMediaToSourceModal::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref()])) ?>" data-bs-target="#wt-ajax-modal" data-bs-toggle="modal" data-bs-backdrop="static">
69            <?= view('icons/link') ?>
70            <?= I18N::translate('Link this media object to a source') ?>
71        </a>
72
73        <?php if (Auth::isManager($record->tree())) : ?>
74            <div class="dropdown-divider"></div>
75
76            <a class="dropdown-item" href="<?= route(EditRecordPage::class, ['xref' => $record->xref(), 'tree' => $record->tree()->name()]) ?>">
77                <?= view('icons/edit') ?>
78                <?= I18N::translate('Edit') ?>
79            </a>
80        <?php endif ?>
81
82        <div class="dropdown-divider"></div>
83
84        <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()])) ?>">
85            <?= view('icons/delete') ?>
86            <?= I18N::translate('Delete') ?>
87        </a>
88    </div>
89</div>
90