コード例 #1
0
ファイル: FunctionsPrint.php プロジェクト: jflash/webtrees
 /**
  * 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
  */
 public static function printFactNotes($factrec, $level, $textOnly = false)
 {
     global $WT_TREE;
     $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 .= self::printNoteRecord($match[$j][1], $nlevel, $nrec, $textOnly);
         } else {
             $note = Note::getInstance($nmatch[1], $WT_TREE);
             if ($note) {
                 if ($note->canShow()) {
                     $noterec = $note->getGedcom();
                     $nt = preg_match("/0 @{$nmatch['1']}@ NOTE (.*)/", $noterec, $n1match);
                     $data .= self::printNoteRecord($nt > 0 ? $n1match[1] : "", 1, $noterec, $textOnly);
                     if (!$textOnly) {
                         if (strpos($noterec, '1 SOUR') !== false) {
                             $data .= FunctionsPrintFacts::printFactSources($noterec, 1);
                         }
                     }
                 }
             } else {
                 $data = '<div class="fact_NOTE"><span class="label">' . 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 .= FunctionsPrintFacts::printFactSources($nrec, $nlevel);
                 $data .= "</div>";
             }
         }
     }
     return $data;
 }
コード例 #2
0
 /**
  * print information for a name record
  *
  * @param Fact $event the event object
  */
 public function printNameRecord(Fact $event)
 {
     $factrec = $event->getGedcom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $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->isPendingDeletion()) {
         echo ' old';
     }
     if ($event->isPendingAddition()) {
         echo ' new';
     }
     echo '">';
     echo '<div class="name1">';
     echo '<dl><dt class="label">', I18N::translate('Name'), '</dt>';
     $dummy->setPrimaryName(0);
     echo '<dd class="field">', $dummy->getFullName();
     if ($this->name_count == 1) {
         if (Auth::isAdmin()) {
             $user = User::findByGenealogyRecord($this->record);
             if ($user) {
                 echo '<span> - <a class="warning" href="admin_users.php?filter=' . Filter::escapeHtml($user->getUserName()) . '">' . Filter::escapeHtml($user->getUserName()) . '</a></span>';
             }
         }
     }
     if ($this->record->canEdit() && !$event->isPendingDeletion()) {
         echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . 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=\"" . I18N::translate('Edit name') . "\"><span class=\"link_text\">" . 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">', GedcomTag::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 = Filter::escapeHtml($nmatch[$i][2]);
                 $name = str_replace('/', '', $name);
                 $name = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $name);
                 switch ($fact) {
                     case 'TYPE':
                         echo GedcomCodeName::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 = Filter::escapeHtml($primary_name['surname']);
                         if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) {
                             echo '<span dir="auto">' . $surname . '</span>';
                         } else {
                             echo I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $surname . '</span>', '<span dir="auto">' . $name . '</span>');
                         }
                         break;
                     default:
                         echo '<span dir="auto">' . $name . '</span>';
                         break;
                 }
             }
             echo '</dd>';
             echo '</dl>';
         }
         echo '</div>';
     }
     if (preg_match("/\n2 SOUR/", $factrec)) {
         echo '<div id="indi_sour" class="clearfloat">', FunctionsPrintFacts::printFactSources($factrec, 2), '</div>';
     }
     if (preg_match("/\n2 NOTE/", $factrec)) {
         echo '<div id="indi_note" class="clearfloat">', FunctionsPrint::printFactNotes($factrec, 2), '</div>';
     }
     echo '</div>';
 }
コード例 #3
0
ファイル: medialist.php プロジェクト: josefpavlik/webtrees
                 echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype));
             }
         }
         echo GedcomTag::getLabelValue('FORM', $mediaobject->mimeType());
         echo GedcomTag::getLabelValue('__FILE_SIZE__', $mediaobject->getFilesize());
         $imgsize = $mediaobject->getImageAttributes();
         if ($imgsize['WxH']) {
             echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
         }
     } else {
         echo '<p class="ui-state-error">', I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '</p>';
     }
 }
 echo '<br>';
 echo '<div>';
 echo FunctionsPrintFacts::printFactSources($mediaobject->getGedcom(), 1);
 echo FunctionsPrint::printFactNotes($mediaobject->getGedcom(), 1);
 echo '</div>';
 foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) {
     echo '<a href="' . $individual->getHtmlUrl() . '">' . I18N::translate('View individual') . ' — ' . $individual->getFullName() . '</a><br>';
 }
 foreach ($mediaobject->linkedFamilies('OBJE') as $family) {
     echo '<a href="' . $family->getHtmlUrl() . '">' . I18N::translate('View family') . ' — ' . $family->getFullName() . '</a><br>';
 }
 foreach ($mediaobject->linkedSources('OBJE') as $source) {
     echo '<a href="' . $source->getHtmlUrl() . '">' . I18N::translate('View source') . ' — ' . $source->getFullName() . '</a><br>';
 }
 echo '</td></tr></table>';
 echo '</td>';
 if (++$n % $columns == 0 && $n < $count) {
     echo '</tr><tr>';