.
*/
namespace Fisharebest\Webtrees;
/**
* Defined in session.php
*
* @global Tree $WT_TREE
*/
global $WT_TREE;
use Fisharebest\Webtrees\Controller\RelationshipController;
use Fisharebest\Webtrees\Functions\Functions;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\Module\RelationshipsChartModule;
define('WT_SCRIPT_NAME', 'relationship.php');
require './includes/session.php';
$max_recursion = $WT_TREE->getPreference('RELATIONSHIP_RECURSION', RelationshipsChartModule::DEFAULT_RECURSION);
$ancestors_only = $WT_TREE->getPreference('RELATIONSHIP_ANCESTORS', RelationshipsChartModule::DEFAULT_ANCESTORS);
$controller = new RelationshipController;
$pid1 = Filter::get('pid1', WT_REGEX_XREF);
$pid2 = Filter::get('pid2', WT_REGEX_XREF);
$show_full = Filter::getInteger('show_full', 0, 1, $WT_TREE->getPreference('PEDIGREE_FULL_DETAILS'));
$recursion = Filter::getInteger('recursion', 0, $max_recursion, 0);
$ancestors = Filter::getInteger('ancestors', 0, 1, 0);
$person1 = Individual::getInstance($pid1, $WT_TREE);
$person2 = Individual::getInstance($pid2, $WT_TREE);
$controller
->restrictAccess(Module::isActiveChart($WT_TREE, 'relationships_chart'))
->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)
->addInlineJavascript('autocomplete();');
if ($person1 && $person2) {
$controller
->setPageTitle(I18N::translate(/* I18N: %s are individual’s names */ 'Relationships between %1$s and %2$s', $person1->getFullName(), $person2->getFullName()))
->pageHeader();
$paths = $controller->calculateRelationships($person1, $person2, $recursion, (bool) $ancestors);
} else {
$controller
->setPageTitle(I18N::translate('Relationships'))
->pageHeader();
$paths = array();
}
?>
getPageTitle() ?>
';
$diagonal1 = Theme::theme()->parameter('image-dline');
$diagonal2 = Theme::theme()->parameter('image-dline2');
} else {
$horizontal_arrow = '
';
$diagonal1 = Theme::theme()->parameter('image-dline2');
$diagonal2 = Theme::theme()->parameter('image-dline');
}
$up_arrow = ' ';
$down_arrow = ' ';
$num_paths = 0;
foreach ($paths as $path) {
// Extract the relationship names between pairs of individuals
$relationships = $controller->oldStyleRelationshipPath($path);
if (empty($relationships)) {
// Cannot see one of the families/individuals, due to privacy;
continue;
}
echo '', I18N::translate('Relationship: %s', Functions::getRelationshipNameFromPath(implode('', $relationships), $person1, $person2)), '
';
$num_paths++;
// Use a table/grid for layout.
$table = array();
// Current position in the grid.
$x = 0;
$y = 0;
// Extent of the grid.
$min_y = 0;
$max_y = 0;
$max_x = 0;
// For each node in the path.
foreach ($path as $n => $xref) {
if ($n % 2 === 1) {
switch ($relationships[$n]) {
case 'hus':
case 'wif':
case 'spo':
case 'bro':
case 'sis':
case 'sib':
$table[$x + 1][$y] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '
' . $horizontal_arrow . '
';
$x += 2;
break;
case 'son':
case 'dau':
case 'chi':
if ($n > 2 && preg_match('/fat|mot|par/', $relationships[$n - 2])) {
$table[$x + 1][$y - 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '
' . $down_arrow . '
';
$x += 2;
} else {
$table[$x][$y - 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '
' . $down_arrow . '
';
}
$y -= 2;
break;
case 'fat':
case 'mot':
case 'par':
if ($n > 2 && preg_match('/son|dau|chi/', $relationships[$n - 2])) {
$table[$x + 1][$y + 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '
' . $up_arrow . '
';
$x += 2;
} else {
$table[$x][$y + 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $WT_TREE), Individual::getInstance($path[$n + 1], $WT_TREE)) . '
' . $up_arrow . '
';
}
$y += 2;
break;
}
$max_x = max($max_x, $x);
$min_y = min($min_y, $y);
$max_y = max($max_y, $y);
} else {
$individual = Individual::getInstance($xref, $WT_TREE);
ob_start();
FunctionsPrint::printPedigreePerson($individual, $show_full);
$table[$x][$y] = ob_get_clean();
}
}
echo '';
for ($y = $max_y; $y >= $min_y; --$y) {
echo '';
for ($x = 0; $x <= $max_x; ++$x) {
echo '';
if (isset($table[$x][$y])) {
echo $table[$x][$y];
}
echo ' | ';
}
echo '
';
}
echo '
';
}
if (!$num_paths) {
echo '', I18N::translate('No link between the two individuals could be found.'), '
';
}
}