1<?php 2 3use Fisharebest\Webtrees\Auth; 4use Fisharebest\Webtrees\Functions\FunctionsPrint; 5use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; 6use Fisharebest\Webtrees\GedcomTag; 7use Fisharebest\Webtrees\I18N; 8use Fisharebest\Webtrees\Media; 9use Fisharebest\Webtrees\MediaFile; 10use Fisharebest\Webtrees\Module\ModuleListInterface; 11use Fisharebest\Webtrees\Registry; 12use Fisharebest\Webtrees\Tree; 13use Illuminate\Support\Collection; 14use League\Flysystem\FilesystemInterface; 15 16/** 17 * @var int $count 18 * @var FilesystemInterface $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 int $max 25 * @var Collection<Media> $media_objects 26 * @var ModuleListInterface $module 27 * @var int $page 28 * @var int $pages 29 * @var string $subdirs 30 * @var string $title 31 * @var Tree $tree 32 */ 33 34?> 35 36<h2 class="wt-page-title"> 37 <?= $title ?> 38</h2> 39 40<form method="post" class="wt-page-options wt-page-options-media-list d-print-none"> 41 <?= csrf_field() ?> 42 43 <div class="row form-group"> 44 <label class="col-sm-3 col-form-label wt-page-options-label" for="folder"> 45 <?= I18N::translate('Folder') ?> 46 </label> 47 <div class="col-sm-3 wt-page-options-value"> 48 <?= view('components/select', ['name' => 'folder', 'selected' => $folder, 'options' => $folders]) ?> 49 <?= view('components/checkbox-inline', ['label' => /* I18N: Label for check-box */ I18N::translate('Include subfolders'), 'name' => 'subdirs', 'checked' => $subdirs === '1']) ?> 50 </div> 51 52 <label class="col-sm-3 col-form-label wt-page-options-label" for="max"> 53 <?= I18N::translate('Media objects per page') ?> 54 </label> 55 <div class="col-sm-3 wt-page-options-value"> 56 <?= view('components/select-number', ['name' => 'max', 'selected' => $max, 'options' => [10, 20, 30, 40, 50, 75, 100, 150, 200]]) ?> 57 </div> 58 </div> 59 60 <div class="row form-group"> 61 <label class="col-sm-3 col-form-label wt-page-options-label" for="format"> 62 <?= I18N::translate('Type') ?> 63 </label> 64 65 <div class="col-sm-3 wt-page-options-value"> 66 <?= view('components/select', ['name' => 'format', 'id' => 'format', 'selected' => $format, 'options' => ['' => ''] + $formats]) ?> 67 </div> 68 69 <div class="col-sm-3 col-form-label wt-page-options-label"></div> 70 71 <div class="col-sm-3 wt-page-options-value"></div> 72 </div> 73 74 <div class="row form-group"> 75 <label class="col-sm-3 col-form-label wt-page-options-label" for="filter"> 76 <?= I18N::translate('Search filters') ?> 77 </label> 78 <div class="col-sm-3 wt-page-options-value"> 79 <input type="text" class="form-control" name="filter" id="filter" value="<?= e($filter) ?>"> 80 </div> 81 82 <div class="col-sm-3 col-form-label wt-page-options-label"></div> 83 84 <div class="col-sm-3 wt-page-options-value"> 85 <button type="submit" name="go" value="1" 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</form> 94 95<div class="wt-page-content"> 96 <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p> 97 <?php if ($media_objects->isNotEmpty()) : ?> 98 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="card-deck row mb-4 mt-4"> 102 <?php foreach ($media_objects as $n => $media_object) : ?> 103 <div class="col-12 col-sm-6 col-lg-4 d-flex"> 104 <div class="card mb-4"> 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 echo FunctionsPrintFacts::printFactSources($tree, $media_object->gedcom(), 1); 126 echo FunctionsPrint::printFactNotes($tree, $media_object->gedcom(), 1); 127 if ($media_file->isExternal()) { 128 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 129 } elseif ($media_file->fileExists($data_filesystem)) { 130 echo Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->mimeType(), $media_object->tree()); 131 if (Auth::isEditor($tree)) { 132 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 133 } 134 if (Auth::isEditor($tree)) { 135 foreach ($media_file->attributes($data_filesystem) as $tag => $value) { 136 echo GedcomTag::getLabelValue($tag, $value); 137 } 138 } 139 } else { 140 echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>'; 141 } 142 ?> 143 </p> 144 <?php endif ?> 145 </div> 146 <div class="card-footer"> 147 <?php foreach ($media_object->linkedIndividuals('OBJE') as $record) : ?> 148 <?= view('icons/individual') ?> 149 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 150 <br> 151 <?php endforeach ?> 152 153 <?php foreach ($media_object->linkedFamilies('OBJE') as $record) : ?> 154 <?= view('icons/family') ?> 155 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 156 <br> 157 <?php endforeach ?> 158 159 <?php foreach ($media_object->linkedSources('OBJE') as $record) : ?> 160 <?= view('icons/source') ?> 161 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 162 <br> 163 <?php endforeach ?> 164 </div> 165 </div> 166 </div> 167 <?php endforeach ?> 168 </div> 169 170 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 171 <?php endif ?> 172</div> 173