public static function readPersonData($pfx, $titleString, &$data, &$gedcomData, $includeRelativeData = false, $saveParentTitle = false, $saveSpouseTitle = false, $includeNonCompareData = false, $revid = 0, $timestamp = '') { $data[$pfx . 'Title'][] = $titleString; if (GedcomUtil::isGedcomTitle($titleString)) { $title = null; $data[$pfx . 'Exists'] = true; $xml = GedcomUtil::getGedcomXml($gedcomData, $titleString); $data[$pfx . 'GedcomMatchTitle'] = (string) $xml['match']; $contents = GedcomUtil::getGedcomContents($gedcomData, $titleString); } else { $title = Title::newFromText($titleString, NS_PERSON); $data[$pfx . 'Exists'] = $title->exists(); $p = new Person($titleString); $p->loadPage($revid); if ($revid) { $data[$pfx . 'Revid'][] = $revid; } // !!! this function can get called multiple times with the same pfx from SpecialReviewMerge $xml = $p->getPageXml(); $contents = $p->getPageContents(); } if (isset($xml)) { $found = true; // add match string $v = (string) @$xml->name['given']; if ($v) { $data[$pfx . 'Given'][] = $v; } $v = (string) @$xml->name['surname']; if ($v) { $data[$pfx . 'Surname'][] = $v; } $v = (string) @$xml->name['title_prefix']; if ($v) { $data[$pfx . 'Prefix'][] = $v; } $v = (string) @$xml->name['title_suffix']; if ($v) { $data[$pfx . 'Suffix'][] = $v; } if (!$pfx || $pfx == 'child') { $gender = (string) $xml->gender; $data[$pfx . 'Gender'][] = $gender; } foreach ($xml->alt_name as $an) { $v = (string) @$an['given']; if ($v) { $data[$pfx . 'Given'][] = $v; } $v = (string) @$an['surname']; if ($v) { $data[$pfx . 'Surname'][] = $v; } $v = (string) @$an['title_prefix']; if ($v) { $data[$pfx . 'Prefix'][] = $v; } $v = (string) @$an['title_suffix']; if ($v) { $data[$pfx . 'Suffix'][] = $v; } } foreach ($xml->event_fact as $ef) { $type = (string) $ef['type']; if ($type == Person::$BIRTH_TAG || $type == PERSON::$ALT_BIRTH_TAG) { CompareForm::getDatePlace($ef, $pfx . 'Birthdate', $pfx . 'Birthplace', $data); } else { if ($type == Person::$CHR_TAG || $type == PERSON::$ALT_CHR_TAG) { CompareForm::getDatePlace($ef, $pfx . 'Christeningdate', $pfx . 'Christeningplace', $data); } else { if ($type == Person::$DEATH_TAG || $type == PERSON::$ALT_DEATH_TAG) { CompareForm::getDatePlace($ef, $pfx . 'Deathdate', $pfx . 'Deathplace', $data); } else { if ($type == Person::$BUR_TAG || $type == PERSON::$ALT_BUR_TAG) { CompareForm::getDatePlace($ef, $pfx . 'Burialdate', $pfx . 'Burialplace', $data); } else { if ($includeNonCompareData) { CompareForm::getOtherEvent($ef, $pfx, $data); } } } } } } if ($includeNonCompareData) { CompareForm::getSINContents($xml, $contents, $pfx, $data); } if ($includeRelativeData) { CompareForm::initPersonData('father', $data); CompareForm::initPersonData('mother', $data); } foreach ($xml->child_of_family as $f) { $familyTitle = (string) $f['title']; if ($familyTitle && $includeRelativeData) { $f = new Family($familyTitle); $familyRevid = $timestamp ? StructuredData::getRevidForTimestamp($f->getTitle(), $timestamp) : 0; $f->loadPage($familyRevid); $famXml = $f->getPageXml(); $fatherFound = $motherFound = false; if (isset($famXml)) { $fatherFound = CompareForm::readRelativeData('father', $famXml->husband, $data, $gedcomData, false, false, $includeNonCompareData, $timestamp); $motherFound = CompareForm::readRelativeData('mother', $famXml->wife, $data, $gedcomData, false, false, $includeNonCompareData, $timestamp); } if (!$fatherFound || !$motherFound) { list($fg, $fs, $mg, $ms) = StructuredData::parseFamilyTitle($familyTitle); if (!$fatherFound) { if ($fg) { $data['fatherGiven'][] = $fg; } if ($fs) { $data['fatherSurname'][] = $fs; } } if (!$motherFound) { if ($mg) { $data['motherGiven'][] = $mg; } if ($ms) { $data['motherSurname'][] = $ms; } } } } else { if ($saveParentTitle) { $data[$pfx . 'ParentFamilyTitle'][] = $familyTitle; } } } if ($includeRelativeData) { CompareForm::initPersonData('spouse', $data); } foreach ($xml->spouse_of_family as $f) { $familyTitle = (string) $f['title']; if ($familyTitle && $includeRelativeData) { if (GedcomUtil::isGedcomTitle($familyTitle)) { $famXml = GedcomUtil::getGedcomXml($gedcomData, $familyTitle); } else { $f = new Family($familyTitle); $familyRevid = $timestamp ? StructuredData::getRevidForTimestamp($f->getTitle(), $timestamp) : 0; $f->loadPage($familyRevid); $famXml = $f->getPageXml(); } $spouseFound = false; if (isset($famXml)) { if ($gender == 'M') { $spouseFound = CompareForm::readRelativeData('spouse', $famXml->wife, $data, $gedcomData, false, false, $includeNonCompareData, $timestamp); } else { $spouseFound = CompareForm::readRelativeData('spouse', $famXml->husband, $data, $gedcomData, false, false, $includeNonCompareData, $timestamp); } } if (!$spouseFound) { list($fg, $fs, $mg, $ms) = StructuredData::parseFamilyTitle($familyTitle); if ($gender == 'M') { if ($mg) { $data['spouseGiven'][] = $mg; } if ($ms) { $data['spouseSurname'][] = $ms; } } else { if ($fg) { $data['spouseGiven'][] = $fg; } if ($fs) { $data['spouseSuranme'][] = $fs; } } } } else { if ($saveSpouseTitle) { $data[$pfx . 'SpouseFamilyTitle'][] = $familyTitle; } } } } else { if ($title && StructuredData::isRedirect($contents)) { $data[$pfx . 'Redirect'] = true; } list($g, $s) = StructuredData::parsePersonTitle($titleString); if ($g) { $data[$pfx . 'Given'][] = $g; } if ($s) { $data[$pfx . 'Surname'][] = $s; } } $data[$pfx . 'Nomerge'] = CompareForm::getNomergeTitleStrings($title); if ($title) { $data[$pfx . 'Updatable'] = CompareForm::isUpdatable($title, $contents); } }
public static function parseFamilyTitle($title) { $hg = $hs = $wg = $ws = ''; $pieces = explode(' and ', $title); list($hg, $hs) = StructuredData::parsePersonTitle($pieces[0]); if (count($pieces) > 1) { list($wg, $ws) = StructuredData::parsePersonTitle($pieces[1]); } return array($hg, $hs, $wg, $ws); }
private static function removeSelf($selfTitle, $familyTitle) { list($selfGiven, $selfSurname) = StructuredData::parsePersonTitle($selfTitle); $titles = explode(', ', $familyTitle); $results = array(); foreach ($titles as $t) { list($hg, $hs, $wg, $ws) = StructuredData::parseFamilyTitle($t); if (preg_replace('/<\\/?b>/', '', $hg) == $selfGiven && preg_replace('/<\\/?b>/', '', $hs) == $selfSurname) { $results[] = "{$wg} {$ws}"; } else { if (preg_replace('/<\\/?b>/', '', $wg) == $selfGiven && preg_replace('/<\\/?b>/', '', $ws) == $selfSurname) { $results[] = "{$hg} {$hs}"; } else { $results[] = $t; } } } return join(', ', $results); }
public static function getSummary($xml, $title) { // surname | given | gender | birthdate | birthplace | deathdate | deathplace list($given, $surname) = StructuredData::parsePersonTitle($title->getText()); $gender = ''; $birthDate = $birthPlace = $deathDate = $deathPlace = ''; $chrDate = $chrPlace = $burDate = $burPlace = ''; $birthFound = $deathFound = false; if (isset($xml)) { $name = (string) @$xml->name['surname']; if ($name) { $surname = $name; } $name = (string) @$xml->name['given']; if ($name) { $given = $name; } $gender = (string) @$xml->gender; if (isset($xml->event_fact)) { foreach ($xml->event_fact as $eventFact) { if ($eventFact['type'] == 'Birth') { $birthFound = true; $birthDate = (string) @$eventFact['date']; $birthPlace = (string) @$eventFact['place']; } else { if ($eventFact['type'] == 'Christening' || $eventFact['type'] == 'Baptism') { $chrDate = (string) @$eventFact['date']; $chrPlace = (string) @$eventFact['place']; } else { if ($eventFact['type'] == 'Death') { $deathFound = true; $deathDate = (string) @$eventFact['date']; $deathPlace = (string) @$eventFact['place']; } else { if ($eventFact['type'] == 'Burial') { $burDate = (string) @$eventFact['date']; $burPlace = (string) @$eventFact['place']; } } } } } } } return StructuredData::removeBars($surname) . '|' . StructuredData::removeBars($given) . '|' . StructuredData::removeBars($gender) . '|' . StructuredData::removeBars($birthFound ? $birthDate : $chrDate) . '|' . StructuredData::removePreBar($birthFound ? $birthPlace : $chrPlace) . '|' . StructuredData::removeBars($deathFound ? $deathDate : $burDate) . '|' . StructuredData::removePreBar($deathFound ? $deathPlace : $burPlace); }