xref: /webtrees/resources/views/media-page.phtml (revision 64d12f7b9a9462c8fcd06eb53b52f5b2d2a444f3)
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', $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.', $media_file->filename()) ?>
122                                        </p>
123                                    <?php endif ?>
124                                    <?= GedcomTag::getLabelValue('FILE', $media_file->filename()) ?>
125                                <?php endif ?>
126
127                                <?= GedcomTag::getLabelValue('TITL', e($media_file->title())) ?>
128                                <?= GedcomTag::getLabelValue('TYPE', e($media_file->type())) ?>
129                                <?= GedcomTag::getLabelValue('FORM', e($media_file->format())) ?>
130                            </div>
131
132                            <div>
133                                <?php if (!$media_file->isExternal()) : ?>
134                                    <?= $media_file->displayImage(200, 150, 'contain', []) ?>
135                                    <?php if ($media->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($media->tree()) && $media_file->fileExists($data_filesystem)) : ?>
136                                        <br>
137                                        <a href="<?= e($media_file->downloadUrl('attachment')) ?>">
138                                            <?= I18N::translate('Download file') ?>
139                                        </a>
140                                    <?php endif ?>
141                                <?php endif ?>
142                            </div>
143                        </td>
144                    </tr>
145                <?php endforeach ?>
146                <?php foreach ($facts as $fact) : ?>
147                    <?php if ($fact->getTag() !== 'FILE') : ?>
148                        <?php FunctionsPrintFacts::printFact($fact, $media) ?>
149                    <?php endif ?>
150                <?php endforeach ?>
151                <?php if ($media->canEdit()) : ?>
152                    <?= view('edit/paste-fact-row', ['record' => $media, 'facts' => $clipboard_facts]) ?>
153
154                    <?php FunctionsPrint::printAddNewFact($media, $facts, 'OBJE') ?>
155                    <tr>
156                        <th>
157                            <?= I18N::translate('Source') ?>
158                        </th>
159                        <td>
160                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SOUR'])) ?>">
161                                <?= I18N::translate('Add a source citation') ?>
162                            </a>
163                        </td>
164                    </tr>
165                    <tr>
166                        <th scope="row">
167                            <?= I18N::translate('Shared note') ?>
168                        </th>
169                        <td>
170                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SHARED_NOTE'])) ?>">
171                                <?= I18N::translate('Add a shared note') ?>
172                            </a>
173                        </td>
174                    </tr>
175                    <tr>
176                        <th scope="row">
177                            <?= I18N::translate('Restriction') ?>
178                        </th>
179                        <td>
180                            <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'RESN'])) ?>">
181                                <?= I18N::translate('Add a restriction') ?>
182                            </a>
183                        </td>
184                    </tr>
185                    <tr>
186                        <th scope="row">
187                            <?= I18N::translate('Media file') ?>
188                        </th>
189                        <td>
190                            <a href="#" data-href="<?= e(route('add-media-file', ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
191                                <?= I18N::translate('Add a media file') ?>
192                            </a>
193                        </td>
194                    </tr>
195                <?php endif ?>
196            </table>
197        </div>
198
199        <div class="tab-pane fade" role="tabpanel" id="individuals">
200            <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?>
201        </div>
202
203        <div class="tab-pane fade" role="tabpanel" id="families">
204            <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?>
205        </div>
206
207        <div class="tab-pane fade" role="tabpanel" id="sources">
208            <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?>
209        </div>
210
211        <div class="tab-pane fade" role="tabpanel" id="notes">
212            <?= view('lists/notes-table', ['notes' => $notes, 'tree' => $tree]) ?>
213        </div>
214    </div>
215</div>
216
217<?= view('modals/ajax') ?>
218