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