xref: /webtrees/resources/views/admin/media.phtml (revision 36779af1bd0601de7819554b13a393f6edb92507)
10c0910bfSGreg Roach<?php
2dd6b2bfcSGreg Roach
30c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
48ce3bd73SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaAction;
58ce3bd73SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaData;
60c0910bfSGreg Roachuse Fisharebest\Webtrees\I18N;
70c0910bfSGreg Roachuse Fisharebest\Webtrees\View;
8455a30feSGreg Roachuse Illuminate\Support\Collection;
90c0910bfSGreg Roach
10be04b569SDavid Drury/**
11be04b569SDavid Drury * @var string                 $data_folder
12455a30feSGreg Roach * @var string                 $files
13be04b569SDavid Drury * @var string                 $media_folder
14*36779af1SGreg Roach * @var Collection<int,string> $media_folders
15*36779af1SGreg Roach * @var array<string>          $media_types
16be04b569SDavid Drury * @var string                 $subfolders
17455a30feSGreg Roach * @var string                 $title
18be04b569SDavid Drury */
190c0910bfSGreg Roach?>
200c0910bfSGreg Roach
210c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
22dd6b2bfcSGreg Roach
23dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
24dd6b2bfcSGreg Roach
258ce3bd73SGreg Roach<form method="post" action="<?= e(route(ManageMediaAction::class)) ?>" id="admin-media-form">
263d180ba8SGreg Roach    <?= csrf_field() ?>
273d180ba8SGreg Roach
28dd6b2bfcSGreg Roach    <table class="table table-bordered table-sm">
29dd6b2bfcSGreg Roach        <thead>
30dd6b2bfcSGreg Roach            <tr>
31dd6b2bfcSGreg Roach                <th><?= I18N::translate('Media files') ?></th>
32dd6b2bfcSGreg Roach                <th><?= I18N::translate('Media folders') ?></th>
33dd6b2bfcSGreg Roach            </tr>
34dd6b2bfcSGreg Roach        </thead>
35dd6b2bfcSGreg Roach        <tbody>
36dd6b2bfcSGreg Roach            <tr>
37dd6b2bfcSGreg Roach                <td>
38dd6b2bfcSGreg Roach                    <label>
39b6c326d8SGreg Roach                        <input type="radio" name="files" value="local" <?= $files === 'local' ? 'checked' : '' ?>>
40dd6b2bfcSGreg Roach                        <?= /* I18N: “Local files” are stored on this computer */ I18N::translate('Local files') ?>
41dd6b2bfcSGreg Roach                    </label>
42dd6b2bfcSGreg Roach                    <br>
43dd6b2bfcSGreg Roach                    <label>
44b6c326d8SGreg Roach                        <input type="radio" name="files" value="external" <?= $files === 'external' ? 'checked' : '' ?>>
45dd6b2bfcSGreg Roach                        <?= /* I18N: “External files” are stored on other computers */ I18N::translate('External files') ?>
46dd6b2bfcSGreg Roach                    </label>
47dd6b2bfcSGreg Roach                    <br>
48dd6b2bfcSGreg Roach                    <label>
49b6c326d8SGreg Roach                        <input type="radio" name="files" value="unused" <?= $files === 'unused' ? 'checked' : '' ?>>
50dd6b2bfcSGreg Roach                        <?= I18N::translate('Unused files') ?>
51dd6b2bfcSGreg Roach                    </label>
52dd6b2bfcSGreg Roach                </td>
53dd6b2bfcSGreg Roach                <td>
54dd6b2bfcSGreg Roach                    <?php if ($files === 'local' || $files === 'unused') : ?>
55b6c326d8SGreg Roach                        <div class="input-group mb-2" dir="ltr">
56b6c326d8SGreg Roach                            <div class="input-group-text"><?= e($data_folder) ?></div>
57315eb316SGreg Roach
58b6c326d8SGreg Roach                            <?php if ($media_folders->count() > 1) : ?>
59c9e11c2aSGreg Roach                                <?= view('components/select', ['name' => 'media_folder', 'selected' => $media_folder, 'options' => $media_folders]) ?>
60dd6b2bfcSGreg Roach                            <?php else : ?>
61be04b569SDavid Drury                                <input aria-label="<?= I18N::translate('Media folder') ?>"
62be04b569SDavid Drury                                       type="text" class="form-control" name="media_folder" value="<?= e($media_folder) ?>" readonly>
63dd6b2bfcSGreg Roach                            <?php endif ?>
64dd6b2bfcSGreg Roach                        </div>
65dd6b2bfcSGreg Roach
66dd6b2bfcSGreg Roach                        <label>
67b6c326d8SGreg Roach                            <input type="radio" name="subfolders" value="include" <?= $subfolders === 'include' ? 'checked' : '' ?>>
68dd6b2bfcSGreg Roach                            <?= I18N::translate('Include subfolders') ?>
69dd6b2bfcSGreg Roach                        </label>
70dd6b2bfcSGreg Roach                        <br>
71dd6b2bfcSGreg Roach                        <label>
72b6c326d8SGreg Roach                            <input type="radio" name="subfolders" value="exclude" <?= $subfolders === 'exclude' ? ' checked' : '' ?>>
73dd6b2bfcSGreg Roach                            <?= I18N::translate('Exclude subfolders') ?>
74dd6b2bfcSGreg Roach                        </label>
75dd6b2bfcSGreg Roach
76dd6b2bfcSGreg Roach                    <?php elseif ($files === 'external') : ?>
77dd6b2bfcSGreg Roach                        <?= I18N::translate('External media files have a URL instead of a filename.') ?>
78dd6b2bfcSGreg Roach                        <input type="hidden" name="media_folder" value="<?= e($media_folder) ?>">
79dd6b2bfcSGreg Roach
80dd6b2bfcSGreg Roach                    <?php endif ?>
81dd6b2bfcSGreg Roach                </td>
82dd6b2bfcSGreg Roach            </tr>
83dd6b2bfcSGreg Roach        </tbody>
84dd6b2bfcSGreg Roach    </table>
85dd6b2bfcSGreg Roach</form>
86dd6b2bfcSGreg Roach<br>
87dd6b2bfcSGreg Roach<br>
88dd6b2bfcSGreg Roach
89b4139381SGreg Roach<table
90b4139381SGreg Roach    class="table table-bordered table-sm datatables d-none"
91b6c326d8SGreg Roach    <?= view('lists/datatables-attributes') ?>
928ce3bd73SGreg Roach    data-ajax="<?= e(route(ManageMediaData::class, ['files' => $files, 'media_folder' => $media_folder, 'subfolders' => $subfolders])) ?>"
9313aa75d8SGreg Roach    data-server-side="true"
94b6c326d8SGreg Roach>
95dd6b2bfcSGreg Roach    <thead>
96dd6b2bfcSGreg Roach        <tr>
9713aa75d8SGreg Roach            <th>
9813aa75d8SGreg Roach                <?= I18N::translate('Media file') ?>
9913aa75d8SGreg Roach            </th>
10013aa75d8SGreg Roach
10113aa75d8SGreg Roach            <th data-sortable="false">
10213aa75d8SGreg Roach                <?= I18N::translate('Media') ?>
10313aa75d8SGreg Roach            </th>
10413aa75d8SGreg Roach
10513aa75d8SGreg Roach            <th data-sortable="<?= $files === 'unused' ? 'false' : 'true' ?>">
10613aa75d8SGreg Roach                <?= I18N::translate('Media object') ?>
10713aa75d8SGreg Roach            </th>
108dd6b2bfcSGreg Roach        </tr>
109dd6b2bfcSGreg Roach    </thead>
110dd6b2bfcSGreg Roach</table>
111455a30feSGreg Roach<?= view('modals/create-media-from-file', ['media_types' => $media_types]) ?>
112dd6b2bfcSGreg Roach
113dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
114dd6b2bfcSGreg Roach<script>
115b6c326d8SGreg Roach    $("#admin-media-form input, #admin-media-form select").change(function () {
116b6c326d8SGreg Roach        $("#admin-media-form").submit();
117b6c326d8SGreg Roach    });
118dd6b2bfcSGreg Roach</script>
119dd6b2bfcSGreg Roach<?php View::endpush() ?>
120