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