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