. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Algorithm\ConnectedComponent; use Fisharebest\Webtrees\Controller\PageController; define('WT_SCRIPT_NAME', 'admin_trees_unconnected.php'); require './includes/session.php'; $controller = new PageController; $controller ->restrictAccess(Auth::isManager($WT_TREE)) ->setPageTitle(I18N::translate('Find unrelated individuals') . ' — ' . $WT_TREE->getTitleHtml()) ->pageHeader(); $rows = Database::prepare( "SELECT l_from, l_to FROM `##link` WHERE l_file = :tree_id AND l_type IN ('FAMS', 'FAMC')" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $graph = array(); foreach ($rows as $row) { $graph[$row->l_from][$row->l_to] = 1; $graph[$row->l_to][$row->l_from] = 1; } $algorithm = new ConnectedComponent($graph); $components = $algorithm->findConnectedComponents(); $root = $controller->getSignificantIndividual(); $root_id = $root->getXref(); /** @var Individual[][] */ $individual_groups = array(); $group_number = 1; foreach ($components as $key => $component) { if (!in_array($root_id, $component)) { $individuals = array(); foreach ($component as $xref) { $individual = Individual::getInstance($xref, $WT_TREE); if ($individual instanceof Individual) { $individuals[] = $individual; } } $individual_groups[$group_number++] = $individuals; } } ?>
getFullName()) ?>