xref: /webtrees/resources/views/admin/trees-import.phtml (revision b7a63c6c26a18692cf47ca93d62b843a1bb01c00)
1dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\I18N; ?>
2dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\View; ?>
3dd6b2bfcSGreg Roach
4dd6b2bfcSGreg Roach<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('admin-trees') => I18N::translate('Manage family trees'), $title]]) ?>
5dd6b2bfcSGreg Roach
6dd6b2bfcSGreg Roach<h1><?= $title ?></h1>
7dd6b2bfcSGreg Roach
8dd6b2bfcSGreg Roach<div class="alert alert-warning">
9cc13d6d8SGreg Roach    <?= /* 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())) ?>
10dd6b2bfcSGreg Roach</div>
11dd6b2bfcSGreg Roach
12*b7a63c6cSGreg Roach<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?')) ?>');">
13dd6b2bfcSGreg Roach    <input type="hidden" id="gedcom_filename" value="<?= e($default_gedcom_file) ?>">
14dd6b2bfcSGreg Roach    <?= csrf_field() ?>
15dd6b2bfcSGreg Roach
16dd6b2bfcSGreg Roach    <fieldset class="form-group">
17dd6b2bfcSGreg Roach        <div class="row">
18dd6b2bfcSGreg Roach            <legend class="col-form-label col-sm-3">
19dd6b2bfcSGreg Roach                <?= I18N::translate('Select a GEDCOM file to import') ?>
20dd6b2bfcSGreg Roach            </legend>
21dd6b2bfcSGreg Roach            <div class="col-sm-9">
22dd6b2bfcSGreg Roach                <div class="row form-group">
23dd6b2bfcSGreg Roach                    <label class="col-sm-3">
24dd6b2bfcSGreg Roach                        <input type="radio" name="source" id="import-computer" value="client" checked>
25dd6b2bfcSGreg Roach                        <?= I18N::translate('A file on your computer') ?>
26dd6b2bfcSGreg Roach                    </label>
27dd6b2bfcSGreg Roach                    <div class="col-sm-9">
28dd6b2bfcSGreg Roach                        <div class="btn btn-default">
29dd6b2bfcSGreg Roach                            <input type="file" class="form-control-file" name="tree_name" id="import-computer-file">
30dd6b2bfcSGreg Roach                        </div>
31dd6b2bfcSGreg Roach                    </div>
32dd6b2bfcSGreg Roach                </div>
33dd6b2bfcSGreg Roach                <div class="row">
34dd6b2bfcSGreg Roach                    <label class="col-sm-3">
35dd6b2bfcSGreg Roach                        <input type="radio" name="source" id="import-server" value="server">
36dd6b2bfcSGreg Roach                        <?= I18N::translate('A file on the server') ?>
37dd6b2bfcSGreg Roach                    </label>
38dd6b2bfcSGreg Roach                    <div class="col-sm-9">
39a3c95e78SGreg Roach                        <div class="input-group" dir="ltr">
40dd6b2bfcSGreg Roach                            <div class="input-group-prepend">
41a3c95e78SGreg Roach                                <span class="input-group-text" dir="ltr">
4208af4a8cSGreg Roach                                <?= e($data_folder) ?>
43dd6b2bfcSGreg Roach                                </span>
44dd6b2bfcSGreg Roach                            </div>
45a3c95e78SGreg Roach                            <select name="tree_name" class="form-control" dir="ltr" id="import-server-file">
46dd6b2bfcSGreg Roach                                <option value=""></option>
47dd6b2bfcSGreg Roach                                <?php foreach ($gedcom_files as $gedcom_file) : ?>
48dd6b2bfcSGreg Roach                                    <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>>
49dd6b2bfcSGreg Roach                                        <?= e($gedcom_file) ?>
50dd6b2bfcSGreg Roach                                    </option>
51dd6b2bfcSGreg Roach                                <?php endforeach ?>
52dd6b2bfcSGreg Roach                                <?php if (empty($gedcom_files)) : ?>
53dd6b2bfcSGreg Roach                                    <option disabled selected>
54dd6b2bfcSGreg Roach                                        <?= I18N::translate('No GEDCOM files found.') ?>
55dd6b2bfcSGreg Roach                                    </option>
56dd6b2bfcSGreg Roach                                <?php endif ?>
57dd6b2bfcSGreg Roach                            </select>
58dd6b2bfcSGreg Roach                        </div>
59dd6b2bfcSGreg Roach                    </div>
60dd6b2bfcSGreg Roach                </div>
61dd6b2bfcSGreg Roach            </div>
62dd6b2bfcSGreg Roach        </div>
63dd6b2bfcSGreg Roach    </fieldset>
64dd6b2bfcSGreg Roach
65dd6b2bfcSGreg Roach    <hr>
66dd6b2bfcSGreg Roach
67dd6b2bfcSGreg Roach    <fieldset class="form-group">
68dd6b2bfcSGreg Roach        <div class="row">
69dd6b2bfcSGreg Roach            <legend class="col-form-label col-sm-3">
70dd6b2bfcSGreg Roach                <?= I18N::translate('Import preferences') ?>
71dd6b2bfcSGreg Roach            </legend>
72dd6b2bfcSGreg Roach            <div class="col-sm-9">
73dd6b2bfcSGreg Roach                <label>
74dd6b2bfcSGreg Roach                    <input type="checkbox" name="keep_media" value="1" <?= $tree->getPreference('keep_media') ? 'checked' : '' ?>>
75dd6b2bfcSGreg Roach                    <?= /* I18N: A configuration setting */ I18N::translate('Keep media objects') ?>
76dd6b2bfcSGreg Roach                </label>
77dd6b2bfcSGreg Roach                <p class="small text-muted">
78dd6b2bfcSGreg Roach                    <?= 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.') ?>
79dd6b2bfcSGreg Roach                </p>
80dd6b2bfcSGreg Roach                <label>
81dd6b2bfcSGreg Roach                    <input type="checkbox" name="WORD_WRAPPED_NOTES" value="1" <?= $tree->getPreference('WORD_WRAPPED_NOTES') ? 'checked' : '' ?>>
82dd6b2bfcSGreg Roach                    <?= I18N::translate('Add spaces where long lines were wrapped') ?>
83dd6b2bfcSGreg Roach                </label>
84dd6b2bfcSGreg Roach                <p class="small text-muted">
85dd6b2bfcSGreg Roach                    <?= 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.') ?>
86dd6b2bfcSGreg Roach                </p>
87dd6b2bfcSGreg Roach                <label for="GEDCOM_MEDIA_PATH">
88dd6b2bfcSGreg Roach                    <?= /* 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') ?>
89dd6b2bfcSGreg Roach                </label>
90dd6b2bfcSGreg Roach                <input
91dd6b2bfcSGreg Roach                    class="form-control"
92dd6b2bfcSGreg Roach                    dir="ltr"
93dd6b2bfcSGreg Roach                    id="GEDCOM_MEDIA_PATH"
94dd6b2bfcSGreg Roach                    maxlength="255"
95dd6b2bfcSGreg Roach                    name="GEDCOM_MEDIA_PATH"
96dd6b2bfcSGreg Roach                    type="text"
97dd6b2bfcSGreg Roach                    value="<?= e($gedcom_media_path) ?>"
98dd6b2bfcSGreg Roach                >
99dd6b2bfcSGreg Roach                <p class="small text-muted">
100dd6b2bfcSGreg Roach                    <?= /* 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.') ?>
101dd6b2bfcSGreg Roach                    <?= /* 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>') ?>
102dd6b2bfcSGreg Roach                </p>
103dd6b2bfcSGreg Roach            </div>
104dd6b2bfcSGreg Roach        </div>
105dd6b2bfcSGreg Roach    </fieldset>
106dd6b2bfcSGreg Roach
107dd6b2bfcSGreg Roach    <div class="row form-group">
108dd6b2bfcSGreg Roach        <div class="offset-sm-3 col-sm-9">
109dd6b2bfcSGreg Roach            <button type="submit" class="btn btn-primary">
110dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */ I18N::translate('continue') ?>
111dd6b2bfcSGreg Roach            </button>
112dd6b2bfcSGreg Roach        </div>
113dd6b2bfcSGreg Roach    </div>
114dd6b2bfcSGreg Roach</form>
115dd6b2bfcSGreg Roach
116dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
117dd6b2bfcSGreg Roach<script>
118dd6b2bfcSGreg Roach  function checkGedcomImportForm (message) {
119dd6b2bfcSGreg Roach    var oldFile = $('#gedcom_filename').val();
120708b06c1SGreg Roach    var method = $('input[name=source]:checked').val();
121708b06c1SGreg Roach    var newFile = method === 'server' ? $('#import-server-file').val() : $('#import-computer-file').val();
122dd6b2bfcSGreg Roach
123dd6b2bfcSGreg Roach    // Some browsers include c:\fakepath\ in the filename.
124dd6b2bfcSGreg Roach    newFile = newFile.replace(/.*[/\\]/, '');
125dd6b2bfcSGreg Roach    if (newFile !== oldFile && oldFile !== '') {
126dd6b2bfcSGreg Roach      return window.confirm(message);
127dd6b2bfcSGreg Roach    } else {
128dd6b2bfcSGreg Roach      return true;
129dd6b2bfcSGreg Roach    }
130dd6b2bfcSGreg Roach  }
131dd6b2bfcSGreg Roach
132dd6b2bfcSGreg Roach  document.getElementById("import-computer-file").addEventListener("click", function () {
133dd6b2bfcSGreg Roach    document.getElementById("import-computer").checked = true;
134dd6b2bfcSGreg Roach  });
135dd6b2bfcSGreg Roach
136dd6b2bfcSGreg Roach  document.getElementById("import-server-file").addEventListener("focus", function () {
137dd6b2bfcSGreg Roach    document.getElementById("import-server").checked = true;
138dd6b2bfcSGreg Roach  });
139dd6b2bfcSGreg Roach</script>
140dd6b2bfcSGreg Roach<?php View::endpush() ?>
141