/** * Generate a recursive list of descendants of an individual. * If parents are specified, we can also show the pedigree (adopted, etc.). * * @param Individual $individual * @param Family|null $parents * * @return string */ private function getDescendantsHtml(Individual $individual, Family $parents = null) { // A person has many names. Select the one that matches the searched surname $person_name = ''; foreach ($individual->getAllNames() as $name) { list($surn1) = explode(",", $name['sort']); if (stripos($surn1, $this->surname) !== false || stripos($this->surname, $surn1) !== false || $this->soundex_std && Soundex::compare(Soundex::russell($surn1), Soundex::russell($this->surname)) || $this->soundex_dm && Soundex::compare(Soundex::daitchMokotoff($surn1), Soundex::daitchMokotoff($this->surname))) { $person_name = $name['full']; break; } } // No matching name? Typically children with a different surname. The branch stops here. if (!$person_name) { return '<li title="' . strip_tags($individual->getFullName()) . '">' . $individual->getSexImage() . '…</li>'; } // Is this individual one of our ancestors? $sosa = array_search($individual, $this->ancestors, true); if ($sosa) { $sosa_class = 'search_hit'; $sosa_html = ' <a class="details1 ' . $individual->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $this->ancestors[1]->getXref() . '&pid1=' . $individual->getXref() . '">' . $sosa . '</a>' . self::sosaGeneration($sosa); } else { $sosa_class = ''; $sosa_html = ''; } // Generate HTML for this individual, and all their descendants $indi_html = $individual->getSexImage() . '<a class="' . $sosa_class . '" href="' . $individual->getHtmlUrl() . '">' . $person_name . '</a> ' . $individual->getLifeSpan() . $sosa_html; // If this is not a birth pedigree (e.g. an adoption), highlight it if ($parents) { $pedi = ''; foreach ($individual->getFacts('FAMC') as $fact) { if ($fact->getTarget() === $parents) { $pedi = $fact->getAttribute('PEDI'); break; } } if ($pedi && $pedi != 'birth') { $indi_html = '<span class="red">' . GedcomCodePedi::getValue($pedi, $individual) . '</span> ' . $indi_html; } } // spouses and children $spouse_families = $individual->getSpouseFamilies(); if ($spouse_families) { usort($spouse_families, '\\Fisharebest\\Webtrees\\Family::compareMarrDate'); $fam_html = ''; foreach ($spouse_families as $family) { $fam_html .= $indi_html; // Repeat the individual details for each spouse. $spouse = $family->getSpouse($individual); if ($spouse) { $sosa = array_search($spouse, $this->ancestors, true); if ($sosa) { $sosa_class = 'search_hit'; $sosa_html = ' <a class="details1 ' . $spouse->getBoxStyle() . '" title="' . I18N::translate('Sosa') . '" href="relationship.php?pid2=' . $this->ancestors[1]->getXref() . '&pid1=' . $spouse->getXref() . '"> ' . $sosa . ' </a>' . self::sosaGeneration($sosa); } else { $sosa_class = ''; $sosa_html = ''; } $marriage_year = $family->getMarriageYear(); if ($marriage_year) { $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . strip_tags($family->getMarriageDate()->display()) . '"><i class="icon-rings"></i>' . $marriage_year . '</a>'; } elseif ($family->getFirstFact('MARR')) { $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . GedcomTag::getLabel('MARR') . '"><i class="icon-rings"></i></a>'; } elseif ($family->getFirstFact('_NMR')) { $fam_html .= ' <a href="' . $family->getHtmlUrl() . '" title="' . GedcomTag::getLabel('_NMR') . '"><i class="icon-rings"></i></a>'; } $fam_html .= ' ' . $spouse->getSexImage() . '<a class="' . $sosa_class . '" href="' . $spouse->getHtmlUrl() . '">' . $spouse->getFullName() . '</a> ' . $spouse->getLifeSpan() . ' ' . $sosa_html; } $fam_html .= '<ol>'; foreach ($family->getChildren() as $child) { $fam_html .= $this->getDescendantsHtml($child, $family); } $fam_html .= '</ol>'; } return '<li>' . $fam_html . '</li>'; } else { // No spouses - just show the individual return '<li>' . $indi_html . '</li>'; } }
/** * Convert custom markup into HTML * * @param Note $note * * @return string */ public static function formatCensusNote(Note $note) { global $WT_TREE; if (preg_match('/(.*)((?:\\n.*)*)\\n\\.start_formatted_area\\.\\n(.+)\\n(.+(?:\\n.+)*)\\n.end_formatted_area\\.((?:\\n.*)*)/', $note->getNote(), $match)) { // This looks like a census-assistant shared note $title = Filter::escapeHtml($match[1]); $preamble = Filter::escapeHtml($match[2]); $header = Filter::escapeHtml($match[3]); $data = Filter::escapeHtml($match[4]); $postamble = Filter::escapeHtml($match[5]); // Get the column headers for the census to which this note refers // requires the fact place & date to match the specific census // censusPlace() (Soundex match) and censusDate() functions $fmt_headers = array(); $linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE')); $firstRecord = array_shift($linkedRecords); if ($firstRecord) { $countryCode = ''; $date = ''; foreach ($firstRecord->getFacts('CENS') as $fact) { if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) { $date = $fact->getAttribute('DATE'); $place = explode(',', strip_tags($fact->getPlace()->getFullName())); $countryCode = Soundex::daitchMokotoff(array_pop($place)); break; } } foreach (Census::allCensusPlaces() as $censusPlace) { if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) { foreach ($censusPlace->allCensusDates() as $census) { if ($census->censusDate() == $date) { foreach ($census->columns() as $column) { $abbrev = $column->abbreviation(); if ($abbrev) { $description = $column->title() ? $column->title() : I18N::translate('Description unavailable'); $fmt_headers[$abbrev] = '<span title="' . $description . '">' . $abbrev . '</span>'; } } break 2; } } } } } // Substitute header labels and format as HTML $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>'; $thead = str_replace('.b.', '', $thead); // Format data as HTML $tbody = ''; foreach (explode("\n", $data) as $row) { $tbody .= '<tr>'; foreach (explode('|', $row) as $column) { $tbody .= '<td>' . $column . '</td>'; } $tbody .= '</tr>'; } return $title . "\n" . '<div class="markdown">' . '<p>' . $preamble . '</p>' . '<table>' . '<thead>' . $thead . '</thead>' . '<tbody>' . $tbody . '</tbody>' . '</table>' . '<p>' . $postamble . '</p>' . '</div>'; } else { // Not a census-assistant shared note - apply default formatting return Filter::formatText($note->getNote(), $WT_TREE); } }