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