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