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