xref: /webtrees/resources/views/admin/gedcom-export-options.phtml (revision c4cbcd7b5d2995f2119e8970ddb302651026bf90)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\Encodings\ANSEL;
5use Fisharebest\Webtrees\Encodings\ASCII;
6use Fisharebest\Webtrees\Encodings\UTF16BE;
7use Fisharebest\Webtrees\Encodings\UTF8;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\Tree;
10use Fisharebest\Webtrees\View;
11
12/**
13 * @var array<string> $download_filenames
14 * @var Tree          $tree
15 * @var bool          $zip_available
16 */
17
18?>
19
20<div class="row mb-3">
21    <label class="col-sm-3" for="format">
22        <?= I18N::translate('Format') ?>
23    </label>
24
25    <div class="col-sm-9">
26        <div class="form-check">
27            <input class="form-check-input" type="radio" name="format" id="format-gedcom" value="gedcom" checked="checked" data-wt-extension=".ged">
28
29            <label class="form-check-label" for="format-gedcom">
30                <?= I18N::translate('GEDCOM') ?>
31            </label>
32        </div>
33
34        <div class="form-check">
35            <input class="form-check-input" type="radio" name="format" id="format-zip" value="zip" data-wt-extension=".zip" <?= $zip_available ? '' : 'disabled="disabled"'?>>
36
37            <label class="form-check-label" for="format-zip">
38                <?= /* I18N: ZIP = file format */ I18N::translate('ZIP') ?>
39            </label>
40        </div>
41
42        <div class="form-check">
43            <input class="form-check-input" type="radio" name="format" id="format-zipmedia" value="zipmedia" data-wt-extension=".zip" <?= $zip_available ? '' : 'disabled="disabled"'?>>
44
45            <label class="form-check-label" for="format-zipmedia">
46                <?= /* I18N: ZIP = file format */ I18N::translate('ZIP') ?>
47                <?= I18N::translate('(includes media files)') ?>
48            </label>
49        </div>
50
51        <div class="form-check">
52            <input class="form-check-input" type="radio" name="format" id="format-gdz" value="gedzip" data-wt-extension=".gdz" <?= $zip_available ? '' : 'disabled="disabled"'?>>
53
54            <label class="form-check-label" for="format-gdz">
55                <?= /* I18N: GEDZIP = file format */ I18N::translate('GEDZIP') ?>
56                <?= I18N::translate('(includes media files)') ?>
57            </label>
58        </div>
59    </div>
60</div>
61
62<div class="row mb-3">
63    <label class="col-sm-3" for="filename">
64        <?= I18N::translate('Filename') ?>
65    </label>
66
67    <div class="col-sm-9">
68        <div class="input-group">
69            <?= view('components/select', ['name' => 'filename', 'id' => 'filename', 'selected' => 0, 'options' => $download_filenames]) ?>
70            <span class="input-group-text" id="extension">.ged</span>
71        </div>
72    </div>
73</div>
74
75<div class="row mb-3">
76    <label class="col-sm-3" for="encoding">
77        <?= I18N::translate('Character encoding') ?>
78    </label>
79
80    <div class="col-sm-9">
81        <?= view('components/select', ['name' => 'encoding', 'id' => 'encoding', 'selected' => UTF8::NAME, 'options' => [UTF8::NAME => 'UTF-8', UTF16BE::NAME => 'UNICODE (UTF16-BE)', ANSEL::NAME => 'ANSEL', ASCII::NAME => 'ASCII', 'CP1252' => 'ANSI (CP1252)']]) ?>
82    </div>
83</div>
84
85<div class="row mb-3">
86    <label class="col-sm-3" for="line_endings">
87        <?= I18N::translate('Line endings') ?>
88    </label>
89
90    <div class="col-sm-9">
91        <?= view('components/radios-inline', ['name' => 'line_endings', 'options' => ['CRLF' => 'CR/LF (windows)', 'LF' => 'LF (unix)'], 'selected' => 'CRLF']) ?>
92    </div>
93</div>
94
95<div class="row mb-3">
96    <label class="col-sm-3" for="privacy">
97        <?= I18N::translate('Apply privacy settings') ?>
98    </label>
99
100    <div class="col-sm-9">
101        <?php if (Auth::isAdmin()) : ?>
102            <?= view('components/radios-inline', ['name' => 'privacy', 'options' => ['none' => I18N::translate('None'), 'gedadmin' => I18N::translate('Manager'), 'user' => I18N::translate('Member'), 'visitor' => I18N::translate('Visitor')], 'selected' => 'none']) ?>
103        <?php elseif (Auth::isManager($tree)) : ?>
104            <?= view('components/radios-inline', ['name' => 'privacy', 'options' => ['gedadmin' => I18N::translate('Manager'), 'user' => I18N::translate('Member'), 'visitor' => I18N::translate('Visitor')], 'selected' => 'gedadmin']) ?>
105        <?php elseif (Auth::isMember($tree)) : ?>
106            <?= view('components/radios-inline', ['name' => 'privacy', 'options' => ['user' => I18N::translate('Member'), 'visitor' => I18N::translate('Visitor')], 'selected' => 'user']) ?>
107        <?php else : ?>
108            <input type="hidden" name="privacy" value="visitor">
109        <?php endif ?>
110    </div>
111</div>
112
113<?php View::push('javascript') ?>
114<script>
115  'use strict';
116
117  document.querySelectorAll('[name=format]').forEach(element => element.addEventListener('change', event => document.getElementById('extension').innerText = event.target.dataset.wtExtension));
118
119  // Firefox will reload the page and change the selected item.
120  document.getElementById('extension').innerText = document.querySelector('[name=format]:checked').dataset.wtExtension;
121
122</script>
123<?php View::endpush(); ?>
124