Esempio n. 1
0
 /**
  * Print a row for the notes tab on the individual page.
  *
  * @param Fact $fact
  * @param int $level
  */
 public static function printMainNotes(Fact $fact, $level)
 {
     $factrec = $fact->getGedcom();
     $fact_id = $fact->getFactId();
     $parent = $fact->getParent();
     $pid = $parent->getXref();
     if ($fact->isPendingAddition()) {
         $styleadd = ' new';
         $can_edit = $level == 1 && $fact->canEdit();
     } elseif ($fact->isPendingDeletion()) {
         $styleadd = ' old';
         $can_edit = false;
     } else {
         $styleadd = '';
         $can_edit = $level == 1 && $fact->canEdit();
     }
     $ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER);
     for ($j = 0; $j < $ct; $j++) {
         // Note object, or inline note?
         if (preg_match("/{$level} NOTE @(.*)@/", $match[$j][0], $nmatch)) {
             $note = Note::getInstance($nmatch[1], $fact->getParent()->getTree());
             if ($note && !$note->canShow()) {
                 continue;
             }
         } else {
             $note = null;
         }
         if ($level >= 2) {
             echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">';
         } else {
             echo '<tr><td class="descriptionbox ', $styleadd, ' width20">';
         }
         if ($can_edit) {
             echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', I18N::translate('Edit'), '">';
             if ($level < 2) {
                 if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
                     echo '<i class="icon-note"></i> ';
                 }
                 if ($note) {
                     echo GedcomTag::getLabel('SHARED_NOTE');
                 } else {
                     echo GedcomTag::getLabel('NOTE');
                 }
                 echo '</a>';
                 echo '<div class="editfacts">';
                 echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Edit') . "\"><span class=\"link_text\">" . I18N::translate('Edit') . "</span></a></div>";
                 echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
                 echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . I18N::translate('Delete') . "\"><span class=\"link_text\">" . I18N::translate('Delete') . "</span></a></div>";
                 if ($note) {
                     echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a>';
                 }
                 echo '</div>';
             }
         } else {
             if ($level < 2) {
                 if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
                     echo '<i class="icon-note"></i> ';
                 }
                 if ($note) {
                     echo GedcomTag::getLabel('SHARED_NOTE');
                 } else {
                     echo GedcomTag::getLabel('NOTE');
                 }
             }
             $factlines = explode("\n", $factrec);
             // 1 BIRT Y\n2 NOTE ...
             $factwords = explode(" ", $factlines[0]);
             // 1 BIRT Y
             $factname = $factwords[1];
             // BIRT
             $parent = GedcomRecord::getInstance($pid, $fact->getParent()->getTree());
             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 GedcomTag::getLabel($factname, $parent);
                 }
             } elseif ($factname != 'NOTE') {
                 // Note is already printed
                 echo GedcomTag::getLabel($factname, $parent);
                 if ($note) {
                     echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . I18N::translate('View') . '"><span class="link_text">' . I18N::translate('View') . '</span></a></div>';
                 }
             }
         }
         echo '</td>';
         if ($note) {
             // Note objects
             if (Module::getModuleByName('GEDFact_assistant')) {
                 // If Census assistant installed, allow it to format the note
                 $text = CensusAssistantModule::formatCensusNote($note);
             } else {
                 $text = Filter::formatText($note->getNote(), $fact->getParent()->getTree());
             }
         } else {
             // Inline notes
             $nrec = Functions::getSubRecord($level, "{$level} NOTE", $factrec, $j + 1);
             $text = $match[$j][1] . Functions::getCont($level + 1, $nrec);
             $text = Filter::formatText($text, $fact->getParent()->getTree());
         }
         echo '<td class="optionbox', $styleadd, ' wrap">';
         echo $text;
         if (!empty($noterec)) {
             echo self::printFactSources($noterec, 1);
         }
         // 2 RESN tags.  Note, there can be more than one, such as "privacy" and "locked"
         if (preg_match_all("/\n2 RESN (.+)/", $factrec, $matches)) {
             foreach ($matches[1] as $match) {
                 echo '<br><span class="label">', GedcomTag::getLabel('RESN'), ':</span> <span class="field">';
                 switch ($match) {
                     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> ', I18N::translate('Show to visitors');
                         break;
                     case 'privacy':
                         echo '<i class="icon-resn-privacy"></i> ', I18N::translate('Show to members');
                         break;
                     case 'confidential':
                         echo '<i class="icon-resn-confidential"></i> ', I18N::translate('Show to managers');
                         break;
                     case 'locked':
                         echo '<i class="icon-resn-locked"></i> ', I18N::translate('Only managers can edit');
                         break;
                     default:
                         echo $match;
                         break;
                 }
                 echo '</span>';
             }
         }
         echo '</td></tr>';
     }
 }
Esempio n. 2
0
 /**
  * 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
  *
  * @return string
  */
 public static function printNoteRecord($text, $nlevel, $nrec, $textOnly = false)
 {
     global $WT_TREE;
     $text .= Functions::getCont($nlevel, $nrec);
     // Check if shared note (we have already checked that it exists)
     if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
         $note = Note::getInstance($match[1], $WT_TREE);
         $label = 'SHARED_NOTE';
         // If Census assistant installed, allow it to format the note
         if (Module::getModuleByName('GEDFact_assistant')) {
             $html = CensusAssistantModule::formatCensusNote($note);
         } else {
             $html = Filter::formatText($note->getNote(), $WT_TREE);
         }
     } else {
         $note = null;
         $label = 'NOTE';
         $html = Filter::formatText($text, $WT_TREE);
     }
     if ($textOnly) {
         return strip_tags($text);
     }
     if (strpos($text, "\n") === false) {
         // A one-line note? strip the block-level tags, so it displays inline
         return GedcomTag::getLabelValue($label, strip_tags($html, '<a><strong><em>'));
     } elseif ($WT_TREE->getPreference('EXPAND_NOTES')) {
         // A multi-line note, and we're expanding notes by default
         return GedcomTag::getLabelValue($label, $html);
     } else {
         // A multi-line note, with an expand/collapse option
         $element_id = Uuid::uuid4();
         // NOTE: class "note-details" is (currently) used only by some third-party themes
         if ($note) {
             $first_line = '<a href="' . $note->getHtmlUrl() . '">' . $note->getFullName() . '</a>';
         } else {
             list($text) = explode("\n", strip_tags($html));
             $first_line = strlen($text) > 100 ? mb_substr($text, 0, 100) . I18N::translate('…') : $text;
         }
         return '<div class="fact_NOTE"><span class="label">' . '<a href="#" onclick="expand_layer(\'' . $element_id . '\'); return false;"><i id="' . $element_id . '_img" class="icon-plus"></i></a> ' . GedcomTag::getLabel($label) . ':</span> ' . '<span id="' . $element_id . '-alt">' . $first_line . '</span>' . '</div>' . '<div class="note-details" id="' . $element_id . '" style="display:none">' . $html . '</div>';
     }
 }
Esempio n. 3
0
			}
		});
');
$linked_indi = $controller->record->linkedIndividuals('NOTE');
$linked_fam = $controller->record->linkedFamilies('NOTE');
$linked_obje = $controller->record->linkedMedia('NOTE');
$linked_sour = $controller->record->linkedSources('NOTE');
$facts = array();
foreach ($controller->record->getFacts() as $fact) {
    if ($fact->getTag() != 'CONT') {
        $facts[] = $fact;
    }
}
// Legacy formatting, created by the census assistant
if (Module::getModuleByName('GEDFact_assistant')) {
    $text = CensusAssistantModule::formatCensusNote($controller->record);
} else {
    $text = Filter::formatText($controller->record->getNote(), $controller->record->getTree());
}
?>
<div id="note-details">
	<h2><?php 
echo $controller->record->getFullName();
?>
</h2>
	<div id="note-tabs">
		<ul>
			<li>
				<a href="#note-edit">
					<span><?php 
echo I18N::translate('Details');