xref: /webtrees/resources/views/admin/media.phtml (revision 1792ff1cf1956b41f3e3c853cfb279a803a71ed2)
1<?php
2
3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\View;
6
7/**
8 * @var string $title
9 * @var string $data_folder
10 * @var array $media_folders
11 * @var string $media_folder
12 * @var string $subfolders
13 */
14?>
15
16<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
17
18<h1><?= $title ?></h1>
19
20<form method="post" action="<?= e(route('admin-media-select')) ?>" id="admin-media-form">
21    <?= csrf_field() ?>
22
23    <table class="table table-bordered table-sm">
24        <thead>
25            <tr>
26                <th><?= I18N::translate('Media files') ?></th>
27                <th><?= I18N::translate('Media folders') ?></th>
28            </tr>
29        </thead>
30        <tbody>
31            <tr>
32                <td>
33                    <label>
34                        <input type="radio" name="files" value="local" <?= $files === 'local' ? 'checked' : '' ?>>
35                        <?= /* I18N: “Local files” are stored on this computer */ I18N::translate('Local files') ?>
36                    </label>
37                    <br>
38                    <label>
39                        <input type="radio" name="files" value="external" <?= $files === 'external' ? 'checked' : '' ?>>
40                        <?= /* I18N: “External files” are stored on other computers */ I18N::translate('External files') ?>
41                    </label>
42                    <br>
43                    <label>
44                        <input type="radio" name="files" value="unused" <?= $files === 'unused' ? 'checked' : '' ?>>
45                        <?= I18N::translate('Unused files') ?>
46                    </label>
47                </td>
48                <td>
49                    <?php if ($files === 'local' || $files === 'unused') : ?>
50                        <div class="input-group mb-2" dir="ltr">
51                            <div class="input-group-prepend">
52                                <div class="input-group-text"><?= e($data_folder) ?></div>
53                            </div>
54                                <?php if ($media_folders->count() > 1) : ?>
55                                    <?= view('components/select', ['name' => 'media_folder', 'selected' => $media_folder, 'options' => $media_folders]) ?>
56
57                                <?php else : ?>
58                                    <input aria-label="<?= I18N::translate('Media folder') ?>"
59                                           type="text" class="form-control" name="media_folder" value="<?= e($media_folder) ?>" readonly>
60                                <?php endif ?>
61                        </div>
62
63                        <label>
64                            <input type="radio" name="subfolders" value="include" <?= $subfolders === 'include' ? 'checked' : '' ?>>
65                            <?= I18N::translate('Include subfolders') ?>
66                        </label>
67                        <br>
68                        <label>
69                            <input type="radio" name="subfolders" value="exclude" <?= $subfolders === 'exclude' ? ' checked' : '' ?>>
70                            <?= I18N::translate('Exclude subfolders') ?>
71                        </label>
72
73                    <?php elseif ($files === 'external') : ?>
74                        <?= I18N::translate('External media files have a URL instead of a filename.') ?>
75                        <input type="hidden" name="media_folder" value="<?= e($media_folder) ?>">
76
77                    <?php endif ?>
78                </td>
79            </tr>
80        </tbody>
81    </table>
82</form>
83<br>
84<br>
85
86<table
87    class="table table-bordered table-sm datatables d-none"
88    <?= view('lists/datatables-attributes') ?>
89    data-ajax="<?= e(route('admin-media-data', ['files' => $files, 'media_folder' => $media_folder, 'subfolders' => $subfolders])) ?>"
90    data-server-side="true"
91>
92    <thead>
93        <tr>
94            <th>
95                <?= I18N::translate('Media file') ?>
96            </th>
97
98            <th data-sortable="false">
99                <?= I18N::translate('Media') ?>
100            </th>
101
102            <th data-sortable="<?= $files === 'unused' ? 'false' : 'true' ?>">
103                <?= I18N::translate('Media object') ?>
104            </th>
105        </tr>
106    </thead>
107</table>
108<?= view('modals/create-media-from-file') ?>
109
110<?php View::push('javascript') ?>
111<script>
112    $("#admin-media-form input, #admin-media-form select").change(function () {
113        $("#admin-media-form").submit();
114    });
115</script>
116<?php View::endpush() ?>
117