xref: /webtrees/resources/views/admin/media.phtml (revision 71239cb694d278d044f33328daaa60c8ed7431e9)
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                        <?php if (count($media_paths) > 1) : ?>
48                            <?= Bootstrap4::select($media_paths, $media_path, ['name' => 'media_path', 'onchange' => 'this.form.submit();']) ?>
49                        <?php else : ?>
50                            <?= e($media_path) ?>
51                            <input type="hidden" name="media_path" value="<?= e($media_path) ?>">
52                        <?php endif ?>
53
54                        <label>
55                            <input type="radio" name="subfolders" value="include" <?= $subfolders === 'include' ? 'checked' : '' ?> onchange="this.form.submit();">
56                            <?= I18N::translate('Include subfolders') ?>
57                        </label>
58                        <br>
59                        <label>
60                            <input type="radio" name="subfolders" value="exclude" <?= $subfolders === 'exclude' ? ' checked' : '' ?> onchange="this.form.submit();">
61                            <?= I18N::translate('Exclude subfolders') ?>
62                        </label>
63
64                    <?php elseif ($files === 'external') : ?>
65                        <?= I18N::translate('External media files have a URL instead of a filename.') ?>
66                        <input type="hidden" name="media_folder" value="<?= e($media_folder) ?>">
67                        <input type="hidden" name="media_path" value="<?= e($media_path) ?>">
68
69                    <?php endif ?>
70                </td>
71            </tr>
72        </tbody>
73    </table>
74</form>
75<br>
76<br>
77
78<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, 'media_path' => $media_path, 'subfolders' => $subfolders])) ?>">
79    <thead>
80        <tr>
81            <th><?= I18N::translate('Media file') ?></th>
82            <th><?= I18N::translate('Media') ?></th>
83            <th><?= I18N::translate('Media object') ?></th>
84        </tr>
85    </thead>
86    <tbody>
87    </tbody>
88</table>
89<?= view('modals/create-media-from-file') ?>
90
91
92<?php View::push('javascript') ?>
93<script>
94  $("#media-table-<?= e($table_id) ?>").dataTable({
95    processing: true,
96    serverSide: true,
97    autoWidth: false,
98    pageLength: 10,
99    pagingType: "full_numbers",
100    stateSave: true,
101    stateDuration: 300,
102    columns: [
103      {},
104      {sortable: false},
105      {sortable: <?= $files === 'unused' ? 'false' : 'true' ?>}
106    ],
107        <?= I18N::datatablesI18N([5, 10, 20, 50, 100, 500, 1000, -1]) ?>
108  });
109</script>
110<?php View::endpush() ?>
111