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