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