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