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