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