1<?php 2 3use Fisharebest\Webtrees\Auth; 4use Fisharebest\Webtrees\Functions\FunctionsPrint; 5use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; 6use Fisharebest\Webtrees\I18N; 7use Fisharebest\Webtrees\Media; 8use Fisharebest\Webtrees\MediaFile; 9use Fisharebest\Webtrees\Module\ModuleListInterface; 10use Fisharebest\Webtrees\Registry; 11use Fisharebest\Webtrees\Tree; 12use Illuminate\Support\Collection; 13use League\Flysystem\FilesystemOperator; 14 15/** 16 * @var int $count 17 * @var FilesystemOperator $data_filesystem 18 * @var string $filter 19 * @var string $folder 20 * @var array<string> $folders 21 * @var string $format 22 * @var array<string> $formats 23 * @var int $max 24 * @var Collection<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 <?= csrf_field() ?> 41 42 <div class="row form-group"> 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 form-group"> 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 form-group"> 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</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 98 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 99 100 <div class="card-deck row mb-4 mt-4"> 101 <?php foreach ($media_objects as $n => $media_object) : ?> 102 <div class="col-12 col-sm-6 col-lg-4 d-flex"> 103 <div class="card mb-4"> 104 <div class="card-header"> 105 <h4 class="card-title"> 106 <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a> 107 </h4> 108 </div> 109 <div class="card-body"> 110 <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 111 <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?> 112 <?php endforeach ?> 113 114 <?php $media_file = $media_object->mediaFiles()->first() ?> 115 <?php if ($media_file instanceof MediaFile): ?> 116 <p class="card-text"> 117 <?php 118 // Show file details 119 $mediatype = $media_file->type(); 120 if ($media_file->type() !== '') { 121 $element = Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE'); 122 echo $element->labelValue($media_file->type(), $media_object->tree()); 123 } 124 echo FunctionsPrintFacts::printFactSources($tree, $media_object->gedcom(), 1); 125 echo FunctionsPrint::printFactNotes($tree, $media_object->gedcom(), 1); 126 if ($media_file->isExternal()) { 127 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 128 } elseif ($media_file->fileExists($data_filesystem)) { 129 echo Registry::elementFactory()->make('OBJE:FILE:FORM')->labelValue($media_file->mimeType(), $media_object->tree()); 130 if (Auth::isEditor($tree)) { 131 echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); 132 } 133 if (Auth::isEditor($tree)) { 134 foreach ($media_file->attributes($data_filesystem) as $label => $value) { 135 $label = '<span class="label">' . $label . '</span>'; 136 $value = '<span class="value">' . $value . '</span>'; 137 138 echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>'; 139 } 140 } 141 } else { 142 echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>'; 143 } 144 ?> 145 </p> 146 <?php endif ?> 147 </div> 148 <div class="card-footer"> 149 <?php foreach ($media_object->linkedIndividuals('OBJE') as $record) : ?> 150 <?= view('icons/individual') ?> 151 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 152 <br> 153 <?php endforeach ?> 154 155 <?php foreach ($media_object->linkedFamilies('OBJE') as $record) : ?> 156 <?= view('icons/family') ?> 157 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 158 <br> 159 <?php endforeach ?> 160 161 <?php foreach ($media_object->linkedSources('OBJE') as $record) : ?> 162 <?= view('icons/source') ?> 163 <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a> 164 <br> 165 <?php endforeach ?> 166 </div> 167 </div> 168 </div> 169 <?php endforeach ?> 170 </div> 171 172 <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?> 173 <?php endif ?> 174</div> 175