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