/** * print fact PLACe TEMPle STATus * * @param string $factrec gedcom fact record * @param boolean $anchor option to print a link to placelist * @param boolean $sub option to print place subrecords * @param boolean $lds option to print LDS TEMPle and STATus */ function print_fact_place($factrec, $anchor = false, $sub = false, $lds = false) { global $SHOW_PEDIGREE_PLACES, $TEMPLE_CODES, $pgv_lang, $factarray, $SEARCH_SPIDER; $out = false; $ct = preg_match("/2 PLAC (.*)/", $factrec, $match); if ($ct > 0) { print " "; $levels = preg_split("/,/", $match[1]); if ($anchor && empty($SEARCH_SPIDER)) { $place = trim($match[1]); // reverse the array so that we get the top level first $levels = array_reverse($levels); print "<a href=\"placelist.php?action=show&"; foreach ($levels as $pindex => $ppart) { // routine for replacing ampersands $ppart = preg_replace("/amp\\%3B/", "", trim($ppart)); print "parent[{$pindex}]=" . PrintReady($ppart) . "&"; } print "level=" . count($levels); print "\"> " . PrintReady($place) . "</a>"; } else { if (empty($SEARCH_SPIDER)) { print " -- "; } for ($level = 0; $level < $SHOW_PEDIGREE_PLACES; $level++) { if (!empty($levels[$level])) { if ($level > 0) { print ", "; } print PrintReady($levels[$level]); } } } } $ctn = 0; if ($sub) { $placerec = get_sub_record(2, "2 PLAC", $factrec); if (!empty($placerec)) { $cts = preg_match("/\\d ROMN (.*)/", $placerec, $match); if ($cts > 0) { // if ($ct>0) print "<br />\n"; if ($ct > 0) { print " - "; } print " " . PrintReady($match[1]); } $cts = preg_match("/\\d _HEB (.*)/", $placerec, $match); if ($cts > 0) { // if ($ct>0) print "<br />\n"; if ($ct > 0) { print " - "; } print " " . PrintReady($match[1]); } $map_lati = ""; $cts = preg_match("/\\d LATI (.*)/", $placerec, $match); if ($cts > 0) { $map_lati = $match[1]; print "<br /><span class=\"label\">" . $factarray["LATI"] . ": </span>" . $map_lati; } $map_long = ""; $cts = preg_match("/\\d LONG (.*)/", $placerec, $match); if ($cts > 0) { $map_long = $match[1]; print " <span class=\"label\">" . $factarray["LONG"] . ": </span>" . $map_long; } if ($map_lati and $map_long) { $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. ")); // S5,6789 ==> -5.6789 $map_long = trim(strtr($map_long, "NSEW,�", " - -. ")); // E3.456� ==> 3.456 print " <a target=\"_BLANK\" href=\"http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=decimal&latitude=" . $map_lati . "&longitude=" . $map_long . "\"><img src=\"images/mapq.gif\" border=\"0\" alt=\"Mapquest ©\" title=\"Mapquest ©\" /></a>"; print " <a target=\"_BLANK\" href=\"http://maps.google.com/maps?q=" . $map_lati . "," . $map_long . "\"><img src=\"images/bubble.gif\" border=\"0\" alt=\"Google Maps ©\" title=\"Google Maps ©\" /></a>"; print " <a target=\"_BLANK\" href=\"http://www.multimap.com/map/browse.cgi?lat=" . $map_lati . "&lon=" . $map_long . "&scale=&icon=x\"><img src=\"images/multim.gif\" border=\"0\" alt=\"Multimap ©\" title=\"Multimap ©\" /></a>"; print " <a target=\"_BLANK\" href=\"http://www.terraserver.com/imagery/image_gx.asp?cpx=" . $map_long . "&cpy=" . $map_lati . "&res=30&provider_id=340\"><img src=\"images/terrasrv.gif\" border=\"0\" alt=\"TerraServer ©\" title=\"TerraServer ©\" /></a>"; } $ctn = preg_match("/\\d NOTE (.*)/", $placerec, $match); if ($ctn > 0) { print_fact_notes($placerec, 3); $out = true; } } } if ($lds) { $ct = preg_match("/2 TEMP (.*)/", $factrec, $match); if ($ct > 0) { $tcode = trim($match[1]); if (array_key_exists($tcode, $TEMPLE_CODES)) { print $pgv_lang["temple"] . ": " . $TEMPLE_CODES[$tcode]; } else { print $pgv_lang["temple_code"] . $tcode; } } $ct = preg_match("/2 STAT (.*)/", $factrec, $match); if ($ct > 0) { print "<br />" . $pgv_lang["status"] . ": "; print trim($match[1]); } } }
/** * 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>'; }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $foundlist; $filter = get_block_setting($block_id, 'filter', 'all'); $controls = get_block_setting($block_id, 'controls', true); $start = get_block_setting($block_id, 'start', false) || WT_Filter::getBool('start'); $block = get_block_setting($block_id, 'block', true); // 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 = WT_DB::prepare("SELECT m_id FROM `##media`" . " WHERE m_file = ?" . " AND m_ext IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')" . " AND m_type IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '')")->execute(array(WT_GED_ID, get_block_setting($block_id, 'filter_avi', false) ? 'avi' : NULL, get_block_setting($block_id, 'filter_bmp', true) ? 'bmp' : NULL, get_block_setting($block_id, 'filter_gif', true) ? 'gif' : NULL, get_block_setting($block_id, 'filter_jpeg', true) ? 'jpg' : NULL, get_block_setting($block_id, 'filter_jpeg', true) ? 'jpeg' : NULL, get_block_setting($block_id, 'filter_mp3', false) ? 'mp3' : NULL, get_block_setting($block_id, 'filter_ole', true) ? 'ole' : NULL, get_block_setting($block_id, 'filter_pcx', true) ? 'pcx' : NULL, get_block_setting($block_id, 'filter_pdf', false) ? 'pdf' : NULL, get_block_setting($block_id, 'filter_png', true) ? 'png' : NULL, get_block_setting($block_id, 'filter_tiff', true) ? 'tiff' : NULL, get_block_setting($block_id, 'filter_wav', false) ? 'wav' : NULL, get_block_setting($block_id, 'filter_audio', false) ? 'audio' : NULL, get_block_setting($block_id, 'filter_book', true) ? 'book' : NULL, get_block_setting($block_id, 'filter_card', true) ? 'card' : NULL, get_block_setting($block_id, 'filter_certificate', true) ? 'certificate' : NULL, get_block_setting($block_id, 'filter_coat', true) ? 'coat' : NULL, get_block_setting($block_id, 'filter_document', true) ? 'document' : NULL, get_block_setting($block_id, 'filter_electronic', true) ? 'electronic' : NULL, get_block_setting($block_id, 'filter_fiche', true) ? 'fiche' : NULL, get_block_setting($block_id, 'filter_film', true) ? 'film' : NULL, get_block_setting($block_id, 'filter_magazine', true) ? 'magazine' : NULL, get_block_setting($block_id, 'filter_manuscript', true) ? 'manuscript' : NULL, get_block_setting($block_id, 'filter_map', true) ? 'map' : NULL, get_block_setting($block_id, 'filter_newspaper', true) ? 'newspaper' : NULL, get_block_setting($block_id, 'filter_other', true) ? 'other' : NULL, get_block_setting($block_id, 'filter_painting', true) ? 'painting' : NULL, get_block_setting($block_id, 'filter_photo', true) ? 'photo' : NULL, get_block_setting($block_id, 'filter_tombstone', true) ? 'tombstone' : NULL, get_block_setting($block_id, 'filter_video', false) ? '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 = WT_Media::getInstance($all_media[$n]); 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' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } 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=\"" . WT_I18N::translate('Play') . "/" . WT_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="' . WT_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'; if ($block) { $content .= ' class="details1"'; } else { $content .= ' class="details2"'; } $content .= ' >'; $content .= $random_media->displayImage(); if ($block) { $content .= '<br>'; } else { $content .= '</td><td class="details2">'; } $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() . '">' . WT_I18N::translate('View person') . ' — ' . $individual->getFullname() . '</a><br>'; } foreach ($random_media->linkedFamilies('OBJE') as $family) { $content .= '<a href="' . $family->getHtmlUrl() . '">' . WT_I18N::translate('View family') . ' — ' . $family->getFullname() . '</a><br>'; } foreach ($random_media->linkedSources('OBJE') as $source) { $content .= '<a href="' . $source->getHtmlUrl() . '">' . WT_I18N::translate('View source') . ' — ' . $source->getFullname() . '</a><br>'; } $content .= '<br><div class="indent">'; $content .= print_fact_notes($random_media->getGedcom(), "1", false, true); $content .= '</div>'; $content .= '</td></tr></table>'; $content .= '</div>'; // random_picture_content $content .= '</div>'; // random_picture_container } else { $content = WT_I18N::translate('This family tree has no images to display.'); } if ($template) { require WT_THEME_DIR . 'templates/block_main_temp.php'; } else { return $content; } }
function print_main_media(WT_Fact $fact, $level) { $factrec = $fact->getGedcom(); $parent = $fact->getParent(); 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 preg_match_all('/(?:^|\\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches); foreach ($matches[1] as $xref) { $media = WT_Media::getInstance($xref); // 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 WT_Gedcom_Tag::getLabel($factname, $parent); } } else { if ($can_edit) { echo '<a onclick="window.open(\'addmedia.php?action=editmedia&pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', WT_I18N::translate('Edit'), '">'; echo WT_Gedcom_Tag::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="', WT_I18N::translate('Edit'), '"><span class="link_text">', WT_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="' . 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?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" 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 ($media) { echo '<span class="field">'; echo $media->displayImage(); if (empty($SEARCH_SPIDER)) { echo '<a href="' . $media->getHtmlUrl() . '">'; } echo '<em>'; foreach ($media->getAllNames() as $name) { if ($name['type'] != 'TITL') { echo '<br>'; } echo $name['full']; } echo '</em>'; if (empty($SEARCH_SPIDER)) { echo '</a>'; } echo '</span>'; echo WT_Gedcom_Tag::getLabelValue('FORM', $media->mimeType()); $imgsize = $media->getImageAttributes('main'); if (!empty($imgsize['WxH'])) { echo WT_Gedcom_Tag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } if ($media->getFilesizeraw() > 0) { echo WT_Gedcom_Tag::getLabelValue('__FILE_SIZE__', $media->getFilesize()); } $mediatype = $media->getMediaType(); if ($mediatype) { echo WT_Gedcom_Tag::getLabelValue('TYPE', WT_Gedcom_Tag::getFileFormTypeValue($mediatype)); } switch ($media->isPrimary()) { case 'Y': echo WT_Gedcom_Tag::getLabelValue('_PRIM', WT_I18N::translate('yes')); break; case 'N': echo WT_Gedcom_Tag::getLabelValue('_PRIM', WT_I18N::translate('no')); break; } echo print_fact_notes($media->getGedcom(), 1); echo print_fact_sources($media->getGedcom(), 1); } else { echo $xref; } echo '</td></tr>'; } } }
/** * print fact PLACe TEMPle STATus * * @param WT_Fact $event gedcom fact record * @param bool $anchor to print a link to placelist * @param bool $sub_records to print place subrecords * @param bool $lds to print LDS TEMPle and STATus * * @return string HTML */ function format_fact_place(WT_Fact $event, $anchor = false, $sub_records = false, $lds = false) { global $SEARCH_SPIDER; if ($anchor) { // Show the full place name, for facts/events tab if ($SEARCH_SPIDER) { $html = $event->getPlace()->getFullName(); } else { $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>'; } } else { // Abbreviate the place name, for chart boxes return ' - ' . $event->getPlace()->getShortName(); } if ($sub_records) { $placerec = get_sub_record(2, '2 PLAC', $event->getGedcom()); if (!empty($placerec)) { if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) { foreach ($matches[1] as $match) { $wt_place = new WT_Place($match, WT_GED_ID); $html .= ' - ' . $wt_place->getFullName(); } } $map_lati = ""; $cts = preg_match('/\\d LATI (.*)/', $placerec, $match); if ($cts > 0) { $map_lati = $match[1]; $html .= '<br><span class="label">' . WT_Gedcom_Tag::getLabel('LATI') . ': </span>' . $map_lati; } $map_long = ''; $cts = preg_match('/\\d LONG (.*)/', $placerec, $match); if ($cts > 0) { $map_long = $match[1]; $html .= ' <span class="label">' . WT_Gedcom_Tag::getLabel('LONG') . ': </span>' . $map_long; } if ($map_lati && $map_long) { $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. ")); // S5,6789 ==> -5.6789 $map_long = trim(strtr($map_long, "NSEW,�", " - -. ")); // E3.456� ==> 3.456 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . WT_I18N::translate('Google Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . WT_I18N::translate('Bing Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . WT_I18N::translate('OpenStreetMap™') . '"></a>'; } if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) { $html .= '<br>' . print_fact_notes($placerec, 3); } } } if ($lds) { if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . WT_I18N::translate('LDS temple') . ': ' . WT_Gedcom_Code_Temp::templeName($match[1]); } if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . WT_I18N::translate('Status') . ': ' . WT_Gedcom_Code_Stat::statusName($match[1]); if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) { $date = new WT_Date($match[1]); $html .= ', ' . WT_Gedcom_Tag::getLabel('STAT:DATE') . ': ' . $date->Display(false); } } } return $html; }
/** * print information for a sex record * * Called from the individual information page * @see individual.php * @param Event $event the Event object */ function print_sex_record(&$event) { global $pgv_lang, $sex; if (!$event->canShowDetails()) { return false; } $sex = $event->getDetail(); if (empty($sex)) { $sex = "U"; } print "<td valign=\"top\"><span class=\"label\">" . $pgv_lang["sex"] . ": </span><span class=\"field\">" . $this->sexarray[$sex]; if ($sex == 'M') { echo Person::sexImage('M', 'small', '', $pgv_lang['male']); } elseif ($sex == 'F') { echo Person::sexImage('F', 'small', '', $pgv_lang['female']); } else { echo Person::sexImage('U', 'small', '', $pgv_lang['unknown']); } if ($this->SEX_COUNT > 1) { if (!$this->isPrintPreview() && $this->userCanEdit() && preg_match("/PGV_OLD/", $event->getGedComRecord()) == 0) { if ($event->getLineNumber() == "new") { print "<br /><a class=\"font9\" href=\"javascript:;\" onclick=\"add_new_record('" . $this->pid . "', 'SEX'); return false;\">" . $pgv_lang["edit"] . "</a>"; } else { print "<br /><a class=\"font9\" href=\"javascript:;\" onclick=\"edit_record('" . $this->pid . "', " . $event->getLineNumber() . "); return false;\">" . $pgv_lang["edit"] . "</a> | "; print "<a class=\"font9\" href=\"javascript:;\" onclick=\"delete_record('" . $this->pid . "', " . $event->getLineNumber() . "); return false;\">" . $pgv_lang["delete"] . "</a>\n"; } } } print "<br /></span>"; // -- find sources print " "; print_fact_sources($event->getGedComRecord(), 2); //-- find the notes print " "; print_fact_notes($event->getGedComRecord(), 2); print "</td>"; }
echo WT_Gedcom_Tag::getLabelValue('FILE', $mediaobject->getFilename()); } echo WT_Gedcom_Tag::getLabelValue('FORM', $mediaobject->mimeType()); echo WT_Gedcom_Tag::getLabelValue('__FILE_SIZE__', $mediaobject->getFilesize()); $imgsize = $mediaobject->getImageAttributes(); if ($imgsize['WxH']) { echo WT_Gedcom_Tag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } } else { echo '<p class="ui-state-error">', WT_I18N::translate('The file “%s” does not exist.', $mediaobject->getFilename()), '</p>'; } } echo '<br>'; echo '<div style="white-space: normal; width: 95%;">'; echo print_fact_sources($mediaobject->getGedcom(), 1); echo print_fact_notes($mediaobject->getGedcom(), 1); echo '</div>'; foreach ($mediaobject->linkedIndividuals('OBJE') as $individual) { echo '<a href="' . $individual->getHtmlUrl() . '">' . WT_I18N::translate('View person') . ' — ' . $individual->getFullname() . '</a><br>'; } foreach ($mediaobject->linkedFamilies('OBJE') as $family) { echo '<a href="' . $family->getHtmlUrl() . '">' . WT_I18N::translate('View family') . ' — ' . $family->getFullname() . '</a><br>'; } foreach ($mediaobject->linkedSources('OBJE') as $source) { echo '<a href="' . $source->getHtmlUrl() . '">' . WT_I18N::translate('View source') . ' — ' . $source->getFullname() . '</a><br>'; } echo '</td></tr></table>'; echo '</td>'; if (++$n % $columns == 0 && $n < $count) { echo '</tr><tr>'; }
function print_random_media($block = true, $config = "", $side, $index) { global $pgv_lang, $foundlist, $MULTI_MEDIA, $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES; global $MEDIA_EXTERNAL, $MEDIA_DIRECTORY, $SHOW_SOURCES; global $MEDIATYPE, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER; global $PGV_BLOCKS, $ctype, $action; global $PGV_IMAGE_DIR, $PGV_IMAGES; if (!$MULTI_MEDIA) { return; } if (empty($config)) { $config = $PGV_BLOCKS["print_random_media"]["config"]; } if (isset($config["filter"])) { $filter = $config["filter"]; } else { $filter = "all"; } if (!isset($config['controls'])) { $config['controls'] = "yes"; } if (!isset($config['start'])) { $config['start'] = "no"; } $medialist = array(); $foundlist = array(); $medialist = get_medialist(false, '', true, true); $ct = count($medialist); if ($ct > 0) { $i = 0; $disp = false; //-- try up to 40 times to get a media to display while ($i < 40) { $error = false; $value = array_rand($medialist); if (PGV_DEBUG) { print "<br />"; print_r($medialist[$value]); print "<br />"; print "Trying " . $medialist[$value]["XREF"] . "<br />"; } $links = $medialist[$value]["LINKS"]; $disp = $medialist[$value]["EXISTS"] > 0 && $medialist[$value]["LINKED"] && $medialist[$value]["CHANGE"] != "delete"; if (PGV_DEBUG && !$disp && !$error) { $error = true; print "<span class=\"error\">" . $medialist[$value]["XREF"] . " File does not exist, or is not linked to anyone, or is marked for deletion.</span><br />"; } $disp &= displayDetailsById($medialist[$value]["XREF"], "OBJE"); $disp &= !FactViewRestricted($medialist[$value]["XREF"], $medialist[$value]["GEDCOM"]); if (PGV_DEBUG && !$disp && !$error) { $error = true; print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Failed to pass privacy</span><br />"; } $isExternal = isFileExternal($medialist[$value]["FILE"]); if ($block && !$isExternal) { $disp &= $medialist[$value]["THUMBEXISTS"] > 0; } if (PGV_DEBUG && !$disp && !$error) { $error = true; print "<span class=\"error\">" . $medialist[$value]["XREF"] . " thumbnail file could not be found</span><br />"; } // Filter according to format and type (Default: unless configured otherwise, don't filter) if (!empty($medialist[$value]["FORM"]) && isset($config["filter_" . $medialist[$value]["FORM"]]) && $config["filter_" . $medialist[$value]["FORM"]] != "yes") { $disp = false; } if (!empty($medialist[$value]["TYPE"]) && isset($config["filter_" . $medialist[$value]["TYPE"]]) && $config["filter_" . $medialist[$value]["TYPE"]] != "yes") { $disp = false; } if (PGV_DEBUG && !$disp && !$error) { $error = true; print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed Format or Type filters</span><br />"; } if ($disp && count($links) != 0) { /** link privacy allready checked in displayDetailsById foreach($links as $key=>$type) { $gedrec = find_gedcom_record($key, PGV_GED_ID); $disp &= !empty($gedrec); //-- source privacy is now available through the display details by id method // $disp &= $type!="SOUR"; $disp &= displayDetailsById($key, $type); } if (PGV_DEBUG && !$disp && !$error) {$error = true; print "<span class=\"error\">".$medialist[$value]["XREF"]." failed link privacy</span><br />";} */ if ($disp && $filter != "all") { // Apply filter criteria $ct = preg_match("/0\\s(@.*@)\\sOBJE/", $medialist[$value]["GEDCOM"], $match); $objectID = $match[1]; //-- we could probably use the database for this filter foreach ($links as $key => $type) { $gedrec = find_gedcom_record($key, PGV_GED_ID); $ct2 = preg_match("/(\\d)\\sOBJE\\s{$objectID}/", $gedrec, $match2); if ($ct2 > 0) { $objectRefLevel = $match2[1]; if ($filter == "indi" && $objectRefLevel != "1") { $disp = false; } if ($filter == "event" && $objectRefLevel == "1") { $disp = false; } if (PGV_DEBUG && !$disp && !$error) { $error = true; print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed to pass config filter</span><br />"; } } else { $disp = false; } } } } //-- leave the loop if we find an image that works if ($disp) { break; } else { if (PGV_DEBUG) { print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Will not be shown</span><br />"; } unset($medialist[$value]); } //-- if there are no more media items, then try to get some more if (count($medialist) == 0) { $medialist = get_medialist(false, '', true, true); } $i++; } if (!$disp) { return false; } $content = ""; $id = ""; $id = "random_picture{$index}"; $title = print_help_link("index_media_help", "qm", "random_picture", false, true); if ($PGV_BLOCKS["print_random_media"]["canconfig"]) { if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) { if ($ctype == "gedcom") { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>"; } } $title .= $pgv_lang["random_picture"]; $content = "<div id=\"random_picture_container{$index}\">"; if ($config['controls'] == 'yes') { if ($config['start'] == 'yes' || isset($_COOKIE['rmblockplay']) && $_COOKIE['rmblockplay'] == 'true') { $image = "stop"; } else { $image = "rarrow"; } $linkNextImage = "<a href=\"javascript: " . $pgv_lang["next_image"] . "\" onclick=\"return ajaxBlock('random_picture{$index}', 'print_random_media', '{$side}', {$index}, '{$ctype}', true);\"><img src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['rdarrow']['other']}\" border=\"0\" alt=\"{$pgv_lang['next_image']}\" title=\"{$pgv_lang['next_image']}\" /></a>"; $content .= "<div class=\"center\" id=\"random_picture_controls{$index}\"><br />"; if ($TEXT_DIRECTION == "rtl") { $content .= $linkNextImage; } $content .= "<a href=\"javascript: " . $pgv_lang["play"] . "/" . $pgv_lang["stop"] . "\" onclick=\"togglePlay(); return false;\">"; if (isset($PGV_IMAGES[$image]['other'])) { $content .= "<img id=\"play_stop\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES[$image]['other']}\" border=\"0\" alt=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" title=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" />"; } else { $content .= $pgv_lang["play"] . "/" . $pgv_lang["stop"]; } $content .= "</a>"; if ($TEXT_DIRECTION == "ltr") { $content .= $linkNextImage; } $content .= ' </div> <script language="JavaScript" type="text/javascript"> <!-- var play = false; function togglePlay() { if (play) { play = false; imgid = document.getElementById("play_stop"); imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["rarrow"]['other'] . '\'; } else { play = true; playSlideShow(); imgid = document.getElementById("play_stop"); imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\'; } } function playSlideShow() { if (play) { ajaxBlock(\'random_picture' . $index . '\', \'print_random_media\', \'' . $side . '\', ' . $index . ', \'' . $ctype . '\', false); window.setTimeout(\'playSlideShow()\', 6000); } } //--> </script>'; } if ($config['start'] == 'yes') { $content .= ' <script language="JavaScript" type="text/javascript"> <!-- play = true; imgid = document.getElementById("play_stop"); imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\'; window.setTimeout("playSlideShow()", 6000); //--> </script>'; } $content .= "<div class=\"center\" id=\"random_picture_content{$index}\">"; $imgsize = findImageSize($medialist[$value]["FILE"]); $imgwidth = $imgsize[0] + 40; $imgheight = $imgsize[1] + 150; $content .= "<table id=\"random_picture_box\" width=\"100%\"><tr><td valign=\"top\""; if ($block) { $content .= " align=\"center\" class=\"details1\""; } else { $content .= " class=\"details2\""; } $mediaid = $medialist[$value]["XREF"]; //LBox -------- change for Lightbox Album -------------------------------------------- ?> <script language="JavaScript" type="text/javascript"> <!-- function openPic(filename, width, height) { height=height+50; screenW = screen.width; screenH = screen.height; if (width>screenW-100) width=screenW-100; if (height>screenH-110) height=screenH-120; if ((filename.search(/\.je?pg$/gi)!=-1)||(filename.search(/\.gif$/gi)!=-1)||(filename.search(/\.png$/gi)!=-1)||(filename.search(/\.bmp$/gi)!=-1)) win02 = window.open('imageview.php?filename='+filename,'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1'); // win03.resizeTo(winWidth 2,winHeight 30); else window.open(unescape(filename),'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1'); win02.focus(); } --> </script><?php if (PGV_USE_LIGHTBOX) { // $content .= " ><a href=\"javascript:;\" onclick=\"return openPic('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">"; // $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">"; // $content .= "><a href=\"" . $medialist[$value]["FILE"] . "\" rel=\"clearbox[general_4]\" title=\"" . $mediaid . "\">" . "\n"; $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">"; } else { // --------------------------------------------------------------------------------------------- if ($USE_MEDIA_VIEWER) { $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">"; } else { $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('" . $medialist[$value]["FILE"] . "', {$imgwidth}, {$imgheight});\">"; } } $mediaTitle = ""; if (!empty($medialist[$value]["TITL"])) { $mediaTitle = PrintReady($medialist[$value]["TITL"]); } else { $mediaTitle = basename($medialist[$value]["FILE"]); } if ($block) { $content .= "<img src=\"" . $medialist[$value]["THUMB"] . "\" border=\"0\" class=\"thumbnail\""; if ($isExternal) { $content .= " width=\"" . $THUMBNAIL_WIDTH . "\""; } } else { $content .= "<img src=\"" . $medialist[$value]["FILE"] . "\" border=\"0\" class=\"thumbnail\" "; $imgsize = findImageSize($medialist[$value]["FILE"]); if ($imgsize[0] > 175) { $content .= "width=\"175\" "; } } $content .= " alt=\"{$mediaTitle}\" title=\"{$mediaTitle}\" />"; $content .= "</a>"; if ($block) { $content .= "<br />"; } else { $content .= "</td><td class=\"details2\">"; } $content .= "<a href=\"mediaviewer.php?mid=" . $mediaid . "\">"; $content .= "<b>" . $mediaTitle . "</b>"; $content .= "</a><br />"; ob_start(); PrintMediaLinks($medialist[$value]["LINKS"], "normal"); $content .= ob_get_clean(); $content .= "<br /><div class=\"indent" . ($TEXT_DIRECTION == "rtl" ? "_rtl" : "") . "\">"; $content .= print_fact_notes($medialist[$value]["GEDCOM"], "1", false, true); $content .= "</div>"; $content .= "</td></tr></table>"; $content .= "</div>"; // random_picture_content $content .= "</div>"; // random_picture_container global $THEME_DIR; require $THEME_DIR . 'templates/block_main_temp.php'; } }
public function getTabContent() { global $controller; $html = '<div id="' . $this->getName() . '_content">'; //Show Lightbox-Album header Links if (WT_USER_CAN_EDIT) { $html .= '<table class="facts_table"><tr><td class="descriptionbox rela">'; // Add a new media object if (get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { $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="' . WT_CSS_URL . 'images/image_add.png" id="head_icon" class="icon" title="' . WT_I18N::translate('Add a new media object') . '" alt="' . WT_I18N::translate('Add a new media object') . '">'; $html .= WT_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="' . WT_CSS_URL . 'images/image_link.png" id="head_icon" class="icon" title="' . WT_I18N::translate('Link to an existing media object') . '" alt="' . WT_I18N::translate('Link to an existing media object') . '">'; $html .= WT_I18N::translate('Link to an existing media object'); $html .= '</a></span>'; } if (WT_USER_GEDCOM_ADMIN && $this->get_media()) { // Popup Reorder Media $html .= '<span><a href="#" onclick="reorder_media(\'' . $controller->record->getXref() . '\')">'; $html .= '<img src="' . WT_CSS_URL . 'images/images.png" id="head_icon" class="icon" title="' . WT_I18N::translate('Re-order media') . '" alt="' . WT_I18N::translate('Re-order media') . '">'; $html .= WT_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->get_media() 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 = print_fact_notes($before . $needle . $after, 1, true); // Prepare Below Thumbnail menu ---------------------------------------------------- $menu = new WT_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 WT_Menu(WT_I18N::translate('View notes')); // Notes Tooltip ---------------------------------------------------- $submenu->addOnclick("modalNotes('" . WT_Filter::escapeJs($notes) . "','" . WT_I18N::translate('View notes') . "'); return false;"); $submenu->addClass("submenuitem"); $menu->addSubMenu($submenu); } //View Details $submenu = new WT_Menu(WT_I18N::translate('View details'), $media->getHtmlUrl()); $submenu->addClass("submenuitem"); $menu->addSubMenu($submenu); //View Sources $source_menu = null; foreach ($media->getFacts('SOUR') as $source_fact) { $source = $source_fact->getTarget(); if ($source && $source->canShow()) { if (!$source_menu) { // Group sources under a top level menu $source_menu = new WT_Menu(WT_I18N::translate('Sources'), '#', null, 'right', 'right'); $source_menu->addClass('submenuitem', 'submenu'); } //now add a link to the actual source as a submenu $submenu = new WT_Menu($source->getFullName(), $source->getHtmlUrl()); $submenu->addClass('submenuitem', 'submenu'); $source_menu->addSubMenu($submenu); } } if ($source_menu) { $menu->addSubMenu($source_menu); } if (WT_USER_CAN_EDIT) { // Edit Media $submenu = new WT_Menu(WT_I18N::translate('Edit media')); $submenu->addOnclick("return window.open('addmedia.php?action=editmedia&pid=" . $media->getXref() . "', '_blank', edit_window_specs);"); $submenu->addClass("submenuitem"); $menu->addSubMenu($submenu); if (Auth::isAdmin()) { // Manage Links if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { $submenu = new WT_Menu(WT_I18N::translate('Manage links')); $submenu->addOnclick("return window.open('inverselink.php?mediaid=" . $media->getXref() . "&linkto=manage', '_blank', find_window_specs);"); $submenu->addClass("submenuitem"); $menu->addSubMenu($submenu); } else { $submenu = new WT_Menu(WT_I18N::translate('Set link'), '#', null, 'right', 'right'); $submenu->addClass('submenuitem', 'submenu'); $ssubmenu = new WT_Menu(WT_I18N::translate('To individual')); $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=" . $media->getXref() . "&linkto=person', '_blank', find_window_specs);"); $ssubmenu->addClass('submenuitem', 'submenu'); $submenu->addSubMenu($ssubmenu); $ssubmenu = new WT_Menu(WT_I18N::translate('To family')); $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=" . $media->getXref() . "&linkto=family', '_blank', find_window_specs);"); $ssubmenu->addClass('submenuitem', 'submenu'); $submenu->addSubMenu($ssubmenu); $ssubmenu = new WT_Menu(WT_I18N::translate('To source')); $ssubmenu->addOnclick("return window.open('inverselink.php?mediaid=" . $media->getXref() . "&linkto=source', '_blank', find_window_specs);"); $ssubmenu->addClass('submenuitem', 'submenu'); $submenu->addSubMenu($ssubmenu); $menu->addSubMenu($submenu); } // Unlink media $submenu = new WT_Menu(WT_I18N::translate('Unlink media')); $submenu->addOnclick("return unlink_media('" . WT_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; }