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