xref: /webtrees/resources/views/admin/media.phtml (revision 66ce3d2365f7eb099897303ad7dc49a8459ceb55)
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="get" action="<?= e(route('admin-media')) ?>" id="admin-media-form">
14    <input type="hidden" name="route" value="admin-media">
15    <table class="table table-bordered table-sm">
16        <thead>
17            <tr>
18                <th><?= I18N::translate('Media files') ?></th>
19                <th><?= I18N::translate('Media folders') ?></th>
20            </tr>
21        </thead>
22        <tbody>
23            <tr>
24                <td>
25                    <label>
26                        <input type="radio" name="files" value="local" <?= $files === 'local' ? 'checked' : '' ?>>
27                        <?= /* I18N: “Local files” are stored on this computer */ I18N::translate('Local files') ?>
28                    </label>
29                    <br>
30                    <label>
31                        <input type="radio" name="files" value="external" <?= $files === 'external' ? 'checked' : '' ?>>
32                        <?= /* I18N: “External files” are stored on other computers */ I18N::translate('External files') ?>
33                    </label>
34                    <br>
35                    <label>
36                        <input type="radio" name="files" value="unused" <?= $files === 'unused' ? 'checked' : '' ?>>
37                        <?= I18N::translate('Unused files') ?>
38                    </label>
39                </td>
40                <td>
41                    <?php if ($files === 'local' || $files === 'unused') : ?>
42                        <div class="input-group mb-2" dir="ltr">
43                            <div class="input-group-prepend">
44                                <div class="input-group-text"><?= e($data_folder) ?></div>
45                            </div>
46                                <?php if ($media_folders->count() > 1) : ?>
47                                    <?= view('components/select', ['name' => 'media_folder', 'selected' => $media_folder, 'options' => $media_folders]) ?>
48
49                                <?php else : ?>
50                                    <?= e($media_folder) ?>
51                                    <input type="hidden" name="media_folder" value="<?= e($media_folder) ?>">
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" id="media-table-<?= e($table_id) ?>"
80    <?= view('lists/datatables-attributes') ?>
81    data-ajax="<?= e(route('admin-media-data', ['files' => $files, 'media_folder' => $media_folder, 'subfolders' => $subfolders])) ?>"
82>
83    <thead>
84        <tr>
85            <th><?= I18N::translate('Media file') ?></th>
86            <th><?= I18N::translate('Media') ?></th>
87            <th><?= I18N::translate('Media object') ?></th>
88        </tr>
89    </thead>
90    <tbody>
91    </tbody>
92</table>
93<?= view('modals/create-media-from-file') ?>
94
95<?php View::push('javascript') ?>
96<script>
97    $("#admin-media-form input, #admin-media-form select").change(function () {
98        $("#admin-media-form").submit();
99    });
100
101  $("#media-table-<?= e($table_id) ?>").dataTable({
102    processing: true,
103    serverSide: true,
104    autoWidth: false,
105    columns: [
106      {},
107      {sortable: false},
108      {sortable: <?= $files === 'unused' ? 'false' : 'true' ?>}
109    ]
110  });
111</script>
112<?php View::endpush() ?>
113