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