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