xref: /webtrees/resources/views/media-page.phtml (revision b4a2f8851f56e7ca6fae19d0a51ff909996d7a30)
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>') . ' ' . view('help/link', ['topic' => '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.') . ' ' . view('help/link', ['topic' => '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>') . ' ' . view('help/link', ['topic' => '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.') . ' ' . view('help/link', ['topic' => '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" role="presentation">
52            <a class="nav-link active" data-toggle="tab" role="tab" href="#details">
53                <?= I18N::translate('Details') ?>
54            </a>
55        </li>
56
57        <li class="nav-item" role="presentation">
58            <a class="nav-link<?= $individuals->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#individuals">
59                <?= I18N::translate('Individuals') ?>
60                <?= view('components/badge', ['count' => $individuals->count()]) ?>
61            </a>
62        </li>
63
64        <li class="nav-item" role="presentation">
65            <a class="nav-link<?= $families->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#families">
66                <?= I18N::translate('Families') ?>
67                <?= view('components/badge', ['count' => $families->count()]) ?>
68            </a>
69        </li>
70
71        <li class="nav-item" role="presentation">
72            <a class="nav-link<?= $sources->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#sources">
73                <?= I18N::translate('Sources') ?>
74                <?= view('components/badge', ['count' => $sources->count()]) ?>
75            </a>
76        </li>
77
78        <li class="nav-item" role="presentation">
79            <a class="nav-link<?= $notes->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#notes">
80                <?= I18N::translate('Notes') ?>
81                <?= view('components/badge', ['count' => $notes->count()]) ?>
82            </a>
83        </li>
84    </ul>
85
86    <div class="tab-content mt-4">
87        <div class="tab-pane active fade show" role="tabpanel" id="details">
88            <table class="table wt-facts-table">
89                <?php foreach ($media->mediaFiles() as $media_file) : ?>
90                    <tr class="<?= $media_file->isPendingAddition() ? 'wt-new' : '' ?><?= $media_file->isPendingDeletion() ? 'wt-old' : '' ?>">
91                        <th scope="row">
92                            <?= I18N::translate('Media file') ?>
93                            <?php if ($media->canEdit()) : ?>
94                                <div class="editfacts nowrap">
95                                    <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') ?>">
96                                        <?= view('icons/edit') ?>
97                                        <span class="sr-only">
98                                        <?= I18N::translate('Edit') ?>
99                                    </span>
100                                    </a>
101
102                                    <?php if (count($media->mediaFiles()) > 1) : ?>
103                                        <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') ?>">
104                                            <?= view('icons/delete') ?>
105                                            <span class="sr-only">
106                                        <?= I18N::translate('Delete') ?>
107                                    </span>
108                                        </a>
109
110                                    <?php endif ?>
111                                </div>
112                            <?php endif ?>
113                        </th>
114                        <td class="d-flex justify-content-between">
115                            <div>
116                                <?php if ($media_file->isExternal()) : ?>
117                                    <?= GedcomTag::getLabelValue('URL', e($media_file->filename())) ?>
118                                <?php elseif (Auth::isEditor($media->tree())) :?>
119                                    <?php if (!$media_file->fileExists($data_filesystem)) : ?>
120                                        <p class="alert alert-danger">
121                                            <?= I18N::translate('The file “%s” does not exist.', e($media_file->filename())) ?>
122                                        </p>
123                                    <?php endif ?>
124                                    <?= GedcomTag::getLabelValue('FILE', e($media_file->filename())) ?>
125                                <?php endif ?>
126
127                                <?= GedcomTag::getLabelValue('TITL', e($media_file->title())) ?>
128                                <?= GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue(e($media_file->type()))) ?>
129                                <?= GedcomTag::getLabelValue('FORM', e($media_file->format())) ?>
130                            </div>
131
132                            <div>
133                                <?php if (!$media_file->isExternal()) : ?>
134                                    <?php if (explode('/', $media_file->mimeType())[0] === 'audio') : ?>
135                                    <audio controls>
136                                        <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>">
137                                    </audio>
138                                    <?php elseif (explode('/', $media_file->mimeType())[0] === 'video') : ?>
139                                        <video controls width="300">
140                                            <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>">
141                                        </video>
142                                    <?php else : ?>
143                                        <?= $media_file->displayImage(200, 150, 'contain', []) ?>
144                                    <?php endif ?>
145                                    <?php if ($media->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($media->tree()) && $media_file->fileExists($data_filesystem)) : ?>
146                                        <br>
147                                        <a href="<?= e($media_file->downloadUrl('attachment')) ?>">
148                                            <?= I18N::translate('Download file') ?>
149                                        </a>
150                                    <?php endif ?>
151                                <?php endif ?>
152                            </div>
153                        </td>
154                    </tr>
155                <?php endforeach ?>
156                <?php foreach ($facts as $fact) : ?>
157                    <?php FunctionsPrintFacts::printFact($fact, $media) ?>
158                <?php endforeach ?>
159                <?php if ($media->canEdit()) : ?>
160                    <?= view('edit/paste-fact-row', ['record' => $media, 'facts' => $clipboard_facts]) ?>
161
162                    <?php FunctionsPrint::printAddNewFact($media, $facts, Media::RECORD_TYPE) ?>
163                    <tr>
164                        <th>
165                            <?= I18N::translate('Source') ?>
166                        </th>
167                        <td>
168                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SOUR'])) ?>">
169                                <?= I18N::translate('Add a source citation') ?>
170                            </a>
171                        </td>
172                    </tr>
173                    <tr>
174                        <th scope="row">
175                            <?= I18N::translate('Shared note') ?>
176                        </th>
177                        <td>
178                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SHARED_NOTE'])) ?>">
179                                <?= I18N::translate('Add a shared note') ?>
180                            </a>
181                        </td>
182                    </tr>
183                    <tr>
184                        <th scope="row">
185                            <?= I18N::translate('Restriction') ?>
186                        </th>
187                        <td>
188                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'RESN'])) ?>">
189                                <?= I18N::translate('Add a restriction') ?>
190                            </a>
191                        </td>
192                    </tr>
193                    <tr>
194                        <th scope="row">
195                            <?= I18N::translate('Media file') ?>
196                        </th>
197                        <td>
198                            <a href="#" data-href="<?= e(route('add-media-file', ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
199                                <?= I18N::translate('Add a media file') ?>
200                            </a>
201                        </td>
202                    </tr>
203                <?php endif ?>
204            </table>
205        </div>
206
207        <div class="tab-pane fade" role="tabpanel" id="individuals">
208            <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?>
209        </div>
210
211        <div class="tab-pane fade" role="tabpanel" id="families">
212            <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?>
213        </div>
214
215        <div class="tab-pane fade" role="tabpanel" id="sources">
216            <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?>
217        </div>
218
219        <div class="tab-pane fade" role="tabpanel" id="notes">
220            <?= view('lists/notes-table', ['notes' => $notes, 'tree' => $tree]) ?>
221        </div>
222    </div>
223</div>
224
225<?= view('modals/ajax') ?>
226