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