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