. */ namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Controller\PageController; use Fisharebest\Webtrees\Functions\Functions; /** @global Tree $WT_TREE */ global $WT_TREE; require 'includes/session.php'; $controller = new PageController; $controller ->addExternalJavascript(WT_ADMIN_JS_URL) ->restrictAccess(Auth::isAdmin() || Auth::isManager($WT_TREE)) ->setPageTitle(I18N::translate('Manage family trees')); // Show a reduced page when there are more than a certain number of trees $multiple_tree_threshold = (int) Site::getPreference('MULTIPLE_TREE_THRESHOLD', '500'); // Note that glob() returns false instead of an empty array when open_basedir_restriction // is in force and no files are found. See PHP bug #47358. if (defined('GLOB_BRACE')) { $gedcom_files = glob(WT_DATA_DIR . '*.{ged,Ged,GED}', GLOB_NOSORT | GLOB_BRACE) ?: []; } else { $gedcom_files = array_merge( glob(WT_DATA_DIR . '*.ged', GLOB_NOSORT) ?: [], glob(WT_DATA_DIR . '*.Ged', GLOB_NOSORT) ?: [], glob(WT_DATA_DIR . '*.GED', GLOB_NOSORT) ?: [] ); } // Process POST actions switch (Filter::post('action')) { case 'delete': $gedcom_id = Filter::postInteger('gedcom_id'); if (Filter::checkCsrf() && $gedcom_id) { $tree = Tree::findById($gedcom_id); FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); $tree->delete(); } header('Location: admin_trees_manage.php'); return; case 'setdefault': if (Filter::checkCsrf()) { Site::setPreference('DEFAULT_GEDCOM', Filter::post('ged')); FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success'); } header('Location: admin_trees_manage.php'); return; case 'new_tree': $basename = basename(Filter::post('tree_name')); $tree_title = Filter::post('tree_title'); if (Filter::checkCsrf() && $basename && $tree_title) { if (Tree::findByName($basename)) { FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” already exists.', Html::escape($basename)), 'danger'); } else { Tree::create($basename, $tree_title); FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ I18N::translate('The family tree “%s” has been created.', Html::escape($basename)), 'success'); } } header('Location: admin_trees_manage.php?ged=' . rawurlencode($basename)); return; case 'replace_upload': $gedcom_id = Filter::postInteger('gedcom_id'); $keep_media = Filter::post('keep_media', '1', '0'); $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); $tree = Tree::findById($gedcom_id); if (Filter::checkCsrf() && $tree) { $tree->setPreference('keep_media', $keep_media); $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); if (isset($_FILES['tree_name'])) { if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); } else { FlashMessages::addMessage(Functions::fileUploadErrorText($_FILES['tree_name']['error']), 'danger'); } } else { FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); } } header('Location: admin_trees_manage.php'); return; case 'replace_import': $basename = basename(Filter::post('tree_name')); $gedcom_id = Filter::postInteger('gedcom_id'); $keep_media = Filter::post('keep_media', '1', '0'); $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); $tree = Tree::findById($gedcom_id); if (Filter::checkCsrf() && $tree) { $tree->setPreference('keep_media', $keep_media); $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); if ($basename) { $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); } else { FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); } } header('Location: admin_trees_manage.php'); return; case 'synchronize': if (Filter::checkCsrf()) { $basenames = []; foreach ($gedcom_files as $gedcom_file) { $filemtime = filemtime($gedcom_file); // Only import files that have changed $basename = basename($gedcom_file); $basenames[] = $basename; $tree = Tree::findByName($basename); if (!$tree) { $tree = Tree::create($basename, $basename); } if ($tree->getPreference('filemtime') != $filemtime) { $tree->importGedcomFile($gedcom_file, $basename); $tree->setPreference('filemtime', $filemtime); FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Html::escape($basename)), 'success'); } } foreach (Tree::getAll() as $tree) { if (!in_array($tree->getName(), $basenames)) { FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); $tree->delete(); } } } header('Location: admin_trees_manage.php'); return; } $default_tree_title = /* I18N: Default name for a new tree */ I18N::translate('My family tree'); $default_tree_name = 'tree'; $default_tree_number = 1; $existing_trees = Tree::getNameList(); while (array_key_exists($default_tree_name . $default_tree_number, $existing_trees)) { $default_tree_number++; } $default_tree_name .= $default_tree_number; // Process GET actions switch (Filter::get('action')) { case 'importform': $controller ->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Import a GEDCOM file')) ->pageHeader(); echo Bootstrap4::breadcrumbs([ 'admin.php' => I18N::translate('Control panel'), 'admin_trees_manage.php' => I18N::translate('Manage family trees'), ], $controller->getPageTitle()); ?>
= /* 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.', $tree->getTitleHtml()) ?>
pageHeader(); $all_trees = Tree::getAll(); // On sites with hundreds or thousands of trees, this page becomes very large. // Just show the current tree, the default tree, and unimported trees if (count($all_trees) >= $multiple_tree_threshold) { $all_trees = array_filter($all_trees, function (Tree $x) use ($WT_TREE) { return $x->getPreference('imported') === '0' || $WT_TREE->getTreeId() === $x->getTreeId() || $x->getName() === Site::getPreference('DEFAULT_GEDCOM'); }); } // List the gedcoms available to this user echo Bootstrap4::breadcrumbs([ 'admin.php' => I18N::translate('Control panel'), ], $controller->getPageTitle()); ?>= I18N::translate('The PhpGedView to webtrees wizard is an automated process to assist administrators make the move from a PhpGedView installation to a new webtrees one. It will transfer all PhpGedView GEDCOM and other database information directly to your new webtrees database. The following requirements are necessary:') ?>
= I18N::translate('Important note: The transfer wizard is not able to assist with moving media items. You will need to set up and move or copy your media configuration and objects separately after the transfer wizard is finished.') ?>
= I18N::translate('PhpGedView to webtrees transfer wizard') ?>
= I18N::translate('Create, update, and delete a family tree for every GEDCOM file in the data folder.') ?>