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