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