.
*/
namespace Fisharebest\Webtrees;
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;
require 'includes/session.php';
$controller = new RelationshipController;
$max_recursion = (int) $controller->tree()->getPreference('RELATIONSHIP_RECURSION', RelationshipsChartModule::DEFAULT_RECURSION);
$ancestors_only = $controller->tree()->getPreference('RELATIONSHIP_ANCESTORS', RelationshipsChartModule::DEFAULT_ANCESTORS);
$pid1 = Filter::get('pid1', WT_REGEX_XREF);
$pid2 = Filter::get('pid2', WT_REGEX_XREF);
$recursion = Filter::getInteger('recursion', 0, $max_recursion, 0);
$ancestors = Filter::get('ancestors', '[01]', '0');
$person1 = Individual::getInstance($pid1, $controller->tree());
$person2 = Individual::getInstance($pid2, $controller->tree());
$controller->restrictAccess(Module::isActiveChart($controller->tree(), 'relationships_chart'));
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 = [];
}
?>
= $controller->getPageTitle() ?>
parameter('image-dline');
$diagonal2 = Theme::theme()->parameter('image-dline2');
} else {
$diagonal1 = Theme::theme()->parameter('image-dline2');
$diagonal2 = Theme::theme()->parameter('image-dline');
}
$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 = [];
// 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], $controller->tree()), Individual::getInstance($path[$n + 1], $controller->tree())) . '
' . FontAwesome::decorativeIcon('arrow-end') . '
';
$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], $controller->tree()), Individual::getInstance($path[$n + 1], $controller->tree())) . '
' . FontAwesome::decorativeIcon('arrow-down') . '
';
$x += 2;
} else {
$table[$x][$y - 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $controller->tree()), Individual::getInstance($path[$n + 1], $controller->tree())) . '
' . FontAwesome::decorativeIcon('arrow-down') . '
';
}
$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], $controller->tree()), Individual::getInstance($path[$n + 1], $controller->tree())) . '
' . FontAwesome::decorativeIcon('arrow-down') . '
';
$x += 2;
} else {
$table[$x][$y + 1] = '' . Functions::getRelationshipNameFromPath($relationships[$n], Individual::getInstance($path[$n - 1], $controller->tree()), Individual::getInstance($path[$n + 1], $controller->tree())) . '
' . FontAwesome::decorativeIcon('arrow-up') . '
';
}
$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, $controller->tree());
ob_start();
FunctionsPrint::printPedigreePerson($individual);
$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.'), '
';
}
}