10f5fd22fSGreg Roach<?php 20f5fd22fSGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg 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 Roach 150f5fd22fSGreg Roach/** 16*c5402244SGreg Roach * @var Collection<int,Fact> $clipboard_facts 170f5fd22fSGreg Roach * @var Media $record 180f5fd22fSGreg Roach * @var Tree $tree 190f5fd22fSGreg Roach */ 200f5fd22fSGreg Roach 210f5fd22fSGreg Roach?> 220f5fd22fSGreg Roach 230f5fd22fSGreg Roach<table class="table wt-facts-table"> 240f5fd22fSGreg Roach <?php foreach ($record->mediaFiles() as $media_file) : ?> 250f5fd22fSGreg Roach <tr class="<?= $media_file->isPendingAddition() ? 'wt-new' : '' ?><?= $media_file->isPendingDeletion() ? 'wt-old' : '' ?>"> 260f5fd22fSGreg Roach <th scope="row"> 270f5fd22fSGreg Roach <?= I18N::translate('Media file') ?> 28acb90a38SGreg Roach <?php if ($record->canEdit() && !$media_file->isPendingDeletion()) : ?> 29b315f3e1SGreg Roach <div class="pt-2 wt-fact-edit-links"> 30d4786c66SGreg 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') ?>"> 310f5fd22fSGreg Roach <?= view('icons/edit') ?> 32315eb316SGreg Roach <span class="visually-hidden"> 330f5fd22fSGreg Roach <?= I18N::translate('Edit') ?> 340f5fd22fSGreg Roach </span> 350f5fd22fSGreg Roach </a> 360f5fd22fSGreg Roach 370f5fd22fSGreg Roach <?php if (count($record->mediaFiles()) > 1) : ?> 38d4786c66SGreg 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') ?>"> 390f5fd22fSGreg Roach <?= view('icons/delete') ?> 40315eb316SGreg Roach <span class="visually-hidden"> 410f5fd22fSGreg Roach <?= I18N::translate('Delete') ?> 420f5fd22fSGreg Roach </span> 430f5fd22fSGreg Roach </a> 440f5fd22fSGreg Roach 450f5fd22fSGreg Roach <?php endif ?> 460f5fd22fSGreg Roach </div> 470f5fd22fSGreg Roach <?php endif ?> 480f5fd22fSGreg Roach </th> 490f5fd22fSGreg Roach <td class="d-flex justify-content-between"> 500f5fd22fSGreg Roach <div> 510f5fd22fSGreg Roach <?php if ($media_file->isExternal()) : ?> 520f5fd22fSGreg Roach <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $record->tree()) ?> 530f5fd22fSGreg Roach <?php elseif (Auth::isEditor($record->tree())) :?> 540127ebe6SGreg Roach <?php if (!$media_file->fileExists()) : ?> 550f5fd22fSGreg Roach <p class="alert alert-danger"> 560f5fd22fSGreg Roach <?= I18N::translate('The file “%s” does not exist.', e($media_file->filename())) ?> 570f5fd22fSGreg Roach </p> 580f5fd22fSGreg Roach <?php endif ?> 590f5fd22fSGreg Roach <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $record->tree()) ?> 600f5fd22fSGreg Roach <?php endif ?> 610f5fd22fSGreg Roach 620f5fd22fSGreg Roach <?= Registry::elementFactory()->make('OBJE:FILE:TITL')->labelValue($media_file->title(), $record->tree()) ?> 630f5fd22fSGreg Roach <?= Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE')->labelValue($media_file->type(), $record->tree()) ?> 640f5fd22fSGreg Roach <?= Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->format(), $record->tree()) ?> 650f5fd22fSGreg Roach </div> 660f5fd22fSGreg Roach 670f5fd22fSGreg Roach <div> 680f5fd22fSGreg Roach <?php if (!$media_file->isExternal()) : ?> 690f5fd22fSGreg Roach <?php if (explode('/', $media_file->mimeType())[0] === 'audio') : ?> 700f5fd22fSGreg Roach <audio controls> 710f5fd22fSGreg Roach <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>"> 720f5fd22fSGreg Roach </audio> 730f5fd22fSGreg Roach <?php elseif (explode('/', $media_file->mimeType())[0] === 'video') : ?> 740f5fd22fSGreg Roach <video controls width="300"> 750f5fd22fSGreg Roach <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>"> 760f5fd22fSGreg Roach </video> 770f5fd22fSGreg Roach <?php else : ?> 780f5fd22fSGreg Roach <?= $media_file->displayImage(200, 150, 'contain', []) ?> 790f5fd22fSGreg Roach <?php endif ?> 800127ebe6SGreg Roach <?php if ($record->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($record->tree()) && $media_file->fileExists()) : ?> 810f5fd22fSGreg Roach <br> 820f5fd22fSGreg Roach <a href="<?= e($media_file->downloadUrl('attachment')) ?>"> 830f5fd22fSGreg Roach <?= I18N::translate('Download file') ?> 840f5fd22fSGreg Roach </a> 850f5fd22fSGreg Roach <?php endif ?> 860f5fd22fSGreg Roach <?php endif ?> 870f5fd22fSGreg Roach </div> 880f5fd22fSGreg Roach </td> 890f5fd22fSGreg Roach </tr> 900f5fd22fSGreg Roach <?php endforeach ?> 910f5fd22fSGreg Roach 926ebf8b65SGreg Roach <?php foreach ($record->facts()->filter(fn (Fact $fact): bool => $fact->tag() !== 'OBJE:FILE') as $fact) : ?> 93b315f3e1SGreg Roach <?= view('fact', ['fact' => $fact, 'record' => $record]) ?> 940f5fd22fSGreg Roach <?php endforeach ?> 950f5fd22fSGreg Roach</table> 96