';
return $content;
}
// Print a link to allow email/messaging contact with a user
// Optionally specify a method (used for webmaster/genealogy contacts)
function user_contact_link($user_id) {
$method=get_user_setting($user_id, 'contactmethod');
$fullname=getUserFullName($user_id);
switch ($method) {
case 'none':
return '';
case 'mailto':
$email=getUserEmail($user_id);
return ''.htmlspecialchars($fullname).'';
default:
return "".$fullname."";
}
}
// print links for genealogy and technical contacts
//
// this function will print appropriate links based on the preferred contact methods for the genealogy
// contact user and the technical support contact user
function contact_links($ged_id=WT_GED_ID) {
$contact_user_id =get_gedcom_setting($ged_id, 'CONTACT_USER_ID');
$webmaster_user_id=get_gedcom_setting($ged_id, 'WEBMASTER_USER_ID');
$supportLink = user_contact_link($webmaster_user_id);
if ($webmaster_user_id==$contact_user_id) {
$contactLink = $supportLink;
} else {
$contactLink = user_contact_link($contact_user_id);
}
if (!$supportLink && !$contactLink) {
return '';
}
if ($supportLink==$contactLink) {
return '
'.WT_I18N::translate('For technical support or genealogy questions, please contact').' '.$supportLink.'
';
} else {
$returnText = '
';
if ($supportLink) {
$returnText .= WT_I18N::translate('For technical support and information contact').' '.$supportLink;
if ($contactLink) {
$returnText .= ' ';
}
}
if ($contactLink) {
$returnText .= WT_I18N::translate('For help with genealogy questions contact').' '.$contactLink;
}
$returnText .= '
';
return $returnText;
}
}
/**
* print a note record
* @param string $text
* @param int $nlevel the level of the note record
* @param string $nrec the note record to print
* @param bool $textOnly Don't print the "Note: " introduction
* @param boolean $return Print the data or return the data
* @param boolean $npage the data is on note page or not
* @return boolean
*/
function print_note_record($text, $nlevel, $nrec, $textOnly=false, $return=false, $npage=false) {
global $EXPAND_SOURCES, $EXPAND_NOTES;
$elementID = 'N-'.(int)(microtime()*1000000);
$text = trim($text);
// Check if Shared Note and if so enable url link on title -------------------
if (preg_match('/^0 @'.WT_REGEX_XREF.'@ NOTE/', $nrec)) {
$centitl = str_replace('~~', '', $text);
$centitl = str_replace(' ', '', $centitl);
if (preg_match('/@N([0-9])+@/', $nrec, $match_nid)) {
$nid = str_replace('@', '', $match_nid[0]);
if (!$npage) {
$centitl = ''.$centitl.'';
}
}
if ($textOnly) {
$text = $centitl;
return $text;
} else {
$text = get_cont($nlevel, $nrec);
}
} else {
$text .= get_cont($nlevel, $nrec);
}
$text = str_replace('~~', ' ', $text);
$text = expand_urls($text);
$data = '';
if (!empty($text) || !empty($centitl)) {
// Check if Formatted Shared Note (using pipe "|" as delimiter ) --------------------
if (preg_match('/^0 @'.WT_REGEX_XREF.'@ NOTE/', $nrec) && strstr($text, "|") && array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
require WT_ROOT.WT_MODULES_DIR.'GEDFact_assistant/_CENS/census_note_decode.php';
// Else if unformatted Shared Note --------------------------------------------------
} else if (preg_match('/^0 @'.WT_REGEX_XREF.'@ NOTE/', $nrec)) {
$text=$centitl.$text;
}
if ($textOnly) {
if (!$return) {
echo $text;
return true;
} else {
return $text;
}
}
$brpos = strpos($text, ' ');
if (!$npage) {
$data .= '
', WT_I18N::translate('For more information contact'), ' ', "", $fullname, '', '
';
break;
}
}
// Print a link for a popup help window
function help_link($help_topic, $module='') {
return '';
}
// Print an external help link to the wiki site, in a new window
function wiki_help_link($topic) {
return '';
}
// When a user has searched for text, highlight any matches in
// the displayed string.
function highlight_search_hits($string) {
global $controller;
if ($controller instanceof WT_Controller_Search && $controller->query) {
// TODO: when a search contains multiple words, we search independently.
// e.g. searching for "FOO BAR" will find records containing both FOO and BAR.
// However, we only highlight the original search string, not the search terms.
// The controller needs to provide its "query_terms" array.
$regex=array();
foreach (array($controller->query) as $search_term) {
$regex[]=preg_quote($search_term, '/');
}
// Match these strings, provided they do not occur inside HTML tags
$regex='('.implode('|', $regex).')(?![^<]*>)';
return preg_replace('/'.$regex.'/i', '$1', $string);
} else {
return $string;
}
}
// Print the associations from the associated individuals in $event to the individuals in $record
function print_asso_rela_record(WT_Fact $event, WT_GedcomRecord $record) {
global $SEARCH_SPIDER;
// To whom is this record an assocate?
if ($record instanceof WT_Individual) {
// On an individual page, we just show links to the person
$associates=array($record);
} elseif ($record instanceof WT_Family) {
// On a family page, we show links to both spouses
$associates=$record->getSpouses();
} else {
// On other pages, it does not make sense to show associates
return;
}
preg_match_all('/^1 ASSO @('.WT_REGEX_XREF.')@((\n[2-9].*)*)/', $event->getGedcom(), $amatches1, PREG_SET_ORDER);
preg_match_all('/\n2 _?ASSO @('.WT_REGEX_XREF.')@((\n[3-9].*)*)/', $event->getGedcom(), $amatches2, PREG_SET_ORDER);
// For each ASSO record
foreach (array_merge($amatches1, $amatches2) as $amatch) {
$person=WT_Individual::getInstance($amatch[1]);
if ($person) {
if (preg_match('/\n[23] RELA (.+)/', $amatch[2], $rmatch)) {
$rela=$rmatch[1];
} else {
$rela='';
}
$html=array();
foreach ($associates as $associate) {
if ($associate) {
if ($rela) {
$label=''.WT_Gedcom_Code_Rela::getValue($rela, $person).': ';
$label_2=''.get_associate_relationship_name($associate, $person).'';
} else {
// Generate an automatic RELA
$label='';
$label_2=''.get_associate_relationship_name($associate, $person).'';
}
if (!$label && !$label_2) {
$label=WT_I18N::translate('Relationships');
$label_2='';
}
// For family records (e.g. MARR), identify the spouse with a sex icon
if ($record instanceof WT_Family) {
$label_2=$associate->getSexImage().$label_2;
}
if ($SEARCH_SPIDER) {
$html[]=$label_2; // Search engines cannot use the relationship chart.
} else {
$html[]=''.$label_2.'';
}
}
}
$html=array_unique($html);
echo
'
';
} else {
echo WT_Gedcom_Tag::getLabelValue('ASSO', '' . $amatch[1] . '');
}
}
}
/**
* Format age of parents in HTML
*
* @param string $pid child ID
*/
function format_parents_age($pid, $birth_date=null) {
global $SHOW_PARENTS_AGE;
$html='';
if ($SHOW_PARENTS_AGE) {
$person=WT_Individual::getInstance($pid);
$families=$person->getChildFamilies();
// Where an indi has multiple birth records, we need to know the
// date of it. For person boxes, etc., use the default birth date.
if (is_null($birth_date)) {
$birth_date=$person->getBirthDate();
}
// Multiple sets of parents (e.g. adoption) cause complications, so ignore.
if ($birth_date->isOK() && count($families)==1) {
$family=current($families);
foreach ($family->getSpouses() as $parent) {
if ($parent->getBirthDate()->isOK()) {
$sex=$parent->getSexImage();
$age=WT_Date::getAge($parent->getBirthDate(), $birth_date, 2);
$deatdate=$parent->getDeathDate();
switch ($parent->getSex()) {
case 'F':
// Highlight mothers who die in childbirth or shortly afterwards
if ($deatdate->isOK() && $deatdate->MinJD()<$birth_date->MinJD()+90) {
$html.=' '.$sex.$age.'';
} else {
$html.=' '.$sex.$age.'';
}
break;
case 'M':
// Highlight fathers who die before the birth
if ($deatdate->isOK() && $deatdate->MinJD()<$birth_date->MinJD()) {
$html.=' '.$sex.$age.'';
} else {
$html.=' '.$sex.$age.'';
}
break;
default:
$html.=' '.$sex.$age.'';
break;
}
}
}
if ($html) {
$html=''.$html.'';
}
}
}
return $html;
}
// print fact DATE TIME
//
// $event - event containing the date/age
// $record - the person (or couple) whose ages should be printed
// $anchor option to print a link to calendar
// $time option to print TIME value
function format_fact_date(WT_Fact $event, WT_GedcomRecord $record, $anchor=false, $time=false) {
global $pid, $SEARCH_SPIDER;
global $GEDCOM;
$ged_id=get_id_from_gedcom($GEDCOM);
$factrec = $event->getGedcom();
$html='';
// Recorded age
if (preg_match('/\n2 AGE (.+)/', $factrec, $match)) {
$fact_age = $match[1];
} else {
$fact_age = '';
}
if (preg_match('/\n2 HUSB\n3 AGE (.+)/', $factrec, $match)) {
$husb_age = $match[1];
} else {
$husb_age = '';
}
if (preg_match('/\n2 WIFE\n3 AGE (.+)/', $factrec, $match)) {
$wife_age = $match[1];
} else {
$wife_age = '';
}
// Calculated age
if (preg_match('/2 DATE (.+)/', $factrec, $match)) {
$date=new WT_Date($match[1]);
$html.=' '.$date->Display($anchor && !$SEARCH_SPIDER);
// time
if ($time) {
$timerec=get_sub_record(2, '2 TIME', $factrec);
if ($timerec=='') {
$timerec=get_sub_record(2, '2 DATE', $factrec);
}
if (preg_match('/[2-3] TIME (.*)/', $timerec, $tmatch)) {
$html.=' - '.$tmatch[1].'';
}
}
$fact = $event->getTag();
if ($record instanceof WT_Individual) {
// age of parents at child birth
if ($fact=='BIRT') {
$html .= format_parents_age($record->getXref(), $date);
}
// age at event
else if ($fact!='CHAN' && $fact!='_TODO') {
$birth_date=$record->getBirthDate();
// Can't use getDeathDate(), as this also gives BURI/CREM events, which
// wouldn't give the correct "days after death" result for people with
// no DEAT.
$death_event=$record->getFirstFact('DEAT');
if ($death_event) {
$death_date=$death_event->getDate();
} else {
$death_date=new WT_Date('');
}
$ageText = '';
if ((WT_Date::Compare($date, $death_date)<=0 || !$record->isDead()) || $fact=='DEAT') {
// Before death, print age
$age=WT_Date::GetAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age!='') {
if (
$fact_age!='' && $fact_age!=$age ||
$fact_age=='' && $husb_age=='' && $wife_age=='' ||
$husb_age!='' && $record->getSex()=='M' && $husb_age!=$age ||
$wife_age!='' && $record->getSex()=='F' && $wife_age!=$age
) {
if ($age!="0d") {
$ageText = '('.WT_I18N::translate('Age').' '.get_age_at_event($age, false).')';
}
}
}
}
if ($fact!='DEAT' && WT_Date::Compare($date, $death_date)>=0) {
// After death, print time since death
$age=get_age_at_event(WT_Date::GetAgeGedcom($death_date, $date), true);
if ($age!='') {
if (WT_Date::GetAgeGedcom($death_date, $date)=="0d") {
$ageText = '('.WT_I18N::translate('on the date of death').')';
} else {
$ageText = '('.$age.' '.WT_I18N::translate('after death').')';
// Family events which occur after death are probably errors
if ($event->getParent() instanceof WT_Family) {
$ageText.='';
}
}
}
}
if ($ageText) $html .= ' '.$ageText.'';
}
} elseif ($record instanceof WT_Family) {
$indi = WT_Individual::getInstance($pid);
if ($indi) {
$birth_date=$indi->getBirthDate();
$death_date=$indi->getDeathDate();
$ageText = '';
if (WT_Date::Compare($date, $death_date)<=0) {
$age=WT_Date::GetAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age!='' && $age>0) {
if (
$fact_age!='' && $fact_age!=$age ||
$fact_age=='' && $husb_age=='' && $wife_age=='' ||
$husb_age!='' && $indi->getSex()=='M' && $husb_age!= $age ||
$wife_age!='' && $indi->getSex()=='F' && $wife_age!=$age
) {
$ageText = '('.WT_I18N::translate('Age').' '.get_age_at_event($age, false).')';
}
}
}
if ($ageText) $html .= ' '.$ageText.'';
}
}
} else {
// 1 DEAT Y with no DATE => print YES
// 1 BIRT 2 SOUR @S1@ => print YES
// 1 DEAT N is not allowed
// It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
$factdetail = explode(' ', trim($factrec));
if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) {
$html.=WT_I18N::translate('yes');
}
}
// print gedcom ages
foreach (array(WT_Gedcom_Tag::getLabel('AGE')=>$fact_age, WT_Gedcom_Tag::getLabel('HUSB')=>$husb_age, WT_Gedcom_Tag::getLabel('WIFE')=>$wife_age) as $label=>$age) {
if ($age!='') {
$html.=' '.$label.':'.get_age_at_event($age, false).'';
}
}
return $html;
}
/**
* print fact PLACe TEMPle STATus
*
* @param Event $event gedcom fact record
* @param boolean $anchor option to print a link to placelist
* @param boolean $sub option to print place subrecords
* @param boolean $lds option to print LDS TEMPle and STATus
*/
function format_fact_place(WT_Fact $event, $anchor=false, $sub=false, $lds=false) {
global $SHOW_PEDIGREE_PLACES, $SHOW_PEDIGREE_PLACES_SUFFIX, $SEARCH_SPIDER;
$factrec = $event->getGedcom();
$wt_place=new WT_Place($event->getPlace(), WT_GED_ID);
$name_parts=explode(', ', $event->getPlace());
$ct=count($name_parts);
if ($anchor) {
// Show the full place name, for facts/events tab
if ($SEARCH_SPIDER) {
$html=$wt_place->getFullName();
} else {
$html='' . $wt_place->getFullName() . '';
}
} else {
// Abbreviate the place name, for chart boxes
return ' - ' . $wt_place->getShortName();
}
$ctn=0;
if ($sub) {
$placerec = get_sub_record(2, '2 PLAC', $factrec);
if (!empty($placerec)) {
if (preg_match_all('/\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) {
foreach ($matches[1] as $match) {
$wt_place=new WT_Place($match, WT_GED_ID);
$html.=' - ' . $wt_place->getFullName();
}
}
$map_lati="";
$cts = preg_match('/\d LATI (.*)/', $placerec, $match);
if ($cts>0) {
$map_lati=$match[1];
$html.=' '.WT_Gedcom_Tag::getLabel('LATI').': '.$map_lati;
}
$map_long="";
$cts = preg_match('/\d LONG (.*)/', $placerec, $match);
if ($cts>0) {
$map_long=$match[1];
$html.=' '.WT_Gedcom_Tag::getLabel('LONG').': '.$map_long;
}
if ($map_lati && $map_long && empty($SEARCH_SPIDER)) {
$map_lati=trim(strtr($map_lati, "NSEW,�", " - -. ")); // S5,6789 ==> -5.6789
$map_long=trim(strtr($map_long, "NSEW,�", " - -. ")); // E3.456� ==> 3.456
if ($name_parts) {
$place=$name_parts[0];
} else {
$place='';
}
$html.=' ';
$html.=' ';
$html.=' ';
$html.=' ';
}
if (preg_match('/\d NOTE (.*)/', $placerec, $match)) {
ob_start();
print_fact_notes($placerec, 3);
$html.=' '.ob_get_contents();
ob_end_clean();
}
}
}
if ($lds) {
if (preg_match('/2 TEMP (.*)/', $factrec, $match)) {
$tcode=trim($match[1]);
$html.=' '.WT_I18N::translate('LDS Temple').': '.WT_Gedcom_Code_Temp::templeName($match[1]);
}
if (preg_match('/2 STAT (.*)/', $factrec, $match)) {
$html.=' '.WT_I18N::translate('Status').': '.WT_Gedcom_Code_Stat::statusName($match[1]);
if (preg_match('/3 DATE (.*)/', $factrec, $match)) {
$date=new WT_Date($match[1]);
$html.=', '.WT_Gedcom_Tag::getLabel('STAT:DATE').': '.$date->Display(false);
}
}
}
return $html;
}
/**
* Check for facts that may exist only once for a certain record type.
* If the fact already exists in the second array, delete it from the first one.
*/
function CheckFactUnique($uniquefacts, $recfacts, $type) {
foreach ($recfacts as $indexval => $factarray) {
$fact=false;
if (is_object($factarray)) {
/* @var $factarray Event */
$fact = $factarray->getTag();
}
else {
if (($type == "SOUR") || ($type == "REPO")) $factrec = $factarray[0];
if (($type == "FAM") || ($type == "INDI")) $factrec = $factarray[1];
$ft = preg_match("/1 (\w+)(.*)/", $factrec, $match);
if ($ft>0) {
$fact = trim($match[1]);
}
}
if ($fact!==false) {
$key = array_search($fact, $uniquefacts);
if ($key !== false) unset($uniquefacts[$key]);
}
}
return $uniquefacts;
}
/**
* Print a new fact box on details pages
* @param string $id the id of the person, family, source etc the fact will be added to
* @param array $usedfacts an array of facts already used in this record
* @param string $type the type of record INDI, FAM, SOUR etc
*/
function print_add_new_fact($id, $usedfacts, $type) {
global $WT_SESSION;
// -- Add from clipboard
if ($WT_SESSION->clipboard) {
$newRow = true;
foreach (array_reverse($WT_SESSION->clipboard, true) as $key=>$fact) {
if ($fact["type"]==$type || $fact["type"]=='all') {
if ($newRow) {
$newRow = false;
echo '
';
echo WT_I18N::translate('Add from clipboard'), '