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