xref: /webtrees/resources/views/modals/media-file-fields.phtml (revision 8e0e1b25d26151378cec98290280e1e3dc075ff7)
1<?php
2
3use Fisharebest\Webtrees\GedcomTag;
4
5?>
6<?php use Fisharebest\Webtrees\I18N; ?>
7
8<div class="form-group row <?= $media_file ? 'd-none' : '' ?>">
9    <label class="col-form-label col-sm-2" for="file-location">
10        <?= I18N::translate('Media file') ?>
11    </label>
12    <div class="col-sm-10">
13        <select class="form-control" id="file-location" name="file_location">
14            <option value="upload">
15                <?= I18N::translate('A file on your computer') ?>
16            </option>
17            <?php if (!empty($unused_files)) : ?>
18            <option value="unused">
19                <?= I18N::translate('A file on the server') ?>
20            </option>
21            <?php endif ?>
22            <option value="url">
23                <?= /* I18N: URL = web address */ I18N::translate('A URL') ?>
24            </option>
25        </select>
26    </div>
27</div>
28
29<div class="form-group row file-location file-location-upload <?= $media_file ? 'd-none' : '' ?>">
30    <label class="col-form-label col-sm-2" for="file">
31        <?= I18N::translate('A file on your computer') ?>
32    </label>
33    <div class="col-sm-10">
34        <input class="form-control" id="file" name="file" type="file">
35        <small class="text-muted">
36            <?= I18N::translate('Maximum upload size: ') ?>
37            <?= $max_upload_size ?>
38        </small>
39    </div>
40</div>
41
42<div class="form-group row file-location file-location-upload <?= $media_file && $media_file->isExternal() ? 'd-none' : '' ?>">
43    <label class="col-form-label col-sm-2" for="folder">
44        <?= I18N::translate('Filename on server') ?>
45    </label>
46    <div class="col-sm-10">
47        <div class="row">
48            <div class="col-sm-6">
49                <div class="form-check">
50                    <label class="form-check-label">
51                        <input class="form-check-input" type="radio" name="auto" value="0" checked>
52                        <input class="form-control" id="folder" name="folder" placeholder="<?= I18N::translate('Folder') ?>" type="text" value="<?= e(dirname($media_file ? $media_file->filename() : '') === '.' ? '' : dirname($media_file ? $media_file->filename() : '')) ?>" data-autocomplete-url="<?= e(route('autocomplete-folder', ['tree' => $tree->name(), 'query' => 'QUERY'])) ?>">
53                        <div class="input-group">
54                            <div class="input-group-append">
55                                <span class="input-group-text">/</span>
56                            </div>
57                        </div>
58                    </label>
59                </div>
60            </div>
61            <div class="col-sm-6">
62                <input class="form-control" name="new_file" type="text" placeholder="<?= I18N::translate('Same as uploaded file') ?>" value="<?= e(basename($media_file ? $media_file->filename() : '')) ?>">
63            </div>
64        </div>
65        <p class="small text-muted">
66            <?= I18N::translate('If you have a large number of media files, you can organize them into folders and subfolders.') ?>
67        </p>
68        <div class="form-check">
69            <label class="form-check-label">
70                <input class="form-check-input" type="radio" name="auto" value="1">
71                <?= I18N::translate('Create a unique filename') ?>
72            </label>
73        </div>
74    </div>
75</div>
76
77<div class="form-group row file-location file-location-unused d-none">
78    <label class="col-form-label col-sm-2" for="unused">
79        <?= I18N::translate('A file on the server') ?>
80    </label>
81    <div class="col-sm-10">
82        <?= view('components/select', ['name' => 'unused', 'selected' => '', 'options' => $unused_files]) ?>
83        <small class="text-muted">
84        </small>
85    </div>
86</div>
87
88<div class="form-group row file-location file-location-url <?= $media_file && $media_file->isExternal() ? '' : 'd-none' ?>">
89    <label class="col-form-label col-sm-2" for="remote">
90        <?= I18N::translate('URL') ?>
91    </label>
92    <div class="col-sm-10">
93        <input class="form-control" type="url" id="remote" name="remote" placeholder="https://www.example.com/photo.jpeg" value="<?= e($media_file && $media_file->isExternal() ? $media_file->filename() : '') ?>">
94        <small class="text-muted">
95            <?= view('icons/warning') ?>
96            <span class="sr-only"><?= I18N::translate('Caution!') ?></span>
97
98            <?= I18N::translate('The GEDCOM standard does not allow URLs in media objects.') ?>
99            <?= I18N::translate('Other genealogy applications might not recognize this data.') ?>
100        </small>
101    </div>
102</div>
103
104<div class="form-group row">
105    <label class="col-form-label col-sm-2" for="title">
106        <?= I18N::translate('Title') ?>
107    </label>
108    <div class="col-sm-10">
109        <input class="form-control" id="title" name="title" type="text" value="<?= e($media_file ? $media_file->title() : '') ?>">
110    </div>
111</div>
112
113<div class="form-group row">
114    <label class="col-form-label col-sm-2" for="type">
115        <?= I18N::translate('Media type') ?>
116    </label>
117    <div class="col-sm-10">
118        <?= view('components/select', ['name' => 'type', 'selected' => $media_file ? $media_file->type() : '', 'options' => ['' => ''] + GedcomTag::getFileFormTypes()]) ?>
119    </div>
120</div>
121
122<script>
123    autocomplete('#folder');
124    document.getElementById('file-location').addEventListener('change', function () {
125    $('.file-location').addClass('d-none');
126    $('.file-location-' + $(this).val()).removeClass('d-none');
127  });
128</script>
129