xref: /webtrees/resources/views/media-page.phtml (revision 8121b9bec19818120092699199161a1357bb8f3f)
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                    <?php FunctionsPrint::printAddNewFact($media, $facts, 'OBJE') ?>
118                    <tr>
119                        <th>
120                            <?= I18N::translate('Source') ?>
121                        </th>
122                        <td>
123                            <a href="<?= e(route('add-fact', ['ged' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SOUR'])) ?>">
124                                <?= I18N::translate('Add a source citation') ?>
125                            </a>
126                        </td>
127                    </tr>
128                    <tr>
129                        <th scope="row">
130                            <?= I18N::translate('Shared note') ?>
131                        </th>
132                        <td>
133                            <a href="<?= e(route('add-fact', ['ged' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SHARED_NOTE'])) ?>">
134                                <?= I18N::translate('Add a shared note') ?>
135                            </a>
136                        </td>
137                    </tr>
138                    <tr>
139                        <th scope="row">
140                            <?= I18N::translate('Restriction') ?>
141                        </th>
142                        <td>
143                            <a href="<?= e(route('add-fact', ['ged' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'RESN'])) ?>">
144                                <?= I18N::translate('Add a restriction') ?>
145                            </a>
146                        </td>
147                    </tr>
148                    <tr>
149                        <th scope="row">
150                            <?= I18N::translate('Media file') ?>
151                        </th>
152                        <td>
153                            <a href="#" data-href="<?= e(route('add-media-file', ['ged' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal">
154                                <?= I18N::translate('Add a media file') ?>
155                            </a>
156                        </td>
157                    </tr>
158                <?php endif ?>
159            </table>
160        </div>
161
162        <div class="tab-pane fade" role="tabpanel" id="individuals">
163            <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?>
164        </div>
165
166        <div class="tab-pane fade" role="tabpanel" id="families">
167            <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?>
168        </div>
169
170        <div class="tab-pane fade" role="tabpanel" id="sources">
171            <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?>
172        </div>
173
174        <div class="tab-pane fade" role="tabpanel" id="notes">
175            <?= view('lists/notes-table', ['notes' => $notes, 'tree' => $tree]) ?>
176        </div>
177    </div>
178</div>
179
180<?= view('modals/ajax') ?>
181