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