pageHeader()
->addExternalJavascript(WT_STATIC_URL.'js/autocomplete.js')
->addInlineJavascript('var pastefield; function paste_id(value) { pastefield.value=value; }'); // For the "find indi" link
echo '
', $controller->getPageTitle(), '
';
echo '
';
if ($controller->error_message) {
echo '
', $controller->error_message, '
';
exit;
}
switch ($controller->chart_style) {
case 0: //-- list
echo '
';
$controller->print_child_descendancy($controller->root, $controller->generations);
echo '
';
break;
case 1: //-- booklet
echo '
';
$show_cousins = true;
$controller->print_child_family($controller->root, $controller->generations);
echo '
';
break;
case 2: //-- Individual list
$descendants=indi_desc($controller->root, $controller->generations, array());
echo '
';
echo format_indi_table($descendants, WT_I18N::translate('Descendants of %s', $controller->name));
echo '
';
break;
case 3: //-- Family list
$descendants=fam_desc($controller->root, $controller->generations, array());
echo '
';
echo format_fam_table($descendants, WT_I18N::translate('Descendants of %s', $controller->name));
echo '
';
break;
}
echo '
';// close #descendancy-page
function indi_desc($person, $n, $array) {
if ($n<1) {
return $array;
}
$array[$person->getXref()]=$person;
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
if ($spouse) {
$array[$spouse->getXref()] = $spouse;
}
foreach ($family->getChildren() as $child) {
$array=indi_desc($child, $n-1, $array);
}
}
return $array;
}
function fam_desc($person, $n, $array) {
if ($n<1) {
return $array;
}
foreach ($person->getSpouseFamilies() as $family) {
$array[$family->getXref()]=$family;
foreach ($family->getChildren() as $child) {
$array=fam_desc($child, $n-1, $array);
}
}
return $array;
}