/** * print information for a name record * * @param WT_Fact $event the event object */ function print_name_record(WT_Fact $event) { global $WT_TREE; $factrec = $event->getGedcom(); // Create a dummy record, so we can extract the formatted NAME value from the event. $dummy = new WT_Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, WT_GED_ID); $all_names = $dummy->getAllNames(); $primary_name = $all_names[0]; $this->name_count++; if ($this->name_count > 1) { echo '<h3 class="name_two">', $dummy->getFullName(), '</h3>'; } //Other names accordion element echo '<div class="indi_name_details'; if ($event->isOld()) { echo ' old'; } if ($event->isNew()) { echo ' new'; } echo '">'; echo '<div class="name1">'; echo '<dl><dt class="label">', WT_I18N::translate('Name'), '</dt>'; $dummy->setPrimaryName(0); echo '<dd class="field">', $dummy->getFullName(); if ($this->name_count == 1) { if (Auth::isAdmin()) { $user = User::findByGenealogyRecord($WT_TREE, $this->record); if ($user) { echo '<span> - <a class="warning" href="admin_users.php?filter=' . WT_Filter::escapeHtml($user->getUserName()) . '">' . WT_Filter::escapeHtml($user->getUserName()) . '</a></span>'; } } } if ($this->record->canEdit() && !$event->isOld()) { echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . WT_I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete this name') . "</span></a></div>"; echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('" . $this->record->getXref() . "', '" . $event->getFactId() . "'); return false;\" title=\"" . WT_I18N::translate('Edit name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit name') . "</span></a></div>"; } echo '</dd>'; echo '</dl>'; echo '</div>'; $ct = preg_match_all('/\\n2 (\\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER); for ($i = 0; $i < $ct; $i++) { echo '<div>'; $fact = $nmatch[$i][1]; if ($fact != 'SOUR' && $fact != 'NOTE' && $fact != 'SPFX') { echo '<dl><dt class="label">', WT_Gedcom_Tag::getLabel($fact, $this->record), '</dt>'; echo '<dd class="field">'; // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element if (isset($nmatch[$i][2])) { $name = WT_Filter::escapeHtml($nmatch[$i][2]); $name = str_replace('/', '', $name); $name = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $name); switch ($fact) { case 'TYPE': echo WT_Gedcom_Code_Name::getValue($name, $this->record); break; case 'SURN': // The SURN field is not necessarily the surname. // Where it is not a substring of the real surname, show it after the real surname. $surname = WT_Filter::escapeHtml($primary_name['surname']); if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) { echo $surname; } else { echo WT_I18N::translate('%1$s (%2$s)', $surname, $name); } break; default: echo $name; break; } } echo '</dd>'; echo '</dl>'; } echo '</div>'; } if (preg_match("/\n2 SOUR/", $factrec)) { echo '<div id="indi_sour" class="clearfloat">', print_fact_sources($factrec, 2), '</div>'; } if (preg_match("/\n2 NOTE/", $factrec)) { echo '<div id="indi_note" class="clearfloat">', print_fact_notes($factrec, 2), '</div>'; } echo '</div>'; }