xref: /webtrees/resources/views/modules/media-list/page.phtml (revision c540224494b4c0b9f7d890f59f1cd44e9f6d92ea)
1ff995987SGreg Roach<?php
2ff995987SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
5ff995987SGreg Roachuse Fisharebest\Webtrees\Auth;
6ff995987SGreg Roachuse Fisharebest\Webtrees\I18N;
706a438b4SGreg Roachuse Fisharebest\Webtrees\Media;
8455a30feSGreg Roachuse Fisharebest\Webtrees\MediaFile;
906a438b4SGreg Roachuse Fisharebest\Webtrees\Module\ModuleListInterface;
10455a30feSGreg Roachuse Fisharebest\Webtrees\Registry;
114991f205SGreg Roachuse Fisharebest\Webtrees\Services\LinkedRecordService;
12455a30feSGreg Roachuse Fisharebest\Webtrees\Tree;
1306a438b4SGreg Roachuse Illuminate\Support\Collection;
1406a438b4SGreg Roach
1506a438b4SGreg Roach/**
1606a438b4SGreg Roach * @var int                   $count
1706a438b4SGreg Roach * @var string                $filter
1806a438b4SGreg Roach * @var string                $folder
1906a438b4SGreg Roach * @var array<string>         $folders
2006a438b4SGreg Roach * @var string                $format
2106a438b4SGreg Roach * @var array<string>         $formats
224991f205SGreg Roach * @var LinkedRecordService   $linked_record_service
23455a30feSGreg Roach * @var int                   $max
2436779af1SGreg Roach * @var Collection<int,Media> $media_objects
2506a438b4SGreg Roach * @var ModuleListInterface   $module
2606a438b4SGreg Roach * @var int                   $page
2706a438b4SGreg Roach * @var int                   $pages
287cda2f2fSGreg Roach * @var bool                  $subdirs
2906a438b4SGreg Roach * @var string                $title
30455a30feSGreg Roach * @var Tree                  $tree
3106a438b4SGreg Roach */
32ff995987SGreg Roach
33ff995987SGreg Roach?>
34ff995987SGreg Roach
35ff995987SGreg Roach<h2 class="wt-page-title">
36ff995987SGreg Roach    <?= $title ?>
37ff995987SGreg Roach</h2>
38ff995987SGreg Roach
39ff995987SGreg Roach<form method="post" class="wt-page-options wt-page-options-media-list d-print-none">
409e3c2cf9SGreg Roach    <div class="row">
41ff995987SGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="folder">
42ff995987SGreg Roach            <?= I18N::translate('Folder') ?>
43ff995987SGreg Roach        </label>
44ff995987SGreg Roach        <div class="col-sm-3 wt-page-options-value">
45ff995987SGreg Roach            <?= view('components/select', ['name' => 'folder', 'selected' => $folder, 'options' => $folders]) ?>
467cda2f2fSGreg Roach            <?= view('components/checkbox-inline', ['label' => /* I18N: Label for check-box */ I18N::translate('Include subfolders'), 'name' => 'subdirs', 'checked' => $subdirs]) ?>
47ff995987SGreg Roach        </div>
48ff995987SGreg Roach
49ff995987SGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="max">
50ff995987SGreg Roach            <?= I18N::translate('Media objects per page') ?>
51ff995987SGreg Roach        </label>
52ff995987SGreg Roach        <div class="col-sm-3 wt-page-options-value">
53f91b18ebSGreg Roach            <?= view('components/select-number', ['name' => 'max', 'selected' => $max, 'options' => [10, 20, 30, 40, 50, 75, 100, 150, 200]]) ?>
54ff995987SGreg Roach        </div>
55ff995987SGreg Roach    </div>
56ff995987SGreg Roach
579e3c2cf9SGreg Roach    <div class="row">
5806a438b4SGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="format">
59ff995987SGreg Roach            <?= I18N::translate('Type') ?>
60ff995987SGreg Roach        </label>
6106a438b4SGreg Roach
62ff995987SGreg Roach        <div class="col-sm-3 wt-page-options-value">
6306a438b4SGreg Roach            <?= view('components/select', ['name' => 'format', 'id' => 'format', 'selected' => $format, 'options' => ['' => ''] + $formats]) ?>
64ff995987SGreg Roach        </div>
65ff995987SGreg Roach
6606a438b4SGreg Roach        <div class="col-sm-3 col-form-label wt-page-options-label"></div>
6706a438b4SGreg Roach
6806a438b4SGreg Roach        <div class="col-sm-3 wt-page-options-value"></div>
69ff995987SGreg Roach    </div>
70ff995987SGreg Roach
719e3c2cf9SGreg Roach    <div class="row">
72ff995987SGreg Roach        <label class="col-sm-3 col-form-label wt-page-options-label" for="filter">
73ff995987SGreg Roach            <?= I18N::translate('Search filters') ?>
74ff995987SGreg Roach        </label>
75ff995987SGreg Roach        <div class="col-sm-3 wt-page-options-value">
76ff995987SGreg Roach            <input type="text" class="form-control" name="filter" id="filter" value="<?= e($filter) ?>">
77ff995987SGreg Roach        </div>
78ff995987SGreg Roach
7906a438b4SGreg Roach        <div class="col-sm-3 col-form-label wt-page-options-label"></div>
8006a438b4SGreg Roach
81ff995987SGreg Roach        <div class="col-sm-3 wt-page-options-value">
82748dbe15SGreg Roach            <input type="hidden" name="page" value="1">
83748dbe15SGreg Roach            <button type="submit" class="btn btn-primary">
84ff995987SGreg Roach                <?= /* I18N: A button label. */ I18N::translate('search') ?>
85ff995987SGreg Roach            </button>
8606a438b4SGreg Roach            <a class="btn btn-secondary" href="<?= e($module->listUrl($tree)) ?>">
87ff995987SGreg Roach                <?= /* I18N: A button label. */ I18N::translate('reset') ?>
88ff995987SGreg Roach            </a>
89ff995987SGreg Roach        </div>
90ff995987SGreg Roach    </div>
9181443e3cSGreg Roach
9281443e3cSGreg Roach    <?= csrf_field() ?>
93ff995987SGreg Roach</form>
94ff995987SGreg Roach
95ff995987SGreg Roach<div class="wt-page-content">
96ff995987SGreg Roach    <p class="text-center mt-4"><?= I18N::translate('Media objects found') ?> <?= I18N::number($count) ?></p>
976e9b2106SThomas Karcher    <?php if ($media_objects->isNotEmpty()) : ?>
9806a438b4SGreg Roach        <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?>
99ff995987SGreg Roach
10061275c55SJonathan Jaubart        <div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 g-4">
101*c5402244SGreg Roach            <?php foreach ($media_objects as $media_object) : ?>
10261275c55SJonathan Jaubart                <div class="col">
10361275c55SJonathan Jaubart                    <div class="card h-100">
104ff995987SGreg Roach                        <div class="card-header">
105ff995987SGreg Roach                            <h4 class="card-title">
106ff995987SGreg Roach                                <a href="<?= e($media_object->url()) ?>"><?= $media_object->fullName() ?></a>
107ff995987SGreg Roach                            </h4>
108ff995987SGreg Roach                        </div>
109ff995987SGreg Roach                        <div class="card-body">
110ff995987SGreg Roach                            <?php foreach ($media_object->mediaFiles() as $media_file) : ?>
111ff995987SGreg Roach                                <?= $media_file->displayImage(300, 200, 'contain', ['class' => 'img-fluid']) ?>
112ff995987SGreg Roach                            <?php endforeach ?>
113ff995987SGreg Roach
114455a30feSGreg Roach                            <?php $media_file = $media_object->mediaFiles()->first() ?>
115455a30feSGreg Roach                            <?php if ($media_file instanceof MediaFile) : ?>
116ff995987SGreg Roach                                <p class="card-text">
117ff995987SGreg Roach                                    <?php
118ff995987SGreg Roach                                    // Show file details
119455a30feSGreg Roach                                    if ($media_file->type() !== '') {
120455a30feSGreg Roach                                        $element = Registry::elementFactory()->make('OBJE:FILE:FORM:TYPE');
121455a30feSGreg Roach                                        echo $element->labelValue($media_file->type(), $media_object->tree());
122ff995987SGreg Roach                                    }
123b315f3e1SGreg Roach
124b315f3e1SGreg Roach                                    foreach ($media_object->facts(['SOUR']) as $fact) {
125b315f3e1SGreg Roach                                        echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]);
126b315f3e1SGreg Roach                                    }
127b315f3e1SGreg Roach
128b315f3e1SGreg Roach                                    foreach ($media_object->facts(['NOTE']) as $fact) {
129b315f3e1SGreg Roach                                        echo view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media_object->tag(), 'tree' => $tree]);
130b315f3e1SGreg Roach                                    }
131b315f3e1SGreg Roach
132ff995987SGreg Roach                                    if ($media_file->isExternal()) {
133455a30feSGreg Roach                                        echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree());
1349458f20aSGreg Roach                                    } elseif ($media_file->fileExists()) {
135ff995987SGreg Roach                                        if (Auth::isEditor($tree)) {
136455a30feSGreg Roach                                            echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree());
137cfb84ff6SGreg Roach
1389458f20aSGreg Roach                                            foreach ($media_file->attributes() as $label => $value) {
13969cdf014SGreg Roach                                                $label = '<span class="label">' . $label . '</span>';
14069cdf014SGreg Roach                                                $value = '<span class="value">' . $value . '</span>';
14169cdf014SGreg Roach
14269cdf014SGreg Roach                                                echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>';
143ff995987SGreg Roach                                            }
144ff995987SGreg Roach                                        }
145ff995987SGreg Roach                                    } else {
1460cfb9b8cSGreg Roach                                        echo '<p class="alert alert-danger">', /* I18N: %s is a filename */ I18N::translate('The file “%s” does not exist.', e($media_file->filename())), '</p>';
147ff995987SGreg Roach                                    }
148ff995987SGreg Roach                                    ?>
149ff995987SGreg Roach                                </p>
150455a30feSGreg Roach                            <?php endif ?>
151ff995987SGreg Roach                        </div>
152ff995987SGreg Roach                        <div class="card-footer">
1534991f205SGreg Roach                            <?php foreach ($linked_record_service->linkedIndividuals($media_object) as $record) : ?>
154ff995987SGreg Roach                                <?= view('icons/individual') ?>
155ff995987SGreg Roach                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
156ff995987SGreg Roach                                <br>
157ff995987SGreg Roach                            <?php endforeach ?>
158ff995987SGreg Roach
1594991f205SGreg Roach                            <?php foreach ($linked_record_service->linkedFamilies($media_object) as $record) : ?>
160ff995987SGreg Roach                                <?= view('icons/family') ?>
161ff995987SGreg Roach                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
162ff995987SGreg Roach                                <br>
163ff995987SGreg Roach                            <?php endforeach ?>
164ff995987SGreg Roach
1654991f205SGreg Roach                            <?php foreach ($linked_record_service->linkedSources($media_object) as $record) : ?>
166ff995987SGreg Roach                                <?= view('icons/source') ?>
167ff995987SGreg Roach                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
168ff995987SGreg Roach                                <br>
169ff995987SGreg Roach                            <?php endforeach ?>
170b90d19c1SRichard Cissée
171b90d19c1SRichard Cissée                            <?php foreach ($linked_record_service->linkedLocations($media_object) as $record) : ?>
172b90d19c1SRichard Cissée                                <?= view('icons/location') ?>
173b90d19c1SRichard Cissée                                <a href="<?= e($record->url()) ?>"><?= $record->fullName() ?></a>
174b90d19c1SRichard Cissée                                <br>
175b90d19c1SRichard Cissée                            <?php endforeach ?>
176ff995987SGreg Roach                        </div>
177ff995987SGreg Roach                    </div>
178ff995987SGreg Roach                </div>
179ff995987SGreg Roach            <?php endforeach ?>
180ff995987SGreg Roach        </div>
181ff995987SGreg Roach
18206a438b4SGreg Roach        <?= view('modules/media-list/pagination', ['module' => $module, 'page' => $page, 'pages' => $pages, 'folder' => $folder, 'subdirs' => $subdirs, 'filter' => $filter, 'format' => $format, 'max' => $max, 'tree' => $tree]) ?>
183ff995987SGreg Roach    <?php endif ?>
184ff995987SGreg Roach</div>
185