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