xref: /webtrees/resources/views/modals/media-file-fields.phtml (revision ba1d7494e9648df5a87aaa3fece3e098e5ce26b1)
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                        <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'])) ?>">
49                        <div class="input-group">
50                            <div class="input-group-append">
51                                <span class="input-group-text">/</span>
52                            </div>
53                        </div>
54                    </label>
55                </div>
56            </div>
57            <div class="col-sm-6">
58                <input class="form-control" name="new_file" type="text" placeholder="<?= I18N::translate('Same as uploaded file') ?>" value="<?= e(basename($media_file ? $media_file->filename() : '')) ?>">
59            </div>
60        </div>
61        <p class="small text-muted">
62            <?= I18N::translate('If you have a large number of media files, you can organize them into folders and subfolders.') ?>
63        </p>
64        <div class="form-check">
65            <label class="form-check-label">
66                <input class="form-check-input" type="radio" name="auto" value="1">
67                <?= I18N::translate('Create a unique filename') ?>
68            </label>
69        </div>
70    </div>
71</div>
72
73<div class="form-group row file-location file-location-unused d-none">
74    <label class="col-form-label col-sm-2" for="unused">
75        <?= I18N::translate('A file on the server') ?>
76    </label>
77    <div class="col-sm-10">
78        <?= view('components/select', ['name' => 'unused', 'selected' => '', 'options' => $unused_files]) ?>
79        <small class="text-muted">
80        </small>
81    </div>
82</div>
83
84<div class="form-group row file-location file-location-url <?= $media_file && $media_file->isExternal() ? '' : 'd-none' ?>">
85    <label class="col-form-label col-sm-2" for="remote">
86        <?= I18N::translate('URL') ?>
87    </label>
88    <div class="col-sm-10">
89        <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() : '') ?>">
90        <small class="text-muted">
91            <?= view('icons/warning') ?>
92            <span class="sr-only"><?= I18N::translate('Caution!') ?></span>
93
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        <?= view('components/select', ['name' => 'type', 'selected' => $media_file ? $media_file->type() : '', 'options' => ['' => ''] + GedcomTag::getFileFormTypes()]) ?>
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