'); define('WT_ICON_BRANCHES', ''); //-- args $surn = safe_GET('surn', '[^<>&%{};]*'); $surn = utf8_strtoupper($surn); $soundex_std = safe_GET_bool('soundex_std'); $soundex_dm = safe_GET_bool('soundex_dm'); $ged = safe_GET('ged'); if (empty($ged)) { $ged = $GEDCOM; } $user_ancestors=array(); if (WT_USER_GEDCOM_ID) { load_ancestors_array(WT_Person::getInstance(WT_USER_GEDCOM_ID), 1); } //-- random surname if ($surn=='*') { $surn = array_rand(WT_Query_Name::surnames('', '', false, true, WT_GED_ID)); } //-- form print_header(WT_I18N::translate('Branches').' - '.$surn); if ($ENABLE_AUTOCOMPLETE) { require WT_ROOT.'/js/autocomplete.js.htm'; } ?>


/> />

', WT_ICON_BRANCHES, ' ', PrintReady($surn), ''; $indis = indis_array($surn, $soundex_std, $soundex_dm); echo '
    '; foreach ($indis as $person) { $famc = $person->getPrimaryChildFamily(); // Don't show INDIs with parents in the list, as they will be shown twice. if ($famc) { foreach ($famc->getSpouses() as $parent) { if (array_key_exists($parent->getXref(), $indis)) { continue 2; } } } print_fams($person); } echo '
'; echo ''; } print_footer(); function print_fams($person, $famid=null) { global $UNKNOWN_NN, $surn, $surn_script, $TEXT_DIRECTION, $user_ancestors; // select person name according to searched surname $person_name = ""; foreach ($person->getAllNames() as $n=>$name) { list($surn1) = explode(", ", $name['list']); if (stripos($surn1, $surn)===false && stripos($surn, $surn1)===false && soundex_std($surn1)!==soundex_std($surn) && soundex_dm($surn1)!==soundex_dm($surn) ) { continue; } if (utf8_script($surn1)!==$surn_script) { continue; } $person_name = $name['full']; break; } if (empty($person_name)) { echo '', $person->getSexImage(), '...'; return; } $person_script = utf8_script($person_name); // current indi echo '
  • '; $class = ''; $sosa = array_search($person->getXref(), $user_ancestors); if ($sosa) { $class = 'search_hit'; $sosa = ' '.$sosa.' '.sosa_gen($sosa); } $current = $person->getSexImage(). ''.PrintReady($person_name).' '. $person->getLifeSpan().' '.$sosa; if ($famid && $person->getChildFamilyPedigree($famid)) { $sex = $person->getSex(); $famcrec = get_sub_record(1, '1 FAMC @'.$famid.'@', $person->getGedcomRecord()); $pedi = get_gedcom_value('PEDI', 2, $famcrec, '', false); if ($pedi) { $label = WT_Gedcom_Code_Pedi::getValue($pedi, $person); } $current = ''.$label.' '.$current; } // spouses and children if (count($person->getSpouseFamilies())<1) { echo $current; } foreach ($person->getSpouseFamilies() as $family) { $txt = $current; $spouse = $family->getSpouse($person); if ($spouse) { $class = ''; $sosa2 = array_search($spouse->getXref(), $user_ancestors); if ($sosa2) { $class = 'search_hit'; $sosa2 = ' '.$sosa2.' '.sosa_gen($sosa2); } if ($family->getMarriageYear()) { $txt .= ' '; $txt .= ''.WT_ICON_RINGS.$family->getMarriageYear().' '; } else if ($family->getMarriage()) { $txt .= ' '; $txt .= ''.WT_ICON_RINGS.' '; } $spouse_name = $spouse->getListName(); foreach ($spouse->getAllNames() as $n=>$name) { if (utf8_script($name['list']) == $person_script) { $spouse_name = $name['list']; $spouse_surname = $name['surname']; break; } //How can we use check_NN($names) or something else to replace the unknown unknown name from the page language to the language of the spouse's name? else if ($name['fullNN']=='@P.N. @N.N.') { $spouse_name = $UNKNOWN_NN.', '.$UNKNOWN_NN; break; } } list($surn2, $givn2) = explode(', ', $spouse_name.', x'); $txt .= $spouse->getSexImage(). ''.PrintReady($givn2).' '. ''.PrintReady($surn2).' '.$spouse->getLifeSpan().' '.$sosa2; } echo $txt; echo '
      '; foreach ($family->getChildren() as $c=>$child) { print_fams($child, $family->getXref()); } echo '
    '; } echo '
  • '; } function load_ancestors_array($person, $sosa=1) { global $user_ancestors; if ($person) { $user_ancestors[$sosa]=$person->getXref(); foreach ($person->getChildFamilies() as $family) { foreach ($family->getSpouses() as $parent) { load_ancestors_array($parent, $sosa*2+($parent->getSex()=='F')); } } } } function indis_array($surn, $soundex_std, $soundex_dm) { $sql= 'SELECT DISTINCT n_id'. ' FROM `##name`'. ' WHERE n_file=?'. ' AND n_type!=?'. ' AND (n_surn=? OR n_surname=?'; $args=array(WT_GED_ID, '_MARNM', $surn, $surn); if ($soundex_std) { $sql .= ' OR n_soundex_surn_std=?'; $args[]=soundex_std($surn); } if ($soundex_dm) { $sql .= ' OR n_soundex_surn_dm=?'; $args[]=soundex_dm($surn); } $sql .= ') ORDER BY n_sort'; $rows= WT_DB::prepare($sql) ->execute($args) ->fetchAll(); $data=array(); foreach ($rows as $row) { $data[$row->n_id]=WT_Person::getInstance($row->n_id); } return $data; } function sosa_gen($sosa) { $gen = (int)log($sosa, 2)+1; return ''.$gen.''; }