/** * 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>'; }
/** * Generate the HTML content of this tab. * * @return string */ public function getTabContent() { global $WT_TREE, $controller; $html = '<div id="' . $this->getName() . '_content">'; //Show Lightbox-Album header Links if (Auth::isEditor($WT_TREE)) { $html .= '<table class="facts_table"><tr><td class="descriptionbox rela">'; // Add a new media object if ($WT_TREE->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($WT_TREE)) { $html .= '<span><a href="#" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=' . $controller->record->getXref() . '\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=780,width=600\');return false;">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_add.png" id="head_icon" class="icon" title="' . I18N::translate('Add a new media object') . '" alt="' . I18N::translate('Add a new media object') . '">'; $html .= I18N::translate('Add a new media object'); $html .= '</a></span>'; // Link to an existing item $html .= '<span><a href="#" onclick="window.open(\'inverselink.php?linktoid=' . $controller->record->getXref() . '&linkto=person\', \'_blank\', \'resizable=1,scrollbars=1,top=50,height=300,width=450\');">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/image_link.png" id="head_icon" class="icon" title="' . I18N::translate('Link to an existing media object') . '" alt="' . I18N::translate('Link to an existing media object') . '">'; $html .= I18N::translate('Link to an existing media object'); $html .= '</a></span>'; } if (Auth::isManager($WT_TREE) && $this->getMedia()) { // Popup Reorder Media $html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">'; $html .= '<img src="' . Theme::theme()->assetUrl() . 'images/images.png" id="head_icon" class="icon" title="' . I18N::translate('Re-order media') . '" alt="' . I18N::translate('Re-order media') . '">'; $html .= I18N::translate('Re-order media'); $html .= '</a></span>'; } $html .= '</td></tr></table>'; } // Used when sorting media on album tab page $html .= '<table class="facts_table"><tr><td class="facts_value">'; // one-cell table - for presentation only $html .= '<ul class="album-list">'; foreach ($this->getMedia() as $media) { //View Edit Menu ---------------------------------- //Get media item Notes $haystack = $media->getGedcom(); $needle = '1 NOTE'; $before = substr($haystack, 0, strpos($haystack, $needle)); $after = substr(strstr($haystack, $needle), strlen($needle)); $notes = FunctionsPrint::printFactNotes($before . $needle . $after, 1, true); // Prepare Below Thumbnail menu ---------------------------------------------------- $menu = new Menu('<div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap">' . $media->getFullName() . '</div>'); $menu->addClass('', 'submenu'); // View Notes if (strpos($media->getGedcom(), "\n1 NOTE")) { $submenu = new Menu(I18N::translate('View notes'), '#', '', array('onclick' => 'modalNotes("' . Filter::escapeJs($notes) . '","' . I18N::translate('View notes') . '"); return false;')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } //View Details $submenu = new Menu(I18N::translate('View details'), $media->getHtmlUrl()); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); //View Sources foreach ($media->getFacts('SOUR') as $source_fact) { $source = $source_fact->getTarget(); if ($source && $source->canShow()) { $submenu = new Menu(I18N::translate('Source') . ' – ' . $source->getFullName(), $source->getHtmlUrl()); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); } } if (Auth::isEditor($media->getTree())) { // Edit Media $submenu = new Menu(I18N::translate('Edit media'), '#', '', array('onclick' => 'return window.open("addmedia.php?action=editmedia&pid=' . $media->getXref() . '", "_blank", edit_window_specs);')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); if (Auth::isAdmin()) { if (Module::getModuleByName('GEDFact_assistant')) { $submenu = new Menu(I18N::translate('Manage links'), '#', '', array('onclick' => 'return window.open("inverselink.php?mediaid=' . $media->getXref() . '&linkto=manage", "_blank", find_window_specs);')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } else { $submenu = new Menu(I18N::translate('Link this media object to an individual'), '#', 'menu-obje-link-indi', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","person");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); $submenu = new Menu(I18N::translate('Link this media object to a family'), '#', 'menu-obje-link-fam', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","family");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); $submenu = new Menu(I18N::translate('Link this media object to a source'), '#', 'menu-obje-link-sour', array('onclick' => 'return ilinkitem("' . $media->getXref() . '","source");')); $submenu->addClass('submenuitem'); $menu->addSubmenu($submenu); } $submenu = new Menu(I18N::translate('Unlink media'), '#', '', array('onclick' => 'return unlink_media("' . I18N::translate('Are you sure you want to remove links to this media object?') . '", "' . $controller->record->getXref() . '", "' . $media->getXref() . '");')); $submenu->addClass("submenuitem"); $menu->addSubmenu($submenu); } } $html .= '<li class="album-list-item">'; $html .= '<div class="album-image">' . $media->displayImage() . '</div>'; $html .= '<div class="album-title">' . $menu->getMenu() . '</div>'; $html .= '</li>'; } $html .= '</ul>'; $html .= '</td></tr></table>'; return $html; }
} } 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>'; }
/** * Print a row for the media tab on the individual page. * * @param Fact $fact * @param int $level */ public static function printMainMedia(Fact $fact, $level) { $factrec = $fact->getGedcom(); $parent = $fact->getParent(); 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(); } // -- find source for each fact preg_match_all('/(?:^|\\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches); foreach ($matches[1] as $xref) { $media = Media::getInstance($xref, $fact->getParent()->getTree()); // Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted if (!$media || $media->canShow()) { if ($level > 1) { echo '<tr class="row_obje2">'; } else { echo '<tr>'; } echo '<td class="descriptionbox'; if ($level > 1) { echo ' rela'; } echo ' ', $styleadd, ' width20">'; preg_match("/^\\d (\\w*)/", $factrec, $factname); $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 = $ematch[1]; echo $factname; } else { echo GedcomTag::getLabel($factname, $parent); } } elseif ($can_edit) { echo '<a onclick="window.open(\'addmedia.php?action=editmedia&pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '">'; echo GedcomTag::getLabel($factname, $parent), '</a>'; echo '<div class="editfacts">'; echo '<div class="editlink"><a class="editicon" onclick="window.open(\'addmedia.php?action=editmedia&pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '"><span class="link_text">', I18N::translate('Edit'), '</span></a></div>'; echo '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\'\', factgedcom:\'' . rawurlencode($factrec) . '\'},function(){location.reload();})" 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?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" href="#" title="', I18N::translate('Delete'), '"><span class="link_text">', I18N::translate('Delete'), '</span></a></div>'; echo '</div>'; } else { echo GedcomTag::getLabel($factname, $parent); } echo '</td>'; echo '<td class="optionbox ', $styleadd, ' wrap">'; if ($media) { echo '<span class="field">'; echo $media->displayImage(); echo '<a href="' . $media->getHtmlUrl() . '">'; echo '<em>'; foreach ($media->getAllNames() as $name) { if ($name['type'] != 'TITL') { echo '<br>'; } echo $name['full']; } echo '</em>'; echo '</a>'; echo '</span>'; echo GedcomTag::getLabelValue('FORM', $media->mimeType()); $imgsize = $media->getImageAttributes('main'); if (!empty($imgsize['WxH'])) { echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } if ($media->getFilesizeraw() > 0) { echo GedcomTag::getLabelValue('__FILE_SIZE__', $media->getFilesize()); } $mediatype = $media->getMediaType(); if ($mediatype) { echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype)); } switch ($media->isPrimary()) { case 'Y': echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes')); break; case 'N': echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no')); break; } echo FunctionsPrint::printFactNotes($media->getGedcom(), 1); echo self::printFactSources($media->getGedcom(), 1); } else { echo $xref; } echo '</td></tr>'; } } }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $filter = $this->getBlockSetting($block_id, 'filter', 'all'); $controls = $this->getBlockSetting($block_id, 'controls', '1'); $start = $this->getBlockSetting($block_id, 'start', '0') || Filter::getBool('start'); // We can apply the filters using SQL // Do not use "ORDER BY RAND()" - it is very slow on large tables. Use PHP::array_rand() instead. $all_media = Database::prepare("SELECT m_id FROM `##media`" . " WHERE m_file = ?" . " AND m_ext IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')" . " AND m_type IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')")->execute(array($WT_TREE->getTreeId(), $this->getBlockSetting($block_id, 'filter_avi', '0') ? 'avi' : null, $this->getBlockSetting($block_id, 'filter_bmp', '1') ? 'bmp' : null, $this->getBlockSetting($block_id, 'filter_gif', '1') ? 'gif' : null, $this->getBlockSetting($block_id, 'filter_jpeg', '1') ? 'jpg' : null, $this->getBlockSetting($block_id, 'filter_jpeg', '1') ? 'jpeg' : null, $this->getBlockSetting($block_id, 'filter_mp3', '0') ? 'mp3' : null, $this->getBlockSetting($block_id, 'filter_ole', '1') ? 'ole' : null, $this->getBlockSetting($block_id, 'filter_pcx', '1') ? 'pcx' : null, $this->getBlockSetting($block_id, 'filter_pdf', '0') ? 'pdf' : null, $this->getBlockSetting($block_id, 'filter_png', '1') ? 'png' : null, $this->getBlockSetting($block_id, 'filter_tiff', '1') ? 'tiff' : null, $this->getBlockSetting($block_id, 'filter_wav', '0') ? 'wav' : null, $this->getBlockSetting($block_id, 'filter_audio', '0') ? 'audio' : null, $this->getBlockSetting($block_id, 'filter_book', '1') ? 'book' : null, $this->getBlockSetting($block_id, 'filter_card', '1') ? 'card' : null, $this->getBlockSetting($block_id, 'filter_certificate', '1') ? 'certificate' : null, $this->getBlockSetting($block_id, 'filter_coat', '1') ? 'coat' : null, $this->getBlockSetting($block_id, 'filter_document', '1') ? 'document' : null, $this->getBlockSetting($block_id, 'filter_electronic', '1') ? 'electronic' : null, $this->getBlockSetting($block_id, 'filter_fiche', '1') ? 'fiche' : null, $this->getBlockSetting($block_id, 'filter_film', '1') ? 'film' : null, $this->getBlockSetting($block_id, 'filter_magazine', '1') ? 'magazine' : null, $this->getBlockSetting($block_id, 'filter_manuscript', '1') ? 'manuscript' : null, $this->getBlockSetting($block_id, 'filter_map', '1') ? 'map' : null, $this->getBlockSetting($block_id, 'filter_newspaper', '1') ? 'newspaper' : null, $this->getBlockSetting($block_id, 'filter_other', '1') ? 'other' : null, $this->getBlockSetting($block_id, 'filter_painting', '1') ? 'painting' : null, $this->getBlockSetting($block_id, 'filter_photo', '1') ? 'photo' : null, $this->getBlockSetting($block_id, 'filter_tombstone', '1') ? 'tombstone' : null, $this->getBlockSetting($block_id, 'filter_video', '0') ? 'video' : null))->fetchOneColumn(); // Keep looking through the media until a suitable one is found. $random_media = null; while ($all_media) { $n = array_rand($all_media); $media = Media::getInstance($all_media[$n], $WT_TREE); if ($media->canShow() && !$media->isExternal()) { // Check if it is linked to a suitable individual foreach ($media->linkedIndividuals('OBJE') as $indi) { if ($filter === 'all' || $filter === 'indi' && strpos($indi->getGedcom(), "\n1 OBJE @" . $media->getXref() . '@') !== false || $filter === 'event' && strpos($indi->getGedcom(), "\n2 OBJE @" . $media->getXref() . '@') !== false) { // Found one :-) $random_media = $media; break 2; } } } unset($all_media[$n]); } $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; } else { $title = ''; } $title .= $this->getTitle(); if ($random_media) { $content = "<div id=\"random_picture_container{$block_id}\">"; if ($controls) { if ($start) { $icon_class = 'icon-media-stop'; } else { $icon_class = 'icon-media-play'; } $content .= '<div dir="ltr" class="center" id="random_picture_controls' . $block_id . '"><br>'; $content .= "<a href=\"#\" onclick=\"togglePlay(); return false;\" id=\"play_stop\" class=\"" . $icon_class . "\" title=\"" . I18N::translate('Play') . "/" . I18N::translate('Stop') . '"></a>'; $content .= '<a href="#" onclick="jQuery(\'#block_' . $block_id . '\').load(\'index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '\');return false;" title="' . I18N::translate('Next image') . '" class="icon-media-next"></a>'; $content .= '</div><script> var play = false; function togglePlay() { if (play) { play = false; jQuery("#play_stop").removeClass("icon-media-stop").addClass("icon-media-play"); } else { play = true; playSlideShow(); jQuery("#play_stop").removeClass("icon-media-play").addClass("icon-media-stop"); } } function playSlideShow() { if (play) { window.setTimeout("reload_image()", 6000); } } function reload_image() { if (play) { jQuery("#block_' . $block_id . '").load("index.php?ctype=' . $ctype . '&action=ajax&block_id=' . $block_id . '&start=1"); } } </script>'; } if ($start) { $content .= '<script>togglePlay();</script>'; } $content .= '<div class="center" id="random_picture_content' . $block_id . '">'; $content .= '<table id="random_picture_box"><tr><td class="details1">'; $content .= $random_media->displayImage(); $content .= '<br>'; $content .= '<a href="' . $random_media->getHtmlUrl() . '"><b>' . $random_media->getFullName() . '</b></a><br>'; foreach ($random_media->linkedIndividuals('OBJE') as $individual) { $content .= '<a href="' . $individual->getHtmlUrl() . '">' . I18N::translate('View this individual') . ' — ' . $individual->getFullName() . '</a><br>'; } foreach ($random_media->linkedFamilies('OBJE') as $family) { $content .= '<a href="' . $family->getHtmlUrl() . '">' . I18N::translate('View this family') . ' — ' . $family->getFullName() . '</a><br>'; } foreach ($random_media->linkedSources('OBJE') as $source) { $content .= '<a href="' . $source->getHtmlUrl() . '">' . I18N::translate('View this source') . ' — ' . $source->getFullName() . '</a><br>'; } $content .= '<br><div class="indent">'; $content .= FunctionsPrint::printFactNotes($random_media->getGedcom(), "1", false); $content .= '</div>'; $content .= '</td></tr></table>'; $content .= '</div>'; // random_picture_content $content .= '</div>'; // random_picture_container } else { $content = I18N::translate('This family tree has no images to display.'); } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }