1<?php 2 3use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 4use Fisharebest\Webtrees\Http\RequestHandlers\ImportGedcomAction; 5use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees; 6use Fisharebest\Webtrees\I18N; 7use Fisharebest\Webtrees\Registry; 8use Fisharebest\Webtrees\Tree; 9use Fisharebest\Webtrees\View; 10use Illuminate\Support\Collection; 11 12/** 13 * @var string $data_folder 14 * @var string $default_gedcom_file 15 * @var Collection<int,string> $gedcom_files 16 * @var string $gedcom_media_path 17 * @var string $title 18 * @var Tree $tree 19 */ 20 21?> 22 23<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?> 24 25<h1><?= $title ?></h1> 26 27<div class="alert alert-warning"> 28 <?= /* 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())) ?> 29</div> 30 31<form method="post" action="<?= e(route(ImportGedcomAction::class, ['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?')) ?>');"> 32 <input type="hidden" id="gedcom_filename" value="<?= e($default_gedcom_file) ?>"> 33 34 <h2><?= I18N::translate('Select a GEDCOM file to import') ?></h2> 35 36 <div class="row mb-3"> 37 <label class="col-sm-3"> 38 <input type="radio" name="source" id="import-computer" value="client" checked> 39 <?= I18N::translate('A file on your computer') ?> 40 </label> 41 <div class="col-sm-9"> 42 <input type="file" class="form-control" name="tree_name" id="import-computer-file"> 43 </div> 44 </div> 45 46 <div class="row"> 47 <label class="col-sm-3" for="import-server-file"> 48 <input type="radio" name="source" id="import-server" value="server"> 49 <?= I18N::translate('A file on the server') ?> 50 </label> 51 <div class="col-sm-9"> 52 <div class="input-group" dir="ltr"> 53 <span class="input-group-text" dir="ltr"> 54 <?= e($data_folder) ?> 55 </span> 56 57 <select name="tree_name" class="form-select" dir="ltr" id="import-server-file"> 58 <option value=""> </option> 59 <?php foreach ($gedcom_files as $gedcom_file) : ?> 60 <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>> 61 <?= e($gedcom_file) ?> 62 </option> 63 <?php endforeach ?> 64 <?php if ($gedcom_files->isEmpty()) : ?> 65 <option disabled selected> 66 <?= I18N::translate('No GEDCOM files found.') ?> 67 </option> 68 <?php endif ?> 69 </select> 70 </div> 71 </div> 72 </div> 73 74 <hr> 75 76 <h2><?= I18N::translate('Import preferences') ?></h2> 77 78 <div class="row mb-3"> 79 <label for="encoding" class="col-sm-3"> 80 <?= I18N::translate('Character encoding') ?> 81 </label> 82 83 <div class="col-sm-9"> 84 <?= view('components/select', ['name' => 'encoding', 'selected' => '', 'options' => ['' => I18N::translate('automatic')] + Registry::encodingFactory()->list()]) ?> 85 </div> 86 </div> 87 88 <div class="row mb-3"> 89 <div class="col-sm-3"> 90 <?= /* I18N: A configuration setting */ I18N::translate('Keep media objects') ?> 91 </div> 92 93 <div class="col-sm-9"> 94 <div class="form-check"> 95 <input type="checkbox" class="form-check-input" name="keep_media" id="keep_media" value="1" <?= $tree->getPreference('keep_media') ? 'checked' : '' ?>> 96 <label for="keep_media" class="form-check-label"> 97 <?= 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.') ?> 98 </label> 99 </div> 100 </div> 101 </div> 102 103 <div class="row mb-3"> 104 <div class="col-sm-3"> 105 <?= I18N::translate('Add spaces where long lines were wrapped') ?> 106 </div> 107 108 <div class="col-sm-9"> 109 <div class="form-check"> 110 <input type="checkbox" class="form-check-input" name="WORD_WRAPPED_NOTES" id="WORD_WRAPPED_NOTES" value="1" <?= $tree->getPreference('WORD_WRAPPED_NOTES') ? 'checked' : '' ?>> 111 <label for="WORD_WRAPPED_NOTES" class="form-check-label"> 112 <?= 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.') ?> 113 </label> 114 </div> 115 </div> 116 </div> 117 118 <div class="row mb-3"> 119 <label for="GEDCOM_MEDIA_PATH" class="col-sm-3"> 120 <?= /* 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') ?> 121 </label> 122 123 <div class="col-sm-9"> 124 <input class="form-control" dir="ltr" id="GEDCOM_MEDIA_PATH" maxlength="255" name="GEDCOM_MEDIA_PATH" type="text" value="<?= e($gedcom_media_path) ?>"> 125 <div class="form-text"> 126 <?= /* 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.') ?> 127 <?= /* 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>') ?> 128 </div> 129 </div> 130 </div> 131 132 <hr> 133 134 <button type="submit" class="btn btn-primary"> 135 <?= /* I18N: A button label. */ I18N::translate('continue') ?> 136 </button> 137 138 <?= csrf_field() ?> 139</form> 140 141<?php View::push('javascript') ?> 142<script> 143 function checkGedcomImportForm (message) { 144 let oldFile = $('#gedcom_filename').val(); 145 let method = $('input[name=source]:checked').val(); 146 let newFile = method === 'server' ? $('#import-server-file').val() : $('#import-computer-file').val(); 147 148 // Some browsers include c:\fakepath\ in the filename. 149 newFile = newFile.replace(/.*[/\\]/, ''); 150 if (newFile !== oldFile && oldFile !== '') { 151 return window.confirm(message); 152 } else { 153 return true; 154 } 155 } 156 157 document.getElementById("import-computer-file").addEventListener("click", function () { 158 document.getElementById("import-computer").checked = true; 159 }); 160 161 document.getElementById("import-server-file").addEventListener("focus", function () { 162 document.getElementById("import-server").checked = true; 163 }); 164</script> 165<?php View::endpush() ?> 166