/** * Print all of the notes in this fact record * @param string $factrec the factrecord to print the notes from * @param int $level The level of the factrecord */ function print_fact_notes($factrec, $level) { global $pgv_lang; global $factarray; global $WORD_WRAPPED_NOTES; $nlevel = $level + 1; $ct = preg_match_all("/{$level} NOTE(.*)/", $factrec, $match, PREG_SET_ORDER); for ($j = 0; $j < $ct; $j++) { $spos1 = strpos($factrec, $match[$j][0]); $spos2 = strpos($factrec, "\n{$level}", $spos1 + 1); if (!$spos2) { $spos2 = strlen($factrec); } $nrec = substr($factrec, $spos1, $spos2 - $spos1); if (!isset($match[$j][1])) { $match[$j][1] = ""; } $nt = preg_match("/@(.*)@/", $match[$j][1], $nmatch); $closeSpan = false; if ($nt == 0) { //-- print embedded note records $closeSpan = print_note_record($match[$j][1], $nlevel, $nrec); } else { if (displayDetailsByID($nmatch[1], "NOTE")) { //-- print linked note records $noterec = find_gedcom_record($nmatch[1]); $nt = preg_match("/0 @{$nmatch['1']}@ NOTE (.*)/", $noterec, $n1match); $closeSpan = print_note_record($nt > 0 ? $n1match[1] : "", 1, $noterec); if (preg_match("/1 SOUR/", $noterec) > 0) { print "<br />\n"; print_fact_sources($noterec, 1); } } } if (preg_match("/{$nlevel} SOUR/", $factrec) > 0) { print "<div class=\"indent\">"; print_fact_sources($nrec, $nlevel); print "</div>"; } if ($closeSpan) { print "</span>"; } } }
/** * Print all of the notes in this fact record * * @param string $factrec the factrecord to print the notes from * @param int $level The level of the factrecord * @param bool $textOnly Don't print the "Note: " introduction * * @return string HTML */ function print_fact_notes($factrec, $level, $textOnly = false) { $data = ""; $previous_spos = 0; $nlevel = $level + 1; $ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER); for ($j = 0; $j < $ct; $j++) { $spos1 = strpos($factrec, $match[$j][0], $previous_spos); $spos2 = strpos($factrec . "\n{$level}", "\n{$level}", $spos1 + 1); if (!$spos2) { $spos2 = strlen($factrec); } $previous_spos = $spos2; $nrec = substr($factrec, $spos1, $spos2 - $spos1); if (!isset($match[$j][1])) { $match[$j][1] = ""; } if (!preg_match("/@(.*)@/", $match[$j][1], $nmatch)) { $data .= print_note_record($match[$j][1], $nlevel, $nrec, $textOnly); } else { $note = WT_Note::getInstance($nmatch[1]); if ($note) { if ($note->canShow()) { $noterec = $note->getGedcom(); $nt = preg_match("/0 @{$nmatch['1']}@ NOTE (.*)/", $noterec, $n1match); $data .= print_note_record($nt > 0 ? $n1match[1] : "", 1, $noterec, $textOnly); if (!$textOnly) { if (strpos($noterec, "1 SOUR") !== false) { require_once WT_ROOT . 'includes/functions/functions_print_facts.php'; $data .= print_fact_sources($noterec, 1); } } } } else { $data = '<div class="fact_NOTE"><span class="label">' . WT_I18N::translate('Note') . '</span>: <span class="field error">' . $nmatch[1] . '</span></div>'; } } if (!$textOnly) { if (strpos($factrec, "{$nlevel} SOUR") !== false) { $data .= "<div class=\"indent\">"; $data .= print_fact_sources($nrec, $nlevel); $data .= "</div>"; } } } return $data; }