&%{};]*'); $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); } $controller=new WT_Controller_Base(); if ($surn) { $controller->setPageTitle(/* I18N: %s is a surname */ WT_I18N::translate('Branches of the %s family', htmlspecialchars($surn))); } else { $controller->setPageTitle(WT_I18N::translate('Branches')); } $controller ->pageHeader() ->addExternalJavascript(WT_STATIC_URL.'js/autocomplete.js'); ?>

> >

', $surn, ''; $indis = indis_array($surn, $soundex_std, $soundex_dm); usort($indis, array('WT_Person', 'CompareBirtDate')); 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 (in_array($parent, $indis, true)) { continue 2; } } } print_fams($person); } echo '
'; echo ''; } echo '
'; // close branches-page if (false) { // These messages were added (briefly) and translated. // Keep them in the translation template, as we will want them in the future WT_I18N::translate('Collapse all'); WT_I18N::translate('Expand all'); } function print_fams($person, $famid=null) { global $surn, $soundex_std, $soundex_dm, $user_ancestors; // select person name according to searched surname $person_name = ""; foreach ($person->getAllNames() as $n=>$name) { list($surn1) = explode(",", $name['sort']); if ( // one name is a substring of the other stripos($surn1, $surn)!==false || stripos($surn, $surn1)!==false || // one name sounds like the other $soundex_std && WT_Soundex::compare(WT_Soundex::soundex_std($surn1), WT_Soundex::soundex_std($surn)) || $soundex_dm && WT_Soundex::compare(WT_Soundex::soundex_dm ($surn1), WT_Soundex::soundex_dm ($surn)) ) { $person_name = $name['full']; break; } } if (empty($person_name)) { echo '
  • ', $person->getSexImage(), '…
  • '; return; } // current indi echo '
  • '; $class = ''; $sosa = array_search($person->getXref(), $user_ancestors); if ($sosa) { $class = 'search_hit'; $sosa = ' '.$sosa.' '.sosa_gen($sosa); } $current = $person->getSexImage(). ''.$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); } $marriage_year=$family->getMarriageYear(); if ($marriage_year) { $txt .= ' '; $txt .= ''.$marriage_year.''; } else if ($family->getMarriage()) { $txt .= ' '; $txt .= ''; } $txt .= $spouse->getSexImage(). ' '.$spouse->getFullName().' '.$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 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". " FROM `##individuals`". " JOIN `##name` ON (i_id=n_id AND i_file=n_file)". " WHERE n_file=?". " AND n_type!=?". " AND (n_surn=? OR n_surname=?"; $args=array(WT_GED_ID, '_MARNM', $surn, $surn); if ($soundex_std) { foreach (explode(':', WT_Soundex::soundex_std($surn)) as $value) { $sql .= " OR n_soundex_surn_std LIKE CONCAT('%', ?, '%')"; $args[]=$value; } } if ($soundex_dm) { foreach (explode(':', WT_Soundex::soundex_dm($surn)) as $value) { $sql .= " OR n_soundex_surn_dm LIKE CONCAT('%', ?, '%')"; $args[]=$value; } } $sql .= ')'; $rows= WT_DB::prepare($sql) ->execute($args) ->fetchAll(PDO::FETCH_ASSOC); $data=array(); foreach ($rows as $row) { $data[]=WT_Person::getInstance($row); } return $data; } function sosa_gen($sosa) { $gen = (int)log($sosa, 2)+1; return ''.$gen.''; }