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