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