xref: /webtrees/resources/views/modules/media-list/page.phtml (revision b43e8d2bb2c20432b6d427f0f5d9a32679a9aa4f)
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\Module\ModuleListInterface;
10use Illuminate\Support\Collection;
11use League\Flysystem\FilesystemInterface;
12
13/**
14 * @var int                 $count
15 * @var FilesystemInterface $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 Collection<Media>   $media_objects
22 * @var ModuleListInterface $module
23 * @var int                 $page
24 * @var int                 $pages
25 * @var string              $subdirs
26 * @var string              $title
27 */
28
29?>
30
31<h2 class="wt-page-title">
32    <?= $title ?>
33</h2>
34
35<form method="post" class="wt-page-options wt-page-options-media-list d-print-none">
36    <?= csrf_field() ?>
37
38    <div class="row form-group">
39        <label class="col-sm-3 col-form-label wt-page-options-label" for="folder">
40            <?= I18N::translate('Folder') ?>
41        </label>
42        <div class="col-sm-3 wt-page-options-value">
43            <?= view('components/select', ['name' => 'folder', 'selected' => $folder, 'options' => $folders]) ?>
44            <?= view('components/checkbox-inline', ['label' => /* I18N: Label for check-box */ I18N::translate('Include subfolders'), 'name' => 'subdirs', 'checked' => $subdirs === '1']) ?>
45        </div>
46
47        <label class="col-sm-3 col-form-label wt-page-options-label" for="max">
48            <?= I18N::translate('Media objects per page') ?>
49        </label>
50        <div class="col-sm-3 wt-page-options-value">
51            <?= view('components/select-number', ['name' => 'max', 'selected' => $max, 'options' => [10, 20, 30, 40, 50, 75, 100, 150, 200]]) ?>
52        </div>
53    </div>
54
55    <div class="row form-group">
56        <label class="col-sm-3 col-form-label wt-page-options-label" for="format">
57            <?= I18N::translate('Type') ?>
58        </label>
59
60        <div class="col-sm-3 wt-page-options-value">
61            <?= view('components/select', ['name' => 'format', 'id' => 'format', 'selected' => $format, 'options' => ['' => ''] + $formats]) ?>
62        </div>
63
64        <div class="col-sm-3 col-form-label wt-page-options-label"></div>
65
66        <div class="col-sm-3 wt-page-options-value"></div>
67    </div>
68
69    <div class="row form-group">
70        <label class="col-sm-3 col-form-label wt-page-options-label" for="filter">
71            <?= I18N::translate('Search filters') ?>
72        </label>
73        <div class="col-sm-3 wt-page-options-value">
74            <input type="text" class="form-control" name="filter" id="filter" value="<?= e($filter) ?>">
75        </div>
76
77        <div class="col-sm-3 col-form-label wt-page-options-label"></div>
78
79        <div class="col-sm-3 wt-page-options-value">
80            <button type="submit" name="go" value="1" class="btn btn-primary">
81                <?= /* I18N: A button label. */ I18N::translate('search') ?>
82            </button>
83            <a class="btn btn-secondary" href="<?= e($module->listUrl($tree)) ?>">
84                <?= /* I18N: A button label. */ I18N::translate('reset') ?>
85            </a>
86        </div>
87    </div>
88</form>
89
90<div class="wt-page-content">
91    <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p>
92    <?php if ($media_objects->isNotEmpty()) : ?>
93
94        <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?>
95
96        <div class="card-deck row mb-4 mt-4">
97            <?php foreach ($media_objects as $n => $media_object) : ?>
98                <div class="col-12 col-sm-6 col-lg-4 d-flex">
99                    <div class="card mb-4">
100                        <div class="card-header">
101                            <h4 class="card-title">
102                                <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a>
103                            </h4>
104                        </div>
105                        <div class="card-body">
106                            <?php foreach ($media_object->mediaFiles() as $media_file) : ?>
107                                <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?>
108                            <?php endforeach ?>
109
110                            <p class="card-text">
111                                <?php
112                                // Show file details
113                                $mediatype = $media_file->type();
114                                if ($mediatype) {
115                                    echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype));
116                                }
117                                echo FunctionsPrintFacts::printFactSources($tree, $media_object->gedcom(), 1);
118                                echo FunctionsPrint::printFactNotes($tree, $media_object->gedcom(), 1);
119                                if ($media_file->isExternal()) {
120                                    echo GedcomTag::getLabelValue('URL', e($media_file->filename()));
121                                } elseif ($media_file->fileExists($data_filesystem)) {
122                                    echo GedcomTag::getLabelValue('FORM', $media_file->mimeType());
123                                    if (Auth::isEditor($tree)) {
124                                        echo GedcomTag::getLabelValue('FILE', e($media_file->filename()));
125                                    }
126                                    if (Auth::isEditor($tree)) {
127                                        foreach ($media_file->attributes($data_filesystem) as $tag => $value) {
128                                            echo GedcomTag::getLabelValue($tag, $value);
129                                        }
130                                    }
131                                } else {
132                                    echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>';
133                                }
134                                ?>
135                            </p>
136                        </div>
137                        <div class="card-footer">
138                            <?php foreach ($media_object->linkedIndividuals('OBJE') as $record) : ?>
139                                <?= view('icons/individual') ?>
140                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
141                                <br>
142                            <?php endforeach ?>
143
144                            <?php foreach ($media_object->linkedFamilies('OBJE') as $record) : ?>
145                                <?= view('icons/family') ?>
146                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
147                                <br>
148                            <?php endforeach ?>
149
150                            <?php foreach ($media_object->linkedSources('OBJE') as $record) : ?>
151                                <?= view('icons/source') ?>
152                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
153                                <br>
154                            <?php endforeach ?>
155                        </div>
156                    </div>
157                </div>
158            <?php endforeach ?>
159        </div>
160
161        <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?>
162    <?php endif ?>
163</div>
164