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\Tree; 10use Illuminate\Support\Collection; 11use League\Flysystem\FilesystemOperator; 12 13/** 14 * @var int $count 15 * @var FilesystemOperator $data_filesystem 16 * @var string $filter 17 * @var string $folder 18 * @var array<string> $folders 19 * @var string $format 20 * @var array<string> $formats 21 * @var int $max 22 * @var Collection<Media> $media_objects 23 * @var ModuleListInterface $module 24 * @var int $page 25 * @var int $pages 26 * @var string $subdirs 27 * @var string $title 28 * @var Tree $tree 29 */ 30 31?> 32 33<h2 class="wt-page-title"> 34 <?= $title ?> 35</h2> 36 37<form method="post" class="wt-page-options wt-page-options-media-list d-print-none"> 38 <?= csrf_field() ?> 39 40 <div class="row form-group"> 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 form-group"> 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 form-group"> 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</form> 91 92<div class="wt-page-content"> 93 <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p> 94 <?php if ($media_objects->isNotEmpty()) : ?> 95 96 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 97 98 <div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 g-4"> 99 <?php foreach ($media_objects as $n => $media_object) : ?> 100 <div class="col"> 101 <div class="card h-100"> 102 <div class="card-header"> 103 <h4 class="card-title"> 104 <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a> 105 </h4> 106 </div> 107 <div class="card-body"> 108 <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 109 <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?> 110 <?php endforeach ?> 111 112 <?php $media_file = $media_object->mediaFiles()->first() ?> 113 <?php if ($media_file instanceof MediaFile): ?> 114 <p class="card-text"> 115 <?php 116 // Show file details 117 $mediatype = $media_file->type(); 118 if ($media_file->type() !== '') { 119 $element = Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE'); 120 echo $element->labelValue($media_file->type(), $media_object->tree()); 121 } 122 123 foreach ($media_object->facts(['SOUR']) as $fact) { 124 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 125 } 126 127 foreach ($media_object->facts(['NOTE']) as $fact) { 128 echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]); 129 } 130 131 if ($media_file->isExternal()) { 132 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 133 } elseif ($media_file->fileExists($data_filesystem)) { 134 echo Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->mimeType(), $media_object->tree()); 135 if (Auth::isEditor($tree)) { 136 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 137 } 138 if (Auth::isEditor($tree)) { 139 foreach ($media_file->attributes($data_filesystem) as $label => $value) { 140 $label = '<span class="label">' . $label . '</span>'; 141 $value = '<span class="value">' . $value . '</span>'; 142 143 echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>'; 144 } 145 } 146 } else { 147 echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>'; 148 } 149 ?> 150 </p> 151 <?php endif ?> 152 </div> 153 <div class="card-footer"> 154 <?php foreach ($media_object->linkedIndividuals('OBJE') as $record) : ?> 155 <?= view('icons/individual') ?> 156 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 157 <br> 158 <?php endforeach ?> 159 160 <?php foreach ($media_object->linkedFamilies('OBJE') as $record) : ?> 161 <?= view('icons/family') ?> 162 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 163 <br> 164 <?php endforeach ?> 165 166 <?php foreach ($media_object->linkedSources('OBJE') as $record) : ?> 167 <?= view('icons/source') ?> 168 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 169 <br> 170 <?php endforeach ?> 171 </div> 172 </div> 173 </div> 174 <?php endforeach ?> 175 </div> 176 177 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 178 <?php endif ?> 179</div> 180