function print_main_sources(WT_Fact $fact, $level) { global $SHOW_FACT_ICONS; $factrec = $fact->getGedcom(); $fact_id = $fact->getFactId(); $parent = $fact->getParent(); $pid = $parent->getXref(); $nlevel = $level + 1; if ($fact->isNew()) { $styleadd = 'new'; $can_edit = $level == 1 && $fact->canEdit(); } elseif ($fact->isOld()) { $styleadd = 'old'; $can_edit = false; } else { $styleadd = ''; $can_edit = $level == 1 && $fact->canEdit(); } // -- find source for each fact $ct = preg_match_all("/({$level} SOUR (.+))/", $factrec, $match, PREG_SET_ORDER); $spos2 = 0; for ($j = 0; $j < $ct; $j++) { $sid = trim($match[$j][2], '@'); $spos1 = strpos($factrec, $match[$j][1], $spos2); $spos2 = strpos($factrec, "\n{$level}", $spos1); if (!$spos2) { $spos2 = strlen($factrec); } $srec = substr($factrec, $spos1, $spos2 - $spos1); $source = WT_Source::getInstance($sid); // Allow access to "1 SOUR @non_existent_source@", so it can be corrected/deleted if (!$source || $source->canShow()) { if ($level > 1) { echo '<tr class="row_sour2">'; } else { echo '<tr>'; } echo '<td class="descriptionbox'; if ($level > 1) { echo ' rela'; } echo ' ', $styleadd, ' width20">'; $factlines = explode("\n", $factrec); // 1 BIRT Y\n2 SOUR ... $factwords = explode(" ", $factlines[0]); // 1 BIRT Y $factname = $factwords[1]; // BIRT if ($factname == 'EVEN' || $factname == 'FACT') { // Add ' EVEN' to provide sensible output for an event with an empty TYPE record $ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch); if ($ct > 0) { $factname = trim($ematch[1]); echo $factname; } else { echo WT_Gedcom_Tag::getLabel($factname, $parent); } } else { if ($can_edit) { echo "<a onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"", WT_I18N::translate('Edit'), '">'; if ($SHOW_FACT_ICONS) { if ($level == 1) { echo '<i class="icon-source"></i> '; } } echo WT_Gedcom_Tag::getLabel($factname, $parent), '</a>'; echo '<div class="editfacts">'; if (preg_match('/^@.+@$/', $match[$j][2])) { // Inline sources can't be edited. Attempting to save one will convert it // into a link, and delete it. // e.g. "1 SOUR my source" becomes "1 SOUR @my source@" which does not exist. echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Edit') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit') . "</span></a></div>"; echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . WT_I18N::translate('Copy') . '"><span class="link_text">' . WT_I18N::translate('Copy') . '</span></a></div>'; } echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Delete') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete') . "</span></a></div>"; echo '</div>'; } else { echo WT_Gedcom_Tag::getLabel($factname, $parent); } } echo '</td>'; echo '<td class="optionbox ', $styleadd, ' wrap">'; if ($source) { echo '<a href="', $source->getHtmlUrl(), '">', $source->getFullName(), '</a>'; // PUBL $publ = $source->getFirstFact('PUBL'); if ($publ) { echo WT_Gedcom_Tag::getLabelValue('PUBL', $publ->getValue()); } // 2 RESN tags. Note, there can be more than one, such as "privacy" and "locked" if (preg_match_all("/\n2 RESN (.+)/", $factrec, $rmatches)) { foreach ($rmatches[1] as $rmatch) { echo '<br><span class="label">', WT_Gedcom_Tag::getLabel('RESN'), ':</span> <span class="field">'; switch ($rmatch) { case 'none': // Note: "2 RESN none" is not valid gedcom, and the GUI will not let you add it. // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public". echo '<i class="icon-resn-none"></i> ', WT_I18N::translate('Show to visitors'); break; case 'privacy': echo '<i class="icon-resn-privacy"></i> ', WT_I18N::translate('Show to members'); break; case 'confidential': echo '<i class="icon-resn-confidential"></i> ', WT_I18N::translate('Show to managers'); break; case 'locked': echo '<i class="icon-resn-locked"></i> ', WT_I18N::translate('Only managers can edit'); break; default: echo $rmatch; break; } echo '</span>'; } } $cs = preg_match("/{$nlevel} EVEN (.*)/", $srec, $cmatch); if ($cs > 0) { echo '<br><span class="label">', WT_Gedcom_Tag::getLabel('EVEN'), ' </span><span class="field">', $cmatch[1], '</span>'; $cs = preg_match("/" . ($nlevel + 1) . " ROLE (.*)/", $srec, $cmatch); if ($cs > 0) { echo '<br> <span class="label">', WT_Gedcom_Tag::getLabel('ROLE'), ' </span><span class="field">', $cmatch[1], '</span>'; } } echo printSourceStructure(getSourceStructure($srec)); echo '<div class="indent">'; print_media_links($srec, $nlevel); if ($nlevel == 2) { print_media_links($source->getGedcom(), 1); } echo print_fact_notes($srec, $nlevel); if ($nlevel == 2) { echo print_fact_notes($source->getGedcom(), 1); } echo '</div>'; } else { echo $sid; } echo '</td></tr>'; } } }
public function format_list_details() { require_once WT_ROOT . 'includes/functions/functions_print_facts.php'; ob_start(); print_media_links('1 OBJE @' . $this->getXref() . '@', 1); return ob_get_clean(); }
function format_list_details() { ob_start(); print_media_links('1 OBJE @' . $this->getXref() . '@', 1, $this->getXref()); return ob_get_clean(); }