1<?php 2 3use Fisharebest\Webtrees\Auth; 4use Fisharebest\Webtrees\I18N; 5use Fisharebest\Webtrees\Media; 6use Fisharebest\Webtrees\MediaFile; 7use Fisharebest\Webtrees\Module\ModuleListInterface; 8use Fisharebest\Webtrees\Registry; 9use Fisharebest\Webtrees\Services\LinkedRecordService; 10use Fisharebest\Webtrees\Tree; 11use Illuminate\Support\Collection; 12use League\Flysystem\FilesystemOperator; 13 14/** 15 * @var int $count 16 * @var FilesystemOperator $data_filesystem 17 * @var string $filter 18 * @var string $folder 19 * @var array<string> $folders 20 * @var string $format 21 * @var array<string> $formats 22 * @var LinkedRecordService $linked_record_service 23 * @var int $max 24 * @var Collection<int,Media> $media_objects 25 * @var ModuleListInterface $module 26 * @var int $page 27 * @var int $pages 28 * @var string $subdirs 29 * @var string $title 30 * @var Tree $tree 31 */ 32 33?> 34 35<h2 class="wt-page-title"> 36 <?= $title ?> 37</h2> 38 39<form method="post" class="wt-page-options wt-page-options-media-list d-print-none"> 40 <div class="row"> 41 <label class="col-sm-3 col-form-label wt-page-options-label" for="folder"> 42 <?= I18N::translate('Folder') ?> 43 </label> 44 <div class="col-sm-3 wt-page-options-value"> 45 <?= view('components/select', ['name' => 'folder', 'selected' => $folder, 'options' => $folders]) ?> 46 <?= view('components/checkbox-inline', ['label' => /* I18N: Label for check-box */ I18N::translate('Include subfolders'), 'name' => 'subdirs', 'checked' => $subdirs === '1']) ?> 47 </div> 48 49 <label class="col-sm-3 col-form-label wt-page-options-label" for="max"> 50 <?= I18N::translate('Media objects per page') ?> 51 </label> 52 <div class="col-sm-3 wt-page-options-value"> 53 <?= view('components/select-number', ['name' => 'max', 'selected' => $max, 'options' => [10, 20, 30, 40, 50, 75, 100, 150, 200]]) ?> 54 </div> 55 </div> 56 57 <div class="row"> 58 <label class="col-sm-3 col-form-label wt-page-options-label" for="format"> 59 <?= I18N::translate('Type') ?> 60 </label> 61 62 <div class="col-sm-3 wt-page-options-value"> 63 <?= view('components/select', ['name' => 'format', 'id' => 'format', 'selected' => $format, 'options' => ['' => ''] + $formats]) ?> 64 </div> 65 66 <div class="col-sm-3 col-form-label wt-page-options-label"></div> 67 68 <div class="col-sm-3 wt-page-options-value"></div> 69 </div> 70 71 <div class="row"> 72 <label class="col-sm-3 col-form-label wt-page-options-label" for="filter"> 73 <?= I18N::translate('Search filters') ?> 74 </label> 75 <div class="col-sm-3 wt-page-options-value"> 76 <input type="text" class="form-control" name="filter" id="filter" value="<?= e($filter) ?>"> 77 </div> 78 79 <div class="col-sm-3 col-form-label wt-page-options-label"></div> 80 81 <div class="col-sm-3 wt-page-options-value"> 82 <button type="submit" name="go" value="1" class="btn btn-primary"> 83 <?= /* I18N: A button label. */ I18N::translate('search') ?> 84 </button> 85 <a class="btn btn-secondary" href="<?= e($module->listUrl($tree)) ?>"> 86 <?= /* I18N: A button label. */ I18N::translate('reset') ?> 87 </a> 88 </div> 89 </div> 90 91 <?= csrf_field() ?> 92</form> 93 94<div class="wt-page-content"> 95 <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p> 96 <?php if ($media_objects->isNotEmpty()) : ?> 97 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 98 99 <div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 g-4"> 100 <?php foreach ($media_objects as $n => $media_object) : ?> 101 <div class="col"> 102 <div class="card h-100"> 103 <div class="card-header"> 104 <h4 class="card-title"> 105 <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a> 106 </h4> 107 </div> 108 <div class="card-body"> 109 <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 110 <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?> 111 <?php endforeach ?> 112 113 <?php $media_file = $media_object->mediaFiles()->first() ?> 114 <?php if ($media_file instanceof MediaFile) : ?> 115 <p class="card-text"> 116 <?php 117 // Show file details 118 $mediatype = $media_file->type(); 119 if ($media_file->type() !== '') { 120 $element = Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE'); 121 echo $element->labelValue($media_file->type(), $media_object->tree()); 122 } 123 124 foreach ($media_object->facts(['SOUR']) as $fact) { 125 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 126 } 127 128 foreach ($media_object->facts(['NOTE']) as $fact) { 129 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 130 } 131 132 if ($media_file->isExternal()) { 133 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 134 } elseif ($media_file->fileExists($data_filesystem)) { 135 if (Auth::isEditor($tree)) { 136 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 137 138 foreach ($media_file->attributes($data_filesystem) as $label => $value) { 139 $label = '<span class="label">' . $label . '</span>'; 140 $value = '<span class="value">' . $value . '</span>'; 141 142 echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>'; 143 } 144 } 145 } else { 146 echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>'; 147 } 148 ?> 149 </p> 150 <?php endif ?> 151 </div> 152 <div class="card-footer"> 153 <?php foreach ($linked_record_service->linkedIndividuals($media_object) as $record) : ?> 154 <?= view('icons/individual') ?> 155 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 156 <br> 157 <?php endforeach ?> 158 159 <?php foreach ($linked_record_service->linkedFamilies($media_object) as $record) : ?> 160 <?= view('icons/family') ?> 161 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 162 <br> 163 <?php endforeach ?> 164 165 <?php foreach ($linked_record_service->linkedSources($media_object) as $record) : ?> 166 <?= view('icons/source') ?> 167 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 168 <br> 169 <?php endforeach ?> 170 171 <?php foreach ($linked_record_service->linkedLocations($media_object) as $record) : ?> 172 <?= view('icons/location') ?> 173 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 174 <br> 175 <?php endforeach ?> 176 </div> 177 </div> 178 </div> 179 <?php endforeach ?> 180 </div> 181 182 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 183 <?php endif ?> 184</div> 185