xref: /webtrees/resources/views/admin/trees-import.phtml (revision b7a63c6c26a18692cf47ca93d62b843a1bb01c00)
1<?php use Fisharebest\Webtrees\I18N; ?>
2<?php use Fisharebest\Webtrees\View; ?>
3
4<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('admin-trees') => I18N::translate('Manage family trees'), $title]]) ?>
5
6<h1><?= $title ?></h1>
7
8<div class="alert alert-warning">
9    <?= /* I18N: %s is the name of a family tree */ I18N::translate('This will delete all the genealogy data from “%s” and replace it with data from a GEDCOM file.', e($tree->title())) ?>
10</div>
11
12<form method="post" action="<?= e(route('admin-trees-import-action', ['tree' => $tree->name()])) ?>" class="form form-horizontal" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?= e(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?')) ?>');">
13    <input type="hidden" id="gedcom_filename" value="<?= e($default_gedcom_file) ?>">
14    <?= csrf_field() ?>
15
16    <fieldset class="form-group">
17        <div class="row">
18            <legend class="col-form-label col-sm-3">
19                <?= I18N::translate('Select a GEDCOM file to import') ?>
20            </legend>
21            <div class="col-sm-9">
22                <div class="row form-group">
23                    <label class="col-sm-3">
24                        <input type="radio" name="source" id="import-computer" value="client" checked>
25                        <?= I18N::translate('A file on your computer') ?>
26                    </label>
27                    <div class="col-sm-9">
28                        <div class="btn btn-default">
29                            <input type="file" class="form-control-file" name="tree_name" id="import-computer-file">
30                        </div>
31                    </div>
32                </div>
33                <div class="row">
34                    <label class="col-sm-3">
35                        <input type="radio" name="source" id="import-server" value="server">
36                        <?= I18N::translate('A file on the server') ?>
37                    </label>
38                    <div class="col-sm-9">
39                        <div class="input-group" dir="ltr">
40                            <div class="input-group-prepend">
41                                <span class="input-group-text" dir="ltr">
42                                <?= e($data_folder) ?>
43                                </span>
44                            </div>
45                            <select name="tree_name" class="form-control" dir="ltr" id="import-server-file">
46                                <option value=""></option>
47                                <?php foreach ($gedcom_files as $gedcom_file) : ?>
48                                    <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>>
49                                        <?= e($gedcom_file) ?>
50                                    </option>
51                                <?php endforeach ?>
52                                <?php if (empty($gedcom_files)) : ?>
53                                    <option disabled selected>
54                                        <?= I18N::translate('No GEDCOM files found.') ?>
55                                    </option>
56                                <?php endif ?>
57                            </select>
58                        </div>
59                    </div>
60                </div>
61            </div>
62        </div>
63    </fieldset>
64
65    <hr>
66
67    <fieldset class="form-group">
68        <div class="row">
69            <legend class="col-form-label col-sm-3">
70                <?= I18N::translate('Import preferences') ?>
71            </legend>
72            <div class="col-sm-9">
73                <label>
74                    <input type="checkbox" name="keep_media" value="1" <?= $tree->getPreference('keep_media') ? 'checked' : '' ?>>
75                    <?= /* I18N: A configuration setting */ I18N::translate('Keep media objects') ?>
76                </label>
77                <p class="small text-muted">
78                    <?= I18N::translate('If you have created media objects in webtrees, and have subsequently edited this GEDCOM file using genealogy software that deletes media objects, then select this option to merge the current media objects with the new GEDCOM file.') ?>
79                </p>
80                <label>
81                    <input type="checkbox" name="WORD_WRAPPED_NOTES" value="1" <?= $tree->getPreference('WORD_WRAPPED_NOTES') ? 'checked' : '' ?>>
82                    <?= I18N::translate('Add spaces where long lines were wrapped') ?>
83                </label>
84                <p class="small text-muted">
85                    <?= I18N::translate('If you created this GEDCOM file using genealogy software that omits spaces when splitting long lines, then select this option to reinsert the missing spaces.') ?>
86                </p>
87                <label for="GEDCOM_MEDIA_PATH">
88                    <?= /* I18N: A media path (e.g. c:\aaa\bbb\ccc\ddd.jpeg) in a GEDCOM file */ I18N::translate('Remove the GEDCOM media path from filenames') ?>
89                </label>
90                <input
91                    class="form-control"
92                    dir="ltr"
93                    id="GEDCOM_MEDIA_PATH"
94                    maxlength="255"
95                    name="GEDCOM_MEDIA_PATH"
96                    type="text"
97                    value="<?= e($gedcom_media_path) ?>"
98                >
99                <p class="small text-muted">
100                    <?= /* I18N: Help text for the “GEDCOM media path” configuration setting. A “path” is something like “C:\Documents\Genealogy\Photos\John_Smith.jpeg” */ I18N::translate('Some genealogy software creates GEDCOM files that contain media filenames with full paths. These paths will not exist on the web-server. To allow webtrees to find the file, the first part of the path must be removed.') ?>
101                    <?= /* I18N: Help text for the “GEDCOM media path” configuration setting. %s are all folder names */ I18N::translate('For example, if the GEDCOM file contains %1$s and webtrees expects to find %2$s in the media folder, then you would need to remove %3$s.', '<code>C:\\Documents\\family\\photo.jpeg</code>', '<code>family\\photo.jpeg</code>', '<code>C:\\Documents\\</code>') ?>
102                </p>
103            </div>
104        </div>
105    </fieldset>
106
107    <div class="row form-group">
108        <div class="offset-sm-3 col-sm-9">
109            <button type="submit" class="btn btn-primary">
110                <?= /* I18N: A button label. */ I18N::translate('continue') ?>
111            </button>
112        </div>
113    </div>
114</form>
115
116<?php View::push('javascript') ?>
117<script>
118  function checkGedcomImportForm (message) {
119    var oldFile = $('#gedcom_filename').val();
120    var method = $('input[name=source]:checked').val();
121    var newFile = method === 'server' ? $('#import-server-file').val() : $('#import-computer-file').val();
122
123    // Some browsers include c:\fakepath\ in the filename.
124    newFile = newFile.replace(/.*[/\\]/, '');
125    if (newFile !== oldFile && oldFile !== '') {
126      return window.confirm(message);
127    } else {
128      return true;
129    }
130  }
131
132  document.getElementById("import-computer-file").addEventListener("click", function () {
133    document.getElementById("import-computer").checked = true;
134  });
135
136  document.getElementById("import-server-file").addEventListener("focus", function () {
137    document.getElementById("import-server").checked = true;
138  });
139</script>
140<?php View::endpush() ?>
141