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