xref: /webtrees/resources/views/admin/media.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
10c0910bfSGreg Roach<?php
2dd6b2bfcSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
50c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
68ce3bd73SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaAction;
78ce3bd73SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageMediaData;
80c0910bfSGreg Roachuse Fisharebest\Webtrees\I18N;
90c0910bfSGreg Roachuse Fisharebest\Webtrees\View;
10455a30feSGreg Roachuse Illuminate\Support\Collection;
110c0910bfSGreg Roach
12be04b569SDavid Drury/**
13be04b569SDavid Drury * @var string                 $data_folder
14455a30feSGreg Roach * @var string                 $files
15be04b569SDavid Drury * @var string                 $media_folder
1636779af1SGreg Roach * @var Collection<int,string> $media_folders
1736779af1SGreg Roach * @var array<string>          $media_types
18be04b569SDavid Drury * @var string                 $subfolders
19455a30feSGreg Roach * @var string                 $title
20be04b569SDavid Drury */
210c0910bfSGreg Roach?>
220c0910bfSGreg Roach
230c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?>
24dd6b2bfcSGreg Roach
25dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
26dd6b2bfcSGreg Roach
278ce3bd73SGreg Roach<form method="post" action="<?= e(route(ManageMediaAction::class)) ?>" id="admin-media-form">
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>
8581443e3cSGreg Roach
8681443e3cSGreg Roach    <?= csrf_field() ?>
87dd6b2bfcSGreg Roach</form>
88dd6b2bfcSGreg Roach<br>
89dd6b2bfcSGreg Roach<br>
90dd6b2bfcSGreg Roach
91b4139381SGreg Roach<table
92b4139381SGreg Roach    class="table table-bordered table-sm datatables d-none"
93b6c326d8SGreg Roach    <?= view('lists/datatables-attributes') ?>
948ce3bd73SGreg Roach    data-ajax="<?= e(route(ManageMediaData::class, ['files' => $files, 'media_folder' => $media_folder, 'subfolders' => $subfolders])) ?>"
9513aa75d8SGreg Roach    data-server-side="true"
96b6c326d8SGreg Roach>
97dd6b2bfcSGreg Roach    <thead>
98dd6b2bfcSGreg Roach        <tr>
9913aa75d8SGreg Roach            <th>
10013aa75d8SGreg Roach                <?= I18N::translate('Media file') ?>
10113aa75d8SGreg Roach            </th>
10213aa75d8SGreg Roach
10313aa75d8SGreg Roach            <th data-sortable="false">
10413aa75d8SGreg Roach                <?= I18N::translate('Media') ?>
10513aa75d8SGreg Roach            </th>
10613aa75d8SGreg Roach
10713aa75d8SGreg Roach            <th data-sortable="<?= $files === 'unused' ? 'false' : 'true' ?>">
10813aa75d8SGreg Roach                <?= I18N::translate('Media object') ?>
10913aa75d8SGreg Roach            </th>
110dd6b2bfcSGreg Roach        </tr>
111dd6b2bfcSGreg Roach    </thead>
112dd6b2bfcSGreg Roach</table>
113455a30feSGreg Roach<?= view('modals/create-media-from-file', ['media_types' => $media_types]) ?>
114dd6b2bfcSGreg Roach
115dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
116dd6b2bfcSGreg Roach<script>
117b6c326d8SGreg Roach    $("#admin-media-form input, #admin-media-form select").change(function () {
118b6c326d8SGreg Roach        $("#admin-media-form").submit();
119b6c326d8SGreg Roach    });
120dd6b2bfcSGreg Roach</script>
121dd6b2bfcSGreg Roach<?php View::endpush() ?>
122