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 bool $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]) ?> 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 <input type="hidden" name="page" value="1"> 85 <button type="submit" class="btn btn-primary"> 86 <?= /* I18N: A button label. */ I18N::translate('search') ?> 87 </button> 88 <a class="btn btn-secondary" href="<?= e($module->listUrl($tree)) ?>"> 89 <?= /* I18N: A button label. */ I18N::translate('reset') ?> 90 </a> 91 </div> 92 </div> 93 94 <?= csrf_field() ?> 95</form> 96 97<div class="wt-page-content"> 98 <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p> 99 <?php if ($media_objects->isNotEmpty()) : ?> 100 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 101 102 <div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 g-4"> 103 <?php foreach ($media_objects as $n => $media_object) : ?> 104 <div class="col"> 105 <div class="card h-100"> 106 <div class="card-header"> 107 <h4 class="card-title"> 108 <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a> 109 </h4> 110 </div> 111 <div class="card-body"> 112 <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 113 <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?> 114 <?php endforeach ?> 115 116 <?php $media_file = $media_object->mediaFiles()->first() ?> 117 <?php if ($media_file instanceof MediaFile) : ?> 118 <p class="card-text"> 119 <?php 120 // Show file details 121 $mediatype = $media_file->type(); 122 if ($media_file->type() !== '') { 123 $element = Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE'); 124 echo $element->labelValue($media_file->type(), $media_object->tree()); 125 } 126 127 foreach ($media_object->facts(['SOUR']) as $fact) { 128 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 129 } 130 131 foreach ($media_object->facts(['NOTE']) as $fact) { 132 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 133 } 134 135 if ($media_file->isExternal()) { 136 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 137 } elseif ($media_file->fileExists($data_filesystem)) { 138 if (Auth::isEditor($tree)) { 139 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 140 141 foreach ($media_file->attributes($data_filesystem) as $label => $value) { 142 $label = '<span class="label">' . $label . '</span>'; 143 $value = '<span class="value">' . $value . '</span>'; 144 145 echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>'; 146 } 147 } 148 } else { 149 echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>'; 150 } 151 ?> 152 </p> 153 <?php endif ?> 154 </div> 155 <div class="card-footer"> 156 <?php foreach ($linked_record_service->linkedIndividuals($media_object) as $record) : ?> 157 <?= view('icons/individual') ?> 158 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 159 <br> 160 <?php endforeach ?> 161 162 <?php foreach ($linked_record_service->linkedFamilies($media_object) as $record) : ?> 163 <?= view('icons/family') ?> 164 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 165 <br> 166 <?php endforeach ?> 167 168 <?php foreach ($linked_record_service->linkedSources($media_object) as $record) : ?> 169 <?= view('icons/source') ?> 170 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 171 <br> 172 <?php endforeach ?> 173 174 <?php foreach ($linked_record_service->linkedLocations($media_object) as $record) : ?> 175 <?= view('icons/location') ?> 176 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 177 <br> 178 <?php endforeach ?> 179 </div> 180 </div> 181 </div> 182 <?php endforeach ?> 183 </div> 184 185 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 186 <?php endif ?> 187</div> 188