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