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