10c0910bfSGreg Roach<?php 2dd6b2bfcSGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg Roach 50c0910bfSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 66fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ImportGedcomAction; 76fd01894SGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees; 80c0910bfSGreg Roachuse Fisharebest\Webtrees\I18N; 91c6adce8SGreg Roachuse Fisharebest\Webtrees\Registry; 106fd01894SGreg Roachuse Fisharebest\Webtrees\Tree; 110c0910bfSGreg Roachuse Fisharebest\Webtrees\View; 126fd01894SGreg Roachuse Illuminate\Support\Collection; 136fd01894SGreg Roach 146fd01894SGreg Roach/** 156fd01894SGreg Roach * @var string $data_folder 166fd01894SGreg Roach * @var string $default_gedcom_file 1736779af1SGreg Roach * @var Collection<int,string> $gedcom_files 186fd01894SGreg Roach * @var string $gedcom_media_path 196fd01894SGreg Roach * @var string $title 206fd01894SGreg Roach * @var Tree $tree 216fd01894SGreg Roach */ 220c0910bfSGreg Roach 230c0910bfSGreg Roach?> 240c0910bfSGreg Roach 256fd01894SGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), route(ManageTrees::class, ['tree' => $tree->name()]) => I18N::translate('Manage family trees'), $title]]) ?> 26dd6b2bfcSGreg Roach 27dd6b2bfcSGreg Roach<h1><?= $title ?></h1> 28dd6b2bfcSGreg Roach 29dd6b2bfcSGreg Roach<div class="alert alert-warning"> 30cc13d6d8SGreg 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())) ?> 31dd6b2bfcSGreg Roach</div> 32dd6b2bfcSGreg Roach 33*6c5ec5a2SGreg Roach<form method="post" action="<?= e(route(ImportGedcomAction::class, ['tree' => $tree->name()])) ?>" enctype="multipart/form-data" onsubmit="return checkGedcomImportForm('<?= e(I18N::translate('You have selected a GEDCOM file with a different name. Is this correct?')) ?>');"> 34dd6b2bfcSGreg Roach <input type="hidden" id="gedcom_filename" value="<?= e($default_gedcom_file) ?>"> 35dd6b2bfcSGreg Roach 361c6adce8SGreg Roach <h2><?= I18N::translate('Select a GEDCOM file to import') ?></h2> 371c6adce8SGreg Roach 389e3c2cf9SGreg Roach <div class="row mb-3"> 39*6c5ec5a2SGreg Roach <label class="col-form-label col-sm-4"> 40*6c5ec5a2SGreg Roach <input type="radio" name="source" id="import-client" value="client" checked> 41dd6b2bfcSGreg Roach <?= I18N::translate('A file on your computer') ?> 42dd6b2bfcSGreg Roach </label> 43*6c5ec5a2SGreg Roach <div class="col-sm-8"> 44*6c5ec5a2SGreg Roach <input id="import-client-file" type="file" name="client_file" class="form-control"> 45dd6b2bfcSGreg Roach </div> 46dd6b2bfcSGreg Roach </div> 471c6adce8SGreg Roach 48*6c5ec5a2SGreg Roach <div class="row mb-3"> 49*6c5ec5a2SGreg Roach <label class="col-form-label col-sm-4"> 50dd6b2bfcSGreg Roach <input type="radio" name="source" id="import-server" value="server"> 51dd6b2bfcSGreg Roach <?= I18N::translate('A file on the server') ?> 52dd6b2bfcSGreg Roach </label> 53*6c5ec5a2SGreg Roach <div class="col-sm-8"> 54a3c95e78SGreg Roach <div class="input-group" dir="ltr"> 55a3c95e78SGreg Roach <span class="input-group-text" dir="ltr"> 5608af4a8cSGreg Roach <?= e($data_folder) ?> 57dd6b2bfcSGreg Roach </span> 58315eb316SGreg Roach 59*6c5ec5a2SGreg Roach <select name="server_file" class="form-select" dir="ltr" id="import-server-file"> 60*6c5ec5a2SGreg Roach <option selected="selected" value=""> </option> 61dd6b2bfcSGreg Roach <?php foreach ($gedcom_files as $gedcom_file) : ?> 62dd6b2bfcSGreg Roach <option value="<?= e($gedcom_file) ?>" <?= $gedcom_file === $default_gedcom_file ? 'selected' : '' ?>> 63dd6b2bfcSGreg Roach <?= e($gedcom_file) ?> 64dd6b2bfcSGreg Roach </option> 65dd6b2bfcSGreg Roach <?php endforeach ?> 666fd01894SGreg Roach <?php if ($gedcom_files->isEmpty()) : ?> 67dd6b2bfcSGreg Roach <option disabled selected> 68dd6b2bfcSGreg Roach <?= I18N::translate('No GEDCOM files found.') ?> 69dd6b2bfcSGreg Roach </option> 70dd6b2bfcSGreg Roach <?php endif ?> 71dd6b2bfcSGreg Roach </select> 72dd6b2bfcSGreg Roach </div> 73dd6b2bfcSGreg Roach </div> 74dd6b2bfcSGreg Roach </div> 75dd6b2bfcSGreg Roach 76dd6b2bfcSGreg Roach <hr> 77dd6b2bfcSGreg Roach 781c6adce8SGreg Roach <h2><?= I18N::translate('Import preferences') ?></h2> 791c6adce8SGreg Roach 801c6adce8SGreg Roach <div class="row mb-3"> 811c6adce8SGreg Roach <label for="encoding" class="col-sm-3"> 821c6adce8SGreg Roach <?= I18N::translate('Character encoding') ?> 831c6adce8SGreg Roach </label> 841c6adce8SGreg Roach 85dd6b2bfcSGreg Roach <div class="col-sm-9"> 861c6adce8SGreg Roach <?= view('components/select', ['name' => 'encoding', 'selected' => '', 'options' => ['' => I18N::translate('automatic')] + Registry::encodingFactory()->list()]) ?> 871c6adce8SGreg Roach </div> 881c6adce8SGreg Roach </div> 891c6adce8SGreg Roach 901c6adce8SGreg Roach <div class="row mb-3"> 911c6adce8SGreg Roach <div class="col-sm-3"> 92dd6b2bfcSGreg Roach <?= /* I18N: A configuration setting */ I18N::translate('Keep media objects') ?> 931c6adce8SGreg Roach </div> 941c6adce8SGreg Roach 951c6adce8SGreg Roach <div class="col-sm-9"> 961c6adce8SGreg Roach <div class="form-check"> 971c6adce8SGreg Roach <input type="checkbox" class="form-check-input" name="keep_media" id="keep_media" value="1" <?= $tree->getPreference('keep_media') ? 'checked' : '' ?>> 981c6adce8SGreg Roach <label for="keep_media" class="form-check-label"> 99dd6b2bfcSGreg 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.') ?> 100dd6b2bfcSGreg Roach </label> 101315eb316SGreg Roach </div> 1021c6adce8SGreg Roach </div> 1031c6adce8SGreg Roach </div> 1041c6adce8SGreg Roach 1051c6adce8SGreg Roach <div class="row mb-3"> 1061c6adce8SGreg Roach <div class="col-sm-3"> 1071c6adce8SGreg Roach <?= I18N::translate('Add spaces where long lines were wrapped') ?> 1081c6adce8SGreg Roach </div> 1091c6adce8SGreg Roach 1101c6adce8SGreg Roach <div class="col-sm-9"> 1111c6adce8SGreg Roach <div class="form-check"> 1121c6adce8SGreg Roach <input type="checkbox" class="form-check-input" name="WORD_WRAPPED_NOTES" id="WORD_WRAPPED_NOTES" value="1" <?= $tree->getPreference('WORD_WRAPPED_NOTES') ? 'checked' : '' ?>> 1131c6adce8SGreg Roach <label for="WORD_WRAPPED_NOTES" class="form-check-label"> 1141c6adce8SGreg 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.') ?> 1151c6adce8SGreg Roach </label> 1161c6adce8SGreg Roach </div> 1171c6adce8SGreg Roach </div> 1181c6adce8SGreg Roach </div> 1191c6adce8SGreg Roach 1201c6adce8SGreg Roach <div class="row mb-3"> 1211c6adce8SGreg Roach <label for="GEDCOM_MEDIA_PATH" class="col-sm-3"> 122dd6b2bfcSGreg 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') ?> 123dd6b2bfcSGreg Roach </label> 1241c6adce8SGreg Roach 1251c6adce8SGreg Roach <div class="col-sm-9"> 1261c6adce8SGreg Roach <input class="form-control" dir="ltr" id="GEDCOM_MEDIA_PATH" maxlength="255" name="GEDCOM_MEDIA_PATH" type="text" value="<?= e($gedcom_media_path) ?>"> 127315eb316SGreg Roach <div class="form-text"> 128dd6b2bfcSGreg 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.') ?> 1291c6adce8SGreg 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>') ?> 130dd6b2bfcSGreg Roach </div> 131dd6b2bfcSGreg Roach </div> 1321c6adce8SGreg Roach </div> 133dd6b2bfcSGreg Roach 1341c6adce8SGreg Roach <hr> 1351c6adce8SGreg Roach 136dd6b2bfcSGreg Roach <button type="submit" class="btn btn-primary"> 137dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ I18N::translate('continue') ?> 138dd6b2bfcSGreg Roach </button> 13981443e3cSGreg Roach 14081443e3cSGreg Roach <?= csrf_field() ?> 141dd6b2bfcSGreg Roach</form> 142dd6b2bfcSGreg Roach 143dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 144dd6b2bfcSGreg Roach<script> 145dd6b2bfcSGreg Roach function checkGedcomImportForm (message) { 1466fd01894SGreg Roach let oldFile = $('#gedcom_filename').val(); 1476fd01894SGreg Roach let method = $('input[name=source]:checked').val(); 148*6c5ec5a2SGreg Roach let newFile = method === 'server' ? $('#import-server-file').val() : $('#import-client-file').val(); 149dd6b2bfcSGreg Roach 150dd6b2bfcSGreg Roach // Some browsers include c:\fakepath\ in the filename. 151dd6b2bfcSGreg Roach newFile = newFile.replace(/.*[/\\]/, ''); 152dd6b2bfcSGreg Roach if (newFile !== oldFile && oldFile !== '') { 153dd6b2bfcSGreg Roach return window.confirm(message); 154dd6b2bfcSGreg Roach } else { 155dd6b2bfcSGreg Roach return true; 156dd6b2bfcSGreg Roach } 157dd6b2bfcSGreg Roach } 158dd6b2bfcSGreg Roach 159*6c5ec5a2SGreg Roach document.getElementById('import-client-file').addEventListener('focus', function () { 160*6c5ec5a2SGreg Roach document.getElementById('import-client').checked = true; 161dd6b2bfcSGreg Roach }); 162dd6b2bfcSGreg Roach 163*6c5ec5a2SGreg Roach document.getElementById('import-server-file').addEventListener('focus', function () { 164*6c5ec5a2SGreg Roach document.getElementById('import-server').checked = true; 165dd6b2bfcSGreg Roach }); 166dd6b2bfcSGreg Roach</script> 167dd6b2bfcSGreg Roach<?php View::endpush() ?> 168