xref: /webtrees/resources/views/media-page-details.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
10f5fd22fSGreg Roach<?php
20f5fd22fSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
50f5fd22fSGreg Roachuse Fisharebest\Webtrees\Auth;
66ebf8b65SGreg Roachuse Fisharebest\Webtrees\Fact;
70f5fd22fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact;
80f5fd22fSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditMediaFileModal;
90f5fd22fSGreg Roachuse Fisharebest\Webtrees\I18N;
100f5fd22fSGreg Roachuse Fisharebest\Webtrees\Media;
110f5fd22fSGreg Roachuse Fisharebest\Webtrees\Registry;
120f5fd22fSGreg Roachuse Fisharebest\Webtrees\Tree;
130f5fd22fSGreg Roachuse Illuminate\Support\Collection;
140f5fd22fSGreg Roachuse League\Flysystem\FilesystemOperator;
150f5fd22fSGreg Roach
160f5fd22fSGreg Roach/**
170f5fd22fSGreg Roach * @var Collection           $clipboard_facts
180f5fd22fSGreg Roach * @var FilesystemOperator   $data_filesystem
190f5fd22fSGreg Roach * @var Media                $record
200f5fd22fSGreg Roach * @var Tree                 $tree
210f5fd22fSGreg Roach */
220f5fd22fSGreg Roach
230f5fd22fSGreg Roach?>
240f5fd22fSGreg Roach
250f5fd22fSGreg Roach<table class="table wt-facts-table">
260f5fd22fSGreg Roach    <?php foreach ($record->mediaFiles() as $media_file) : ?>
270f5fd22fSGreg Roach        <tr class="<?= $media_file->isPendingAddition() ? 'wt-new' : '' ?><?= $media_file->isPendingDeletion() ? 'wt-old' : '' ?>">
280f5fd22fSGreg Roach            <th scope="row">
290f5fd22fSGreg Roach                <?= I18N::translate('Media file') ?>
30acb90a38SGreg Roach                <?php if ($record->canEdit() && !$media_file->isPendingDeletion()) : ?>
31b315f3e1SGreg Roach                    <div class="pt-2 wt-fact-edit-links">
32d4786c66SGreg Roach                        <a class="btn btn-link" href="#" data-bs-toggle="modal" data-bs-backdrop="static" data-bs-target="#wt-ajax-modal" data-wt-href="<?= route(EditMediaFileModal::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref(), 'fact_id' => $media_file->factId()]) ?>" title="<?= I18N::translate('Edit') ?>">
330f5fd22fSGreg Roach                            <?= view('icons/edit') ?>
34315eb316SGreg Roach                            <span class="visually-hidden">
350f5fd22fSGreg Roach                            <?= I18N::translate('Edit') ?>
360f5fd22fSGreg Roach                        </span>
370f5fd22fSGreg Roach                        </a>
380f5fd22fSGreg Roach
390f5fd22fSGreg Roach                        <?php if (count($record->mediaFiles()) > 1) : ?>
40d4786c66SGreg Roach                            <a class="btn btn-link" href="#" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete this fact?') ?>" data-wt-post-url="<?= e(route(DeleteFact::class, ['tree' => $record->tree()->name(), 'xref' => $record->xref(), 'fact_id' => $media_file->factId()])) ?>" title="<?= I18N::translate('Delete') ?>">
410f5fd22fSGreg Roach                                <?= view('icons/delete') ?>
42315eb316SGreg Roach                                <span class="visually-hidden">
430f5fd22fSGreg Roach                            <?= I18N::translate('Delete') ?>
440f5fd22fSGreg Roach                        </span>
450f5fd22fSGreg Roach                            </a>
460f5fd22fSGreg Roach
470f5fd22fSGreg Roach                        <?php endif ?>
480f5fd22fSGreg Roach                    </div>
490f5fd22fSGreg Roach                <?php endif ?>
500f5fd22fSGreg Roach            </th>
510f5fd22fSGreg Roach            <td class="d-flex justify-content-between">
520f5fd22fSGreg Roach                <div>
530f5fd22fSGreg Roach                    <?php if ($media_file->isExternal()) : ?>
540f5fd22fSGreg Roach                        <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $record->tree()) ?>
550f5fd22fSGreg Roach                    <?php elseif (Auth::isEditor($record->tree())) :?>
560f5fd22fSGreg Roach                        <?php if (!$media_file->fileExists($data_filesystem)) : ?>
570f5fd22fSGreg Roach                            <p class="alert alert-danger">
580f5fd22fSGreg Roach                                <?= I18N::translate('The file “%s” does not exist.', e($media_file->filename())) ?>
590f5fd22fSGreg Roach                            </p>
600f5fd22fSGreg Roach                        <?php endif ?>
610f5fd22fSGreg Roach                        <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $record->tree()) ?>
620f5fd22fSGreg Roach                    <?php endif ?>
630f5fd22fSGreg Roach
640f5fd22fSGreg Roach                    <?= Registry::elementFactory()->make('OBJE:FILE:TITL')->labelValue($media_file->title(), $record->tree()) ?>
650f5fd22fSGreg Roach                    <?= Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE')->labelValue($media_file->type(), $record->tree()) ?>
660f5fd22fSGreg Roach                    <?= Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->format(), $record->tree()) ?>
670f5fd22fSGreg Roach                </div>
680f5fd22fSGreg Roach
690f5fd22fSGreg Roach                <div>
700f5fd22fSGreg Roach                    <?php if (!$media_file->isExternal()) : ?>
710f5fd22fSGreg Roach                        <?php if (explode('/', $media_file->mimeType())[0] === 'audio') : ?>
720f5fd22fSGreg Roach                        <audio controls>
730f5fd22fSGreg Roach                            <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>">
740f5fd22fSGreg Roach                        </audio>
750f5fd22fSGreg Roach                        <?php elseif (explode('/', $media_file->mimeType())[0] === 'video') : ?>
760f5fd22fSGreg Roach                            <video controls width="300">
770f5fd22fSGreg Roach                                <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>">
780f5fd22fSGreg Roach                            </video>
790f5fd22fSGreg Roach                        <?php else : ?>
800f5fd22fSGreg Roach                            <?= $media_file->displayImage(200, 150, 'contain', []) ?>
810f5fd22fSGreg Roach                        <?php endif ?>
820f5fd22fSGreg Roach                        <?php if ($record->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($record->tree()) && $media_file->fileExists($data_filesystem)) : ?>
830f5fd22fSGreg Roach                            <br>
840f5fd22fSGreg Roach                            <a href="<?= e($media_file->downloadUrl('attachment')) ?>">
850f5fd22fSGreg Roach                                <?= I18N::translate('Download file') ?>
860f5fd22fSGreg Roach                            </a>
870f5fd22fSGreg Roach                        <?php endif ?>
880f5fd22fSGreg Roach                    <?php endif ?>
890f5fd22fSGreg Roach                </div>
900f5fd22fSGreg Roach            </td>
910f5fd22fSGreg Roach        </tr>
920f5fd22fSGreg Roach    <?php endforeach ?>
930f5fd22fSGreg Roach
946ebf8b65SGreg Roach    <?php foreach ($record->facts()->filter(fn (Fact $fact): bool => $fact->tag() !== 'OBJE:FILE') as $fact) : ?>
95b315f3e1SGreg Roach        <?= view('fact', ['fact' => $fact, 'record' => $record]) ?>
960f5fd22fSGreg Roach    <?php endforeach ?>
970f5fd22fSGreg Roach</table>
98