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