restrictAccess(Auth::isManager()) ->setPageTitle(WT_I18N::translate('Manage family trees')); $gedcom_files = glob(WT_DATA_DIR . '*.{ged,Ged,GED}', GLOB_NOSORT | GLOB_BRACE); // Process POST actions switch (WT_Filter::post('action')) { case 'delete': $gedcom_id = WT_Filter::postInteger('gedcom_id'); if (WT_Filter::checkCsrf() && $gedcom_id) { $tree = WT_Tree::get($gedcom_id); WT_FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ WT_I18N::translate('The family tree “%s” has been deleted.', $tree->titleHtml()), 'success'); $tree->delete(); } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'setdefault': if (WT_Filter::checkCsrf()) { WT_Site::setPreference('DEFAULT_GEDCOM', WT_Filter::post('ged')); WT_FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ WT_I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->titleHtml()), 'success'); } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'new_tree': $basename = basename(WT_Filter::post('tree_name')); $tree_title = WT_Filter::post('tree_title'); if (WT_Filter::checkCsrf() && $basename && $tree_title) { if (WT_Tree::getIdFromName($basename)) { WT_FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ WT_I18N::translate('The family tree “%s” already exists.', WT_Filter::escapeHtml($basename)), 'danger'); } else { WT_Tree::create($basename, $tree_title); WT_FlashMessages::addMessage(/* I18N: %s is the name of a family tree */ WT_I18N::translate('The family tree “%s” has been created.', WT_Filter::escapeHtml($basename)), 'success'); } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . $basename); return; case 'replace_upload': $gedcom_id = WT_Filter::postInteger('gedcom_id'); $keep_media = WT_Filter::postBool('keep_media'); $tree = WT_Tree::get($gedcom_id); if (WT_Filter::checkCsrf() && $tree) { foreach ($_FILES as $FILE) { if ($FILE['error'] == 0 && is_readable($FILE['tmp_name'])) { $tree->importGedcomFile($FILE['tmp_name'], $FILE['name'], $keep_media); } } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'replace_import': $basename = basename(WT_Filter::post('tree_name')); $gedcom_id = WT_Filter::postInteger('gedcom_id'); $keep_media = WT_Filter::postBool('keep_media'); $tree = WT_Tree::get($gedcom_id); if (WT_Filter::checkCsrf() && $tree && $basename) { $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename, $keep_media); } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'bulk-import': if (WT_Filter::checkCsrf()) { $tree_names = WT_Tree::getNameList(); $basenames = array(); foreach ($gedcom_files as $gedcom_file) { $filemtime = filemtime($gedcom_file); // Only import files that have changed $basename = basename($gedcom_file); $basenames[] = $basename; $tree = WT_Tree::create($basename, $basename); if ($tree->getPreference('filemtime') != $filemtime) { $tree->importGedcomFile($gedcom_file, $basename, false); $tree->setPreference('filemtime', $filemtime); WT_FlashMessages::addMessage(WT_I18N::translate('The GEDCOM file “%s” has been imported.', WT_Filter::escapeHtml($basename)), 'success'); } } foreach (WT_Tree::getAll() as $tree) { if (!in_array($tree->name(), $basenames)) { WT_FlashMessages::addMessage(WT_I18N::translate('The family tree “%s” has been deleted.', $tree->titleHtml()), 'success'); $tree->delete(); } } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; } $default_tree_title = /* I18N: Default name for a new tree */ WT_I18N::translate('My family tree'); $default_tree_name = 'tree'; $default_tree_number = 1; $existing_trees = WT_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 (WT_Filter::get('action')) { case 'uploadform': case 'importform': if (WT_Filter::get('action') === 'uploadform') { $controller->setPageTitle(WT_I18N::translate('Upload family tree')); } else { $controller->setPageTitle(WT_I18N::translate('Import family tree')); } $controller->pageHeader(); ?>

getPageTitle(); ?>

', /* I18N: %s is the name of a family tree */ WT_I18N::translate('This will delete all the genealogical data from “%s” and replace it with data from another GEDCOM file.', $tree->titleHtml()), '

'; // the javascript in the next line strips any path associated with the file before comparing it to the current GEDCOM name (both Chrome and IE8 include c:\fakepath\ in the filename). $previous_gedcom_filename = $tree->getPreference('gedcom_filename'); echo '
'; echo ''; echo WT_Filter::getCsrf(); if (WT_Filter::get('action') == 'uploadform') { echo ''; echo ''; } else { echo ''; $d = opendir(WT_DATA_DIR); $files = array(); while (($f = readdir($d)) !== false) { if (!is_dir(WT_DATA_DIR . $f) && is_readable(WT_DATA_DIR . $f)) { $fp = fopen(WT_DATA_DIR . $f, 'rb'); $header = fread($fp, 64); fclose($fp); if (preg_match('/^(' . WT_UTF8_BOM . ')?0 *HEAD/', $header)) { $files[] = $f; } } } if ($files) { sort($files); echo WT_DATA_DIR, ''; } else { echo '

', /* I18N: %s is the name of a folder */ WT_I18N::translate('No GEDCOM files found. You need to copy files to the “%s” folder on your server.', WT_DATA_DIR); echo '

'; return; } } echo '

'; echo WT_I18N::translate('If you have created media objects in webtrees, and have edited your gedcom off-line using a program that deletes media objects, then check this box to merge the current media objects with the new GEDCOM file.'); echo '

'; echo ''; return; } if (!WT_Tree::getAll()) { WT_FlashMessages::addMessage(WT_I18N::translate('You need to create a family tree.'), 'info'); } $controller->pageHeader(); // List the gedcoms available to this user ?>

getPageTitle(); ?>

execute(array($tree->id()))->fetchOne(); if ($importing) { ?>
addInlineJavascript( 'jQuery("#import' . $tree->id() . '").load("import.php?gedcom_id=' . $tree->id() . '");' ); } ?>
?ged=

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.'); ?>

= 25): ?>