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