xref: /webtrees/resources/views/media-page.phtml (revision 9b152ff9230017d2c03aa1bf603a98b18250446d)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Functions\FunctionsPrint;
5use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
6use Fisharebest\Webtrees\GedcomTag;
7use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
8use Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact;
9use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord;
10use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord;
11use Fisharebest\Webtrees\I18N;
12use Fisharebest\Webtrees\Media;
13use Illuminate\Support\Collection;
14
15/**
16 * @var Collection $clipboard_facts
17 * @var Collection $facts
18 * @var Collection $families
19 * @var Collection $individuals
20 * @var Media      $media
21 * @var Collection $notes
22 * @var Collection $sources
23 */
24?>
25
26<?php if ($media->isPendingDeletion()) : ?>
27    <?php if (Auth::isModerator($media->tree())) : ?>
28        <?= view('components/alert-warning-dismissible', ['alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate('This media object has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
29    <?php elseif (Auth::isEditor($media->tree())) : ?>
30        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
31    <?php endif ?>
32<?php elseif ($media->isPendingAddition()) : ?>
33    <?php if (Auth::isModerator($media->tree())) : ?>
34        <?= view('components/alert-warning-dismissible', ['alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ I18N::translate('This media object has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
35    <?php elseif (Auth::isEditor($media->tree())) : ?>
36        <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes')]) ?>
37    <?php endif ?>
38<?php endif ?>
39
40<div class="d-flex mb-4">
41    <h2 class="wt-page-title mx-auto">
42        <?= $media->fullName() ?>
43    </h2>
44    <?php if ($media->canEdit()) : ?>
45        <?= view('media-page-menu', ['record' => $media]) ?>
46    <?php endif ?>
47</div>
48
49<div class="wt-page-content">
50    <ul class="nav nav-tabs" role="tablist">
51        <li class="nav-item">
52            <a class="nav-link active" data-toggle="tab" role="tab" href="#details">
53                <?= I18N::translate('Details') ?>
54            </a>
55        </li>
56        <li class="nav-item">
57            <a class="nav-link<?= $individuals->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#individuals">
58                <?= I18N::translate('Individuals') ?>
59                <?= view('components/badge', ['count' => $individuals->count()]) ?>
60            </a>
61        </li>
62        <li class="nav-item">
63            <a class="nav-link<?= $families->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#families">
64                <?= I18N::translate('Families') ?>
65                <?= view('components/badge', ['count' => $families->count()]) ?>
66            </a>
67        </li>
68        <li class="nav-item">
69            <a class="nav-link<?= $sources->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#sources">
70                <?= I18N::translate('Sources') ?>
71                <?= view('components/badge', ['count' => $sources->count()]) ?>
72            </a>
73        </li>
74        <li class="nav-item">
75            <a class="nav-link<?= $notes->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#notes">
76                <?= I18N::translate('Notes') ?>
77                <?= view('components/badge', ['count' => $notes->count()]) ?>
78            </a>
79        </li>
80    </ul>
81
82    <div class="tab-content mt-4">
83        <div class="tab-pane active fade show" role="tabpanel" id="details">
84            <table class="table wt-facts-table">
85                <?php foreach ($media->mediaFiles() as $media_file) : ?>
86                    <tr class="<?= $media_file->isPendingAddition() ? 'wt-new' : '' ?><?= $media_file->isPendingDeletion() ? 'wt-old' : '' ?>">
87                        <th scope="row">
88                            <?= I18N::translate('Media file') ?>
89                            <?php if ($media->canEdit()) : ?>
90                                <div class="editfacts nowrap">
91                                    <a class="btn btn-link" href="#" data-toggle="modal" data-target="#wt-ajax-modal" data-href="<?= route('edit-media-file', ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact_id' => $media_file->factId()]) ?>" title="<?= I18N::translate('Edit') ?>">
92                                        <?= view('icons/edit') ?>
93                                        <span class="sr-only">
94                                        <?= I18N::translate('Edit') ?>
95                                    </span>
96                                    </a>
97
98                                    <?php if (count($media->mediaFiles()) > 1) : ?>
99                                        <a class="btn btn-link" href="#" data-confirm="<?= I18N::translate('Are you sure you want to delete this fact?') ?>" data-post-url="<?= e(route(DeleteFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact_id' => $media_file->factId()])) ?>" title="<?= I18N::translate('Delete') ?>">
100                                            <?= view('icons/delete') ?>
101                                            <span class="sr-only">
102                                        <?= I18N::translate('Delete') ?>
103                                    </span>
104                                        </a>
105
106                                    <?php endif ?>
107                                </div>
108                            <?php endif ?>
109                        </th>
110                        <td class="d-flex justify-content-between">
111                            <div>
112                                <?php if ($media_file->isExternal()) : ?>
113                                    <?= GedcomTag::getLabelValue('URL', $media_file->filename()) ?>
114                                <?php elseif (Auth::isEditor($media->tree())) :?>
115                                    <?php if (!$media_file->fileExists($data_filesystem)) : ?>
116                                        <p class="alert alert-danger">
117                                            <?= I18N::translate('The file “%s” does not exist.', $media_file->filename()) ?>
118                                        </p>
119                                    <?php endif ?>
120                                    <?= GedcomTag::getLabelValue('FILE', $media_file->filename()) ?>
121                                <?php endif ?>
122
123                                <?= GedcomTag::getLabelValue('TITL', e($media_file->title())) ?>
124                                <?= GedcomTag::getLabelValue('TYPE', e($media_file->type())) ?>
125                                <?= GedcomTag::getLabelValue('FORM', e($media_file->format())) ?>
126                            </div>
127
128                            <div>
129                                <?php if (!$media_file->isExternal()) : ?>
130                                    <?= $media_file->displayImage(200, 150, 'contain', []) ?>
131                                    <?php if ($media->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($media->tree()) && $media_file->fileExists($data_filesystem)) : ?>
132                                        <br>
133                                        <a href="<?= e(route('media-download', ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact_id' => $media_file->factId()])) ?>">
134                                            <?= I18N::translate('Download file') ?>
135                                        </a>
136                                    <?php endif ?>
137                                <?php endif ?>
138                            </div>
139                        </td>
140                    </tr>
141                <?php endforeach ?>
142                <?php foreach ($facts as $fact) : ?>
143                    <?php if ($fact->getTag() !== 'FILE') : ?>
144                        <?php FunctionsPrintFacts::printFact($fact, $media) ?>
145                    <?php endif ?>
146                <?php endforeach ?>
147                <?php if ($media->canEdit()) : ?>
148                    <?= view('edit/paste-fact-row', ['record' => $media, 'facts' => $clipboard_facts]) ?>
149
150                    <?php FunctionsPrint::printAddNewFact($media, $facts, 'OBJE') ?>
151                    <tr>
152                        <th>
153                            <?= I18N::translate('Source') ?>
154                        </th>
155                        <td>
156                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SOUR'])) ?>">
157                                <?= I18N::translate('Add a source citation') ?>
158                            </a>
159                        </td>
160                    </tr>
161                    <tr>
162                        <th scope="row">
163                            <?= I18N::translate('Shared note') ?>
164                        </th>
165                        <td>
166                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SHARED_NOTE'])) ?>">
167                                <?= I18N::translate('Add a shared note') ?>
168                            </a>
169                        </td>
170                    </tr>
171                    <tr>
172                        <th scope="row">
173                            <?= I18N::translate('Restriction') ?>
174                        </th>
175                        <td>
176                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'RESN'])) ?>">
177                                <?= I18N::translate('Add a restriction') ?>
178                            </a>
179                        </td>
180                    </tr>
181                    <tr>
182                        <th scope="row">
183                            <?= I18N::translate('Media file') ?>
184                        </th>
185                        <td>
186                            <a href="#" data-href="<?= e(route('add-media-file', ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
187                                <?= I18N::translate('Add a media file') ?>
188                            </a>
189                        </td>
190                    </tr>
191                <?php endif ?>
192            </table>
193        </div>
194
195        <div class="tab-pane fade" role="tabpanel" id="individuals">
196            <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?>
197        </div>
198
199        <div class="tab-pane fade" role="tabpanel" id="families">
200            <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?>
201        </div>
202
203        <div class="tab-pane fade" role="tabpanel" id="sources">
204            <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?>
205        </div>
206
207        <div class="tab-pane fade" role="tabpanel" id="notes">
208            <?= view('lists/notes-table', ['notes' => $notes, 'tree' => $tree]) ?>
209        </div>
210    </div>
211</div>
212
213<?= view('modals/ajax') ?>
214