1<?php 2 3use Fisharebest\Webtrees\Auth; 4use Fisharebest\Webtrees\Functions\FunctionsPrint; 5use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; 6use Fisharebest\Webtrees\GedcomTag; 7use Fisharebest\Webtrees\Http\RequestHandlers\AddMediaFileModal; 8use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 9use Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact; 10use Fisharebest\Webtrees\Http\RequestHandlers\EditMediaFileModal; 11use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord; 12use Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord; 13use Fisharebest\Webtrees\I18N; 14use Fisharebest\Webtrees\Media; 15use Fisharebest\Webtrees\Registry; 16use Fisharebest\Webtrees\Tree; 17use Illuminate\Support\Collection; 18use League\Flysystem\FilesystemOperator; 19 20/** 21 * @var Collection $clipboard_facts 22 * @var FilesystemOperator $data_filesystem 23 * @var Collection $facts 24 * @var Collection $families 25 * @var Collection $individuals 26 * @var Media $media 27 * @var Collection $notes 28 * @var Collection $sources 29 * @var Tree $tree 30 */ 31?> 32 33<?php if ($media->isPendingDeletion()) : ?> 34 <?php if (Auth::isModerator($media->tree())) : ?> 35 <?= 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" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 36 <?php elseif (Auth::isEditor($media->tree())) : ?> 37 <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This media object has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 38 <?php endif ?> 39<?php elseif ($media->isPendingAddition()) : ?> 40 <?php if (Auth::isModerator($media->tree())) : ?> 41 <?= 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" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 42 <?php elseif (Auth::isEditor($media->tree())) : ?> 43 <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This media object has been edited. The changes need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 44 <?php endif ?> 45<?php endif ?> 46 47<div class="d-flex mb-4"> 48 <h2 class="wt-page-title mx-auto"> 49 <?= $media->fullName() ?> 50 </h2> 51 <?php if ($media->canEdit()) : ?> 52 <?= view('media-page-menu', ['record' => $media]) ?> 53 <?php endif ?> 54</div> 55 56<div class="wt-page-content"> 57 <ul class="nav nav-tabs" role="tablist"> 58 <li class="nav-item" role="presentation"> 59 <a class="nav-link active" data-toggle="tab" role="tab" href="#details"> 60 <?= I18N::translate('Details') ?> 61 </a> 62 </li> 63 64 <li class="nav-item" role="presentation"> 65 <a class="nav-link<?= $individuals->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#individuals"> 66 <?= I18N::translate('Individuals') ?> 67 <?= view('components/badge', ['count' => $individuals->count()]) ?> 68 </a> 69 </li> 70 71 <li class="nav-item" role="presentation"> 72 <a class="nav-link<?= $families->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#families"> 73 <?= I18N::translate('Families') ?> 74 <?= view('components/badge', ['count' => $families->count()]) ?> 75 </a> 76 </li> 77 78 <li class="nav-item" role="presentation"> 79 <a class="nav-link<?= $sources->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#sources"> 80 <?= I18N::translate('Sources') ?> 81 <?= view('components/badge', ['count' => $sources->count()]) ?> 82 </a> 83 </li> 84 85 <li class="nav-item" role="presentation"> 86 <a class="nav-link<?= $notes->isEmpty() ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" href="#notes"> 87 <?= I18N::translate('Notes') ?> 88 <?= view('components/badge', ['count' => $notes->count()]) ?> 89 </a> 90 </li> 91 </ul> 92 93 <div class="tab-content mt-4"> 94 <div class="tab-pane active fade show" role="tabpanel" id="details"> 95 <table class="table wt-facts-table"> 96 <?php foreach ($media->mediaFiles() as $media_file) : ?> 97 <tr class="<?= $media_file->isPendingAddition() ? 'wt-new' : '' ?><?= $media_file->isPendingDeletion() ? 'wt-old' : '' ?>"> 98 <th scope="row"> 99 <?= I18N::translate('Media file') ?> 100 <?php if ($media->canEdit()) : ?> 101 <div class="editfacts nowrap"> 102 <a class="btn btn-link" href="#" data-toggle="modal" data-backdrop="static" data-target="#wt-ajax-modal" data-href="<?= route(EditMediaFileModal::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact_id' => $media_file->factId()]) ?>" title="<?= I18N::translate('Edit') ?>"> 103 <?= view('icons/edit') ?> 104 <span class="sr-only"> 105 <?= I18N::translate('Edit') ?> 106 </span> 107 </a> 108 109 <?php if (count($media->mediaFiles()) > 1) : ?> 110 <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' => $media->tree()->name(), 'xref' => $media->xref(), 'fact_id' => $media_file->factId()])) ?>" title="<?= I18N::translate('Delete') ?>"> 111 <?= view('icons/delete') ?> 112 <span class="sr-only"> 113 <?= I18N::translate('Delete') ?> 114 </span> 115 </a> 116 117 <?php endif ?> 118 </div> 119 <?php endif ?> 120 </th> 121 <td class="d-flex justify-content-between"> 122 <div> 123 <?php if ($media_file->isExternal()) : ?> 124 <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media->tree()) ?> 125 <?php elseif (Auth::isEditor($media->tree())) :?> 126 <?php if (!$media_file->fileExists($data_filesystem)) : ?> 127 <p class="alert alert-danger"> 128 <?= I18N::translate('The file “%s” does not exist.', e($media_file->filename())) ?> 129 </p> 130 <?php endif ?> 131 <?= Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media->tree()) ?> 132 <?php endif ?> 133 134 <?= Registry::elementFactory()->make('OBJE:FILE:TITL')->labelValue($media_file->title(), $media->tree()) ?> 135 <?= Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE')->labelValue($media_file->type(), $media->tree()) ?> 136 <?= Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->format(), $media->tree()) ?> 137 </div> 138 139 <div> 140 <?php if (!$media_file->isExternal()) : ?> 141 <?php if (explode('/', $media_file->mimeType())[0] === 'audio') : ?> 142 <audio controls> 143 <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>"> 144 </audio> 145 <?php elseif (explode('/', $media_file->mimeType())[0] === 'video') : ?> 146 <video controls width="300"> 147 <source src="<?= e($media_file->downloadUrl('inline')) ?>" type="<?= $media_file->mimeType() ?>"> 148 </video> 149 <?php else : ?> 150 <?= $media_file->displayImage(200, 150, 'contain', []) ?> 151 <?php endif ?> 152 <?php if ($media->tree()->getPreference('SHOW_MEDIA_DOWNLOAD') >= Auth::accessLevel($media->tree()) && $media_file->fileExists($data_filesystem)) : ?> 153 <br> 154 <a href="<?= e($media_file->downloadUrl('attachment')) ?>"> 155 <?= I18N::translate('Download file') ?> 156 </a> 157 <?php endif ?> 158 <?php endif ?> 159 </div> 160 </td> 161 </tr> 162 <?php endforeach ?> 163 <?php foreach ($facts as $fact) : ?> 164 <?php FunctionsPrintFacts::printFact($fact, $media) ?> 165 <?php endforeach ?> 166 <?php if ($media->canEdit()) : ?> 167 <?= view('edit/paste-fact-row', ['record' => $media, 'facts' => $clipboard_facts]) ?> 168 169 <?php FunctionsPrint::printAddNewFact($media, $facts, Media::RECORD_TYPE) ?> 170 <tr> 171 <th> 172 <?= I18N::translate('Source') ?> 173 </th> 174 <td> 175 <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'SOUR'])) ?>"> 176 <?= I18N::translate('Add a source citation') ?> 177 </a> 178 </td> 179 </tr> 180 <tr> 181 <th scope="row"> 182 <?= I18N::translate('Restriction') ?> 183 </th> 184 <td> 185 <a href="<?= e(route(AddNewFact::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref(), 'fact' => 'RESN'])) ?>"> 186 <?= I18N::translate('Add a restriction') ?> 187 </a> 188 </td> 189 </tr> 190 <tr> 191 <th scope="row"> 192 <?= I18N::translate('Media file') ?> 193 </th> 194 <td> 195 <a href="#" data-href="<?= e(route(AddMediaFileModal::class, ['tree' => $media->tree()->name(), 'xref' => $media->xref()])) ?>" data-target="#wt-ajax-modal" data-toggle="modal" data-backdrop="static"> 196 <?= I18N::translate('Add a media file') ?> 197 </a> 198 </td> 199 </tr> 200 <?php endif ?> 201 </table> 202 </div> 203 204 <div class="tab-pane fade" role="tabpanel" id="individuals"> 205 <?= view('lists/individuals-table', ['individuals' => $individuals, 'sosa' => false, 'tree' => $tree]) ?> 206 </div> 207 208 <div class="tab-pane fade" role="tabpanel" id="families"> 209 <?= view('lists/families-table', ['families' => $families, 'tree' => $tree]) ?> 210 </div> 211 212 <div class="tab-pane fade" role="tabpanel" id="sources"> 213 <?= view('lists/sources-table', ['sources' => $sources, 'tree' => $tree]) ?> 214 </div> 215 216 <div class="tab-pane fade" role="tabpanel" id="notes"> 217 <?= view('lists/notes-table', ['notes' => $notes, 'tree' => $tree]) ?> 218 </div> 219 </div> 220</div> 221 222<?= view('modals/ajax') ?> 223