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