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