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