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