10c0910bfSGreg Roach<?php 2dd6b2bfcSGreg Roach 30c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 46fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ImportGedcomAction; 56fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees; 60c0910bfSGreg Roachuse Fisharebest\Webtrees\I18N; 71c6adce8SGreg Roachuse Fisharebest\Webtrees\Registry; 86fd01894SGreg Roachuse Fisharebest\Webtrees\Tree; 90c0910bfSGreg Roachuse Fisharebest\Webtrees\View; 106fd01894SGreg Roachuse Illuminate\Support\Collection; 116fd01894SGreg Roach 126fd01894SGreg Roach/** 136fd01894SGreg Roach * @var string $data_folder 146fd01894SGreg Roach * @var string $default_gedcom_file 1536779af1SGreg Roach * @var Collection<int,string> $gedcom_files 166fd01894SGreg Roach * @var string $gedcom_media_path 176fd01894SGreg Roach * @var string $title 186fd01894SGreg Roach * @var Tree $tree 196fd01894SGreg Roach */ 200c0910bfSGreg Roach 210c0910bfSGreg Roach?> 220c0910bfSGreg Roach 236fd01894SGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?> 24dd6b2bfcSGreg Roach 25dd6b2bfcSGreg Roach<h1><?= $title ?></h1> 26dd6b2bfcSGreg Roach 27dd6b2bfcSGreg Roach<div class="alert alert-warning"> 28cc13d6d8SGreg 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())) ?> 29dd6b2bfcSGreg Roach</div> 30dd6b2bfcSGreg Roach 316fd01894SGreg Roach<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?')) ?>');"> 32dd6b2bfcSGreg Roach <input type="hidden" id="gedcom_filename" value="<?= e($default_gedcom_file) ?>"> 33dd6b2bfcSGreg Roach <?= csrf_field() ?> 34dd6b2bfcSGreg Roach 351c6adce8SGreg Roach <h2><?= I18N::translate('Select a GEDCOM file to import') ?></h2> 361c6adce8SGreg Roach 37*9e3c2cf9SGreg Roach <div class="row mb-3"> 38dd6b2bfcSGreg Roach <label class="col-sm-3"> 39dd6b2bfcSGreg Roach <input type="radio" name="source" id="import-computer" value="client" checked> 40dd6b2bfcSGreg Roach <?= I18N::translate('A file on your computer') ?> 41dd6b2bfcSGreg Roach </label> 42dd6b2bfcSGreg Roach <div class="col-sm-9"> 43*9e3c2cf9SGreg Roach <input type="file" class="form-control" name="tree_name" id="import-computer-file"> 44dd6b2bfcSGreg Roach </div> 45dd6b2bfcSGreg Roach </div> 461c6adce8SGreg Roach 47dd6b2bfcSGreg Roach <div class="row"> 486fd01894SGreg Roach <label class="col-sm-3" for="import-server-file"> 49dd6b2bfcSGreg Roach <input type="radio" name="source" id="import-server" value="server"> 50dd6b2bfcSGreg Roach <?= I18N::translate('A file on the server') ?> 51dd6b2bfcSGreg Roach </label> 52dd6b2bfcSGreg Roach <div class="col-sm-9"> 53a3c95e78SGreg Roach <div class="input-group" dir="ltr"> 54a3c95e78SGreg Roach <span class="input-group-text" dir="ltr"> 5508af4a8cSGreg Roach <?= e($data_folder) ?> 56dd6b2bfcSGreg Roach </span> 57315eb316SGreg Roach 58a3c95e78SGreg Roach <select name="tree_name" class="form-control" dir="ltr" id="import-server-file"> 59027478c2SGreg Roach <option value=""> </option> 60dd6b2bfcSGreg Roach <?php foreach ($gedcom_files as $gedcom_file) : ?> 61dd6b2bfcSGreg Roach <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>> 62dd6b2bfcSGreg Roach <?= e($gedcom_file) ?> 63dd6b2bfcSGreg Roach </option> 64dd6b2bfcSGreg Roach <?php endforeach ?> 656fd01894SGreg Roach <?php if ($gedcom_files->isEmpty()) : ?> 66dd6b2bfcSGreg Roach <option disabled selected> 67dd6b2bfcSGreg Roach <?= I18N::translate('No GEDCOM files found.') ?> 68dd6b2bfcSGreg Roach </option> 69dd6b2bfcSGreg Roach <?php endif ?> 70dd6b2bfcSGreg Roach </select> 71dd6b2bfcSGreg Roach </div> 72dd6b2bfcSGreg Roach </div> 73dd6b2bfcSGreg Roach </div> 74dd6b2bfcSGreg Roach 75dd6b2bfcSGreg Roach <hr> 76dd6b2bfcSGreg Roach 771c6adce8SGreg Roach <h2><?= I18N::translate('Import preferences') ?></h2> 781c6adce8SGreg Roach 791c6adce8SGreg Roach <div class="row mb-3"> 801c6adce8SGreg Roach <label for="encoding" class="col-sm-3"> 811c6adce8SGreg Roach <?= I18N::translate('Character encoding') ?> 821c6adce8SGreg Roach </label> 831c6adce8SGreg Roach 84dd6b2bfcSGreg Roach <div class="col-sm-9"> 851c6adce8SGreg Roach <?= view('components/select', ['name' => 'encoding', 'selected' => '', 'options' => ['' => I18N::translate('automatic')] + Registry::encodingFactory()->list()]) ?> 861c6adce8SGreg Roach </div> 871c6adce8SGreg Roach </div> 881c6adce8SGreg Roach 891c6adce8SGreg Roach <div class="row mb-3"> 901c6adce8SGreg Roach <div class="col-sm-3"> 91dd6b2bfcSGreg Roach <?= /* I18N: A configuration setting */ I18N::translate('Keep media objects') ?> 921c6adce8SGreg Roach </div> 931c6adce8SGreg Roach 941c6adce8SGreg Roach <div class="col-sm-9"> 951c6adce8SGreg Roach <div class="form-check"> 961c6adce8SGreg Roach <input type="checkbox" class="form-check-input" name="keep_media" id="keep_media" value="1" <?= $tree->getPreference('keep_media') ? 'checked' : '' ?>> 971c6adce8SGreg Roach <label for="keep_media" class="form-check-label"> 98dd6b2bfcSGreg 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.') ?> 99dd6b2bfcSGreg Roach </label> 100315eb316SGreg Roach </div> 1011c6adce8SGreg Roach </div> 1021c6adce8SGreg Roach </div> 1031c6adce8SGreg Roach 1041c6adce8SGreg Roach <div class="row mb-3"> 1051c6adce8SGreg Roach <div class="col-sm-3"> 1061c6adce8SGreg Roach <?= I18N::translate('Add spaces where long lines were wrapped') ?> 1071c6adce8SGreg Roach </div> 1081c6adce8SGreg Roach 1091c6adce8SGreg Roach <div class="col-sm-9"> 1101c6adce8SGreg Roach <div class="form-check"> 1111c6adce8SGreg Roach <input type="checkbox" class="form-check-input" name="WORD_WRAPPED_NOTES" id="WORD_WRAPPED_NOTES" value="1" <?= $tree->getPreference('WORD_WRAPPED_NOTES') ? 'checked' : '' ?>> 1121c6adce8SGreg Roach <label for="WORD_WRAPPED_NOTES" class="form-check-label"> 1131c6adce8SGreg 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.') ?> 1141c6adce8SGreg Roach </label> 1151c6adce8SGreg Roach </div> 1161c6adce8SGreg Roach </div> 1171c6adce8SGreg Roach </div> 1181c6adce8SGreg Roach 1191c6adce8SGreg Roach <div class="row mb-3"> 1201c6adce8SGreg Roach <label for="GEDCOM_MEDIA_PATH" class="col-sm-3"> 121dd6b2bfcSGreg 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') ?> 122dd6b2bfcSGreg Roach </label> 1231c6adce8SGreg Roach 1241c6adce8SGreg Roach <div class="col-sm-9"> 1251c6adce8SGreg Roach <input class="form-control" dir="ltr" id="GEDCOM_MEDIA_PATH" maxlength="255" name="GEDCOM_MEDIA_PATH" type="text" value="<?= e($gedcom_media_path) ?>"> 126315eb316SGreg Roach <div class="form-text"> 127dd6b2bfcSGreg 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.') ?> 1281c6adce8SGreg 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>') ?> 129dd6b2bfcSGreg Roach </div> 130dd6b2bfcSGreg Roach </div> 1311c6adce8SGreg Roach </div> 132dd6b2bfcSGreg Roach 1331c6adce8SGreg Roach <hr> 1341c6adce8SGreg Roach 135dd6b2bfcSGreg Roach <button type="submit" class="btn btn-primary"> 136dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ I18N::translate('continue') ?> 137dd6b2bfcSGreg Roach </button> 138dd6b2bfcSGreg Roach</form> 139dd6b2bfcSGreg Roach 140dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 141dd6b2bfcSGreg Roach<script> 142dd6b2bfcSGreg Roach function checkGedcomImportForm (message) { 1436fd01894SGreg Roach let oldFile = $('#gedcom_filename').val(); 1446fd01894SGreg Roach let method = $('input[name=source]:checked').val(); 1456fd01894SGreg Roach let newFile = method === 'server' ? $('#import-server-file').val() : $('#import-computer-file').val(); 146dd6b2bfcSGreg Roach 147dd6b2bfcSGreg Roach // Some browsers include c:\fakepath\ in the filename. 148dd6b2bfcSGreg Roach newFile = newFile.replace(/.*[/\\]/, ''); 149dd6b2bfcSGreg Roach if (newFile !== oldFile && oldFile !== '') { 150dd6b2bfcSGreg Roach return window.confirm(message); 151dd6b2bfcSGreg Roach } else { 152dd6b2bfcSGreg Roach return true; 153dd6b2bfcSGreg Roach } 154dd6b2bfcSGreg Roach } 155dd6b2bfcSGreg Roach 156dd6b2bfcSGreg Roach document.getElementById("import-computer-file").addEventListener("click", function () { 157dd6b2bfcSGreg Roach document.getElementById("import-computer").checked = true; 158dd6b2bfcSGreg Roach }); 159dd6b2bfcSGreg Roach 160dd6b2bfcSGreg Roach document.getElementById("import-server-file").addEventListener("focus", function () { 161dd6b2bfcSGreg Roach document.getElementById("import-server").checked = true; 162dd6b2bfcSGreg Roach }); 163dd6b2bfcSGreg Roach</script> 164dd6b2bfcSGreg Roach<?php View::endpush() ?> 165