Example #1
0
 public function __construct()
 {
     global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight;
     $bwidth = $Dbwidth;
     $pbwidth = $bwidth + 12;
     $pbheight = $bheight + 14;
     $xref = WT_Filter::get('famid', WT_REGEX_XREF);
     $this->record = WT_Family::getInstance($xref);
     parent::__construct();
 }
Example #2
0
 public function getTarget()
 {
     $xref = trim($this->getValue(), '@');
     switch ($this->tag) {
         case 'FAMC':
         case 'FAMS':
             return WT_Family::getInstance($xref, $this->getParent()->getGedcomId());
         case 'HUSB':
         case 'WIFE':
         case 'CHIL':
             return WT_Individual::getInstance($xref, $this->getParent()->getGedcomId());
         case 'SOUR':
             return WT_Source::getInstance($xref, $this->getParent()->getGedcomId());
         case 'OBJE':
             return WT_Media::getInstance($xref, $this->getParent()->getGedcomId());
         case 'REPO':
             return WT_Repository::getInstance($xref, $this->getParent()->getGedcomId());
         case 'NOTE':
             return WT_Note::getInstance($xref, $this->getParent()->getGedcomId());
         default:
             return WT_GedcomRecord::getInstance($xref, $this->getParent()->getGedcomId());
     }
 }
function print_media_links($factrec, $level)
{
    global $SEARCH_SPIDER, $HIDE_GEDCOM_ERRORS;
    $nlevel = $level + 1;
    if (preg_match_all("/{$level} OBJE @(.*)@/", $factrec, $omatch, PREG_SET_ORDER) == 0) {
        return;
    }
    $objectNum = 0;
    while ($objectNum < count($omatch)) {
        $media_id = $omatch[$objectNum][1];
        $media = WT_Media::getInstance($media_id);
        if ($media) {
            if ($media->canShow()) {
                if ($objectNum > 0) {
                    echo '<br class="media-separator" style="clear:both;">';
                }
                echo '<div class="media-display"><div class="media-display-image">';
                echo $media->displayImage();
                echo '</div>';
                // close div "media-display-image"
                echo '<div class="media-display-title">';
                if ($SEARCH_SPIDER) {
                    echo $media->getFullName();
                } else {
                    echo '<a href="mediaviewer.php?mid=', $media->getXref(), '&amp;ged=', WT_GEDURL, '">', $media->getFullName(), '</a>';
                }
                // NOTE: echo the notes of the media
                echo '<p>';
                echo print_fact_notes($media->getGedcom(), 1);
                $ttype = preg_match("/" . ($nlevel + 1) . " TYPE (.*)/", $media->getGedcom(), $match);
                if ($ttype > 0) {
                    $mediaType = WT_Gedcom_Tag::getFileFormTypeValue($match[1]);
                    echo '<p class="label">', WT_I18N::translate('Type'), ': </span> <span class="field">', $mediaType, '</p>';
                }
                echo '</p>';
                //-- print spouse name for marriage events
                $ct = preg_match("/WT_SPOUSE: (.*)/", $factrec, $match);
                if ($ct > 0) {
                    $spouse = WT_Individual::getInstance($match[1]);
                    if ($spouse) {
                        echo '<a href="', $spouse->getHtmlUrl(), '">';
                        echo $spouse->getFullName();
                        echo '</a>';
                    }
                    if (empty($SEARCH_SPIDER)) {
                        $ct = preg_match("/WT_FAMILY_ID: (.*)/", $factrec, $match);
                        if ($ct > 0) {
                            $famid = trim($match[1]);
                            $family = WT_Family::getInstance($famid);
                            if ($family) {
                                if ($spouse) {
                                    echo " - ";
                                }
                                echo '<a href="', $family->getHtmlUrl(), '">', WT_I18N::translate('View family'), '</a>';
                            }
                        }
                    }
                }
                echo print_fact_notes($media->getGedcom(), $nlevel);
                echo print_fact_sources($media->getGedcom(), $nlevel);
                echo '</div>';
                //close div "media-display-title"
                echo '</div>';
                //close div "media-display"
            }
        } elseif (!$HIDE_GEDCOM_ERRORS) {
            echo '<p class="ui-state-error">', $media_id, '</p>';
        }
        $objectNum++;
    }
}
Example #4
0
/**
 * print cousins list
 *
 * @param string $famid family ID
 * @param int    $personcount
 */
function print_cousins($famid, $personcount = 1)
{
    global $show_full, $bheight, $bwidth, $cbheight, $cbwidth, $WT_IMAGES, $TEXT_DIRECTION;
    $family = WT_Family::getInstance($famid);
    $fchildren = $family->getChildren();
    $kids = count($fchildren);
    $save_show_full = $show_full;
    $sbheight = $bheight;
    $sbwidth = $bwidth;
    if ($save_show_full) {
        $bheight = $cbheight;
        $bwidth = $cbwidth;
    }
    $show_full = false;
    echo '<td valign="middle" height="100%">';
    if ($kids) {
        echo '<table cellspacing="0" cellpadding="0" border="0" ><tr valign="middle">';
        if ($kids > 1) {
            echo '<td rowspan="', $kids, '" valign="middle" align="right"><img width="3px" height="', ($bheight + 9) * ($kids - 1), 'px" src="', $WT_IMAGES["vline"], '" alt=""></td>';
        }
        $ctkids = count($fchildren);
        $i = 1;
        foreach ($fchildren as $fchil) {
            if ($i == 1) {
                echo '<td><img width="10px" height="3px" align="top"';
            } else {
                echo '<td><img width="10px" height="3px"';
            }
            if ($TEXT_DIRECTION == 'ltr') {
                echo ' style="padding-right: 2px;"';
            } else {
                echo ' style="padding-left: 2px;"';
            }
            echo ' src="', $WT_IMAGES['hline'], '" alt=""></td><td>';
            print_pedigree_person($fchil, 1, 0, $personcount);
            $personcount++;
            echo '</td></tr>';
            if ($i < $ctkids) {
                echo '<tr>';
                $i++;
            }
        }
        echo '</table>';
    } else {
        // If there is known that there are no children (as opposed to no known children)
        if (preg_match('/\\n1 NCHI (\\d+)/', $family->getGedcom(), $match) && $match[1] == 0) {
            echo ' <i class="icon-childless" title="', WT_I18N::translate('This family remained childless'), '"></i>';
        }
    }
    $show_full = $save_show_full;
    if ($save_show_full) {
        $bheight = $sbheight;
        $bwidth = $sbwidth;
    }
    echo '</td>';
}
Example #5
0
 protected function createPrivateGedcomRecord($access_level)
 {
     global $SHOW_PRIVATE_RELATIONSHIPS, $SHOW_LIVING_NAMES;
     $rec = '0 @' . $this->xref . '@ INDI';
     if ($SHOW_LIVING_NAMES >= $access_level) {
         // Show all the NAME tags, including subtags
         foreach ($this->getFacts('NAME') as $fact) {
             $rec .= "\n" . $fact->getGedcom();
         }
     }
     // Just show the 1 FAMC/FAMS tag, not any subtags, which may contain private data
     preg_match_all('/\\n1 (?:FAMC|FAMS) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $rela = WT_Family::getInstance($match[1]);
         if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) {
             $rec .= $match[0];
         }
     }
     // Don’t privatize sex.
     if (preg_match('/\\n1 SEX [MFU]/', $this->gedcom, $match)) {
         $rec .= $match[0];
     }
     return $rec;
 }
Example #6
0
    private function buildIndividualMap(WT_Individual $indi, $indifacts, $famids)
    {
        global $controller;
        $GM_MAX_ZOOM = $this->getSetting('GM_MAX_ZOOM');
        // Create the markers list array
        $gmarks = array();
        sort_facts($indifacts);
        $i = 0;
        foreach ($indifacts as $fact) {
            if (!$fact->getPlace()->isEmpty()) {
                $ctla = preg_match("/\\d LATI (.*)/", $fact->getGedcom(), $match1);
                $ctlo = preg_match("/\\d LONG (.*)/", $fact->getGedcom(), $match2);
                if ($fact->getParent() instanceof WT_Family) {
                    $spouse = $fact->getParent()->getSpouse($indi);
                } else {
                    $spouse = null;
                }
                if ($ctla && $ctlo) {
                    $i++;
                    $gmarks[$i] = array('class' => 'optionbox', 'date' => $fact->getDate()->Display(true), 'fact_label' => $fact->getLabel(), 'image' => $spouse ? $spouse->displayImage() : $fact->Icon(), 'info' => $fact->getValue(), 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $match1[1]), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $match2[1]), 'name' => $spouse ? '<a href="' . $spouse->getHtmlUrl() . '"' . $spouse->getFullName() . '</a>' : '', 'pl_icon' => '', 'place' => $fact->getPlace()->getFullName(), 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'tooltip' => $fact->getPlace()->getGedcomName());
                } else {
                    $latlongval = $this->getLatitudeAndLongitudeFromPlaceLocation($fact->getPlace()->getGedcomName());
                    if ($latlongval && $latlongval->pl_lati && $latlongval->pl_long) {
                        $i++;
                        $gmarks[$i] = array('class' => 'optionbox', 'date' => $fact->getDate()->Display(true), 'fact_label' => $fact->getLabel(), 'image' => $spouse ? $spouse->displayImage() : $fact->Icon(), 'info' => $fact->getValue(), 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval->pl_lati), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval->pl_long), 'name' => $spouse ? '<a href="' . $spouse->getHtmlUrl() . '"' . $spouse->getFullName() . '</a>' : '', 'pl_icon' => $latlongval->pl_icon, 'place' => $fact->getPlace()->getFullName(), 'sv_bearing' => $latlongval->sv_bearing, 'sv_elevation' => $latlongval->sv_elevation, 'sv_lati' => $latlongval->sv_lati, 'sv_long' => $latlongval->sv_long, 'sv_zoom' => $latlongval->sv_zoom, 'tooltip' => $fact->getPlace()->getGedcomName());
                        if ($GM_MAX_ZOOM > $latlongval->pl_zoom) {
                            $GM_MAX_ZOOM = $latlongval->pl_zoom;
                        }
                    }
                }
            }
        }
        // Add children to the markers list array
        foreach ($famids as $xref) {
            $family = WT_Family::getInstance($xref);
            foreach ($family->getChildren() as $child) {
                $birth = $child->getFirstFact('BIRT');
                if ($birth) {
                    $birthrec = $birth->getGedcom();
                    if (!$birth->getPlace()->isEmpty()) {
                        $ctla = preg_match('/\\n4 LATI (.+)/', $birthrec, $match1);
                        $ctlo = preg_match('/\\n4 LONG (.+)/', $birthrec, $match2);
                        if ($ctla && $ctlo) {
                            $i++;
                            $gmarks[$i] = array('date' => $birth->getDate()->Display(true), 'image' => $child->displayImage(), 'info' => '', 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $match1[1]), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $match2[1]), 'name' => '<a href="' . $child->getHtmlUrl() . '"' . $child->getFullName() . '</a>', 'pl_icon' => '', 'place' => $birth->getPlace()->getFullName(), 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'tooltip' => $birth->getPlace()->getGedcomName());
                            switch ($child->getSex()) {
                                case 'F':
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('daughter');
                                    $gmarks[$i]['class'] = 'person_boxF';
                                    break;
                                case 'M':
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('son');
                                    $gmarks[$i]['class'] = 'person_box';
                                    break;
                                default:
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('child');
                                    $gmarks[$i]['class'] = 'person_boxNN';
                                    break;
                            }
                        } else {
                            $latlongval = $this->getLatitudeAndLongitudeFromPlaceLocation($birth->getPlace()->getGedcomName());
                            if ($latlongval && $latlongval->pl_lati && $latlongval->pl_long) {
                                $i++;
                                $gmarks[$i] = array('date' => $birth->getDate()->Display(true), 'image' => $child->displayImage(), 'info' => '', 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval->pl_lati), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval->pl_long), 'name' => '<a href="' . $child->getHtmlUrl() . '"' . $child->getFullName() . '</a>', 'pl_icon' => $latlongval->pl_icon, 'place' => $birth->getPlace()->getFullName(), 'sv_bearing' => $latlongval->sv_bearing, 'sv_elevation' => $latlongval->sv_elevation, 'sv_lati' => $latlongval->sv_lati, 'sv_long' => $latlongval->sv_long, 'sv_zoom' => $latlongval->sv_zoom, 'tooltip' => $birth->getPlace()->getGedcomName());
                                switch ($child->getSex()) {
                                    case 'M':
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('son');
                                        $gmarks[$i]['class'] = 'person_box';
                                        break;
                                    case 'F':
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('daughter');
                                        $gmarks[$i]['class'] = 'person_boxF';
                                        break;
                                    default:
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('child');
                                        $gmarks[$i]['class'] = 'option_boxNN';
                                        break;
                                }
                                if ($GM_MAX_ZOOM > $latlongval->pl_zoom) {
                                    $GM_MAX_ZOOM = $latlongval->pl_zoom;
                                }
                            }
                        }
                    }
                }
            }
        }
        // Group markers by location
        $location_groups = array();
        foreach ($gmarks as $gmark) {
            $key = $gmark['lat'] . $gmark['lng'];
            if (isset($location_groups[$key])) {
                $location_groups[$key][] = $gmark;
            } else {
                $location_groups[$key] = array($gmark);
            }
        }
        $location_groups = array_values($location_groups);
        // *** ENABLE STREETVIEW ***
        $STREETVIEW = $this->getSetting('GM_USE_STREETVIEW');
        ?>

		<script>
			// this variable will collect the html which will eventually be placed in the side_bar
			var side_bar_html = '';
			var map_center = new google.maps.LatLng(0,0);
			var gmarkers = [];
			var gicons = [];
			var map = null;
			var head = '';
			var dir = '';
			var svzoom = '';

			var infowindow = new google.maps.InfoWindow({});

			gicons["red"] = new google.maps.MarkerImage("https://maps.google.com/mapfiles/marker.png",
				new google.maps.Size(20, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconImage = new google.maps.MarkerImage("https://maps.google.com/mapfiles/marker.png",
				new google.maps.Size(20, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconShadow = new google.maps.MarkerImage("https://www.google.com/mapfiles/shadow50.png",
				new google.maps.Size(37, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconShape = {
				coord: [9,0,6,1,4,2,2,4,0,8,0,12,1,14,2,16,5,19,7,23,8,26,9,30,9,34,11,34,11,30,12,26,13,24,14,21,16,18,18,16,20,12,20,8,18,4,16,2,15,1,13,0],
				type: "poly"
			};

			function getMarkerImage(iconColor) {
				if (typeof(iconColor) === 'undefined' || iconColor === null) {
					iconColor = 'red';
				}
				if (!gicons[iconColor]) {
					gicons[iconColor] = new google.maps.MarkerImage('//maps.google.com/mapfiles/marker'+ iconColor +'.png',
					new google.maps.Size(20, 34),
					new google.maps.Point(0,0),
					new google.maps.Point(9, 34));
				}
				return gicons[iconColor];
			}

			var sv2_bear = null;
			var sv2_elev = null;
			var sv2_zoom = null;
			var placer   = null;

			// A function to create the marker and set up the event window
			function createMarker(latlng, html, tooltip, sv_lati, sv_long, sv_bearing, sv_elevation, sv_zoom, sv_point, marker_icon) {
				var contentString = '<div id="iwcontent">'+html+'</div>';

				// Use flag icon (if defined) instead of regular marker icon
				if (marker_icon) {
					var icon_image = new google.maps.MarkerImage(WT_STATIC_URL+WT_MODULES_DIR+'googlemap/'+marker_icon,
						new google.maps.Size(25, 15),
						new google.maps.Point(0,0),
						new google.maps.Point(0, 44));
					var icon_shadow = new google.maps.MarkerImage(WT_STATIC_URL+WT_MODULES_DIR+'googlemap/images/flag_shadow.png',
						new google.maps.Size(35, 45), // Shadow size
						new google.maps.Point(0,0),   // Shadow origin
						new google.maps.Point(1, 45)  // Shadow anchor is base of flagpole
					);
				} else {
					var icon_image = getMarkerImage('red');
					var icon_shadow = iconShadow;
				}

				// Decide if marker point is Regular (latlng) or StreetView (sv_point) derived
				if (sv_point == '(0, 0)' || sv_point == '(null, null)') {
					placer = latlng;
				} else {
					placer = sv_point;
				}

				// Define the marker
				var marker = new google.maps.Marker({
					position: placer,
					icon:     icon_image,
					shadow:   icon_shadow,
					map:      map,
					title:    tooltip,
					zIndex:   Math.round(latlng.lat()*-100000)<<5
				});

				// Store the tab and event info as marker properties
				marker.sv_lati  = sv_lati;
				marker.sv_long  = sv_long;
				marker.sv_point = sv_point;

				if (sv_bearing == '') {
					marker.sv_bearing = 0;
				} else {
					marker.sv_bearing = sv_bearing;
				}
				if (sv_elevation == '') {
					marker.sv_elevation = 5;
				} else {
					marker.sv_elevation = sv_elevation;
				}
				if (sv_zoom == '' || sv_zoom == 0 || sv_zoom == 1) {
					marker.sv_zoom = 1.2;
				} else {
					marker.sv_zoom = sv_zoom;
				}

				marker.sv_latlng = new google.maps.LatLng(sv_lati, sv_long);
				gmarkers.push(marker);

				// Open infowindow when marker is clicked
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.close();
					infowindow.setContent(contentString);
					infowindow.open(map, marker);
					var panoramaOptions = {
						position:          marker.position,
						mode:              'html5',
						navigationControl: false,
						linksControl:      false,
						addressControl:    false,
						pov: {
							heading: sv_bearing,
							pitch:   sv_elevation,
							zoom:    sv_zoom
						}
					};

					// Use jquery for info window tabs
					google.maps.event.addListener(infowindow, 'domready', function() {
		  	    //jQuery code here
						jQuery('#EV').click(function() {
							document.tabLayerEV = document.getElementById("EV");
							document.tabLayerEV.style.background = '#ffffff';
							document.tabLayerEV.style.paddingBottom = '1px';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.tabLayerSV = document.getElementById("SV");
							document.tabLayerSV.style.background = '#cccccc';
							document.tabLayerSV.style.paddingBottom = '0px';
							<?php 
        }
        ?>
							document.panelLayer1 = document.getElementById("pane1");
							document.panelLayer1.style.display = 'block';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.panelLayer2 = document.getElementById("pane2");
							document.panelLayer2.style.display = 'none';
							<?php 
        }
        ?>
						});

						jQuery('#SV').click(function() {
							document.tabLayerEV = document.getElementById("EV");
							document.tabLayerEV.style.background = '#cccccc';
							document.tabLayerEV.style.paddingBottom = '0px';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.tabLayerSV = document.getElementById("SV");
							document.tabLayerSV.style.background = '#ffffff';
							document.tabLayerSV.style.paddingBottom = '1px';
							<?php 
        }
        ?>
							document.panelLayer1 = document.getElementById("pane1");
							document.panelLayer1.style.display = 'none';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.panelLayer2 = document.getElementById("pane2");
							document.panelLayer2.style.display = 'block';
							<?php 
        }
        ?>
							var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);
							setTimeout(function() { panorama.setVisible(true); }, 100);
							setTimeout(function() { panorama.setVisible(true); }, 500);
						});
					});
				});
			}

			// Opens Marker infowindow when corresponding Sidebar item is clicked
			function myclick(i) {
				infowindow.close();
				google.maps.event.trigger(gmarkers[i], 'click');
			}

			// Home control
			// returns the user to the original map position ... loadMap() function
			// This constructor takes the control DIV as an argument.
			function HomeControl(controlDiv, map) {
				// Set CSS styles for the DIV containing the control
				// Setting padding to 5 px will offset the control from the edge of the map
				controlDiv.style.paddingTop = '5px';
				controlDiv.style.paddingRight = '0px';

				// Set CSS for the control border
				var controlUI = document.createElement('DIV');
				controlUI.style.backgroundColor = 'white';
				controlUI.style.borderStyle = 'solid';
				controlUI.style.borderWidth = '2px';
				controlUI.style.cursor = 'pointer';
				controlUI.style.textAlign = 'center';
				controlUI.title = '';
				controlDiv.appendChild(controlUI);

				// Set CSS for the control interior
				var controlText = document.createElement('DIV');
				controlText.style.fontFamily = 'Arial,sans-serif';
				controlText.style.fontSize = '12px';
				controlText.style.paddingLeft = '15px';
				controlText.style.paddingRight = '15px';
				controlText.innerHTML = '<b><?php 
        echo WT_I18N::translate('Redraw map');
        ?>
</b>';
				controlUI.appendChild(controlText);

				// Setup the click event listeners: simply set the map to original LatLng
				google.maps.event.addDomListener(controlUI, 'click', function() {
					loadMap();
				});
			}

			function loadMap() {
				<?php 
        global $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS, $SHOW_HIGHLIGHT_IMAGES;
        ?>

				// Create the map and mapOptions
				var mapOptions = {
					zoom: 7,
					center: map_center,
					mapTypeId: google.maps.MapTypeId.<?php 
        echo $this->getSetting('GM_MAP_TYPE');
        ?>
,
					mapTypeControlOptions: {
						style: google.maps.MapTypeControlStyle.DROPDOWN_MENU  // DEFAULT, DROPDOWN_MENU, HORIZONTAL_BAR
					},
					navigationControl: true,
					navigationControlOptions: {
					position: google.maps.ControlPosition.TOP_RIGHT,  // BOTTOM, BOTTOM_LEFT, LEFT, TOP, etc
					style: google.maps.NavigationControlStyle.SMALL  // ANDROID, DEFAULT, SMALL, ZOOM_PAN
					},
					streetViewControl: false,  // Show Pegman or not
					scrollwheel: false
				};
				map = new google.maps.Map(document.getElementById('map_pane'), mapOptions);

				// Close any infowindow when map is clicked
				google.maps.event.addListener(map, 'click', function() {
					infowindow.close();
				});

				// Create the Home DIV and call the HomeControl() constructor in this DIV.
				var homeControlDiv = document.createElement('DIV');
				var homeControl = new HomeControl(homeControlDiv, map);
				homeControlDiv.index = 1;
				map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);

				// Add the markers to the map from the $gmarks array
				var locations = [
					<?php 
        foreach ($gmarks as $n => $gmark) {
            ?>
					<?php 
            echo $n ? ',' : '';
            ?>
					{
						"event":        "<?php 
            echo WT_Filter::escapeJs($gmark['fact_label']);
            ?>
",
						"lat":          "<?php 
            echo WT_Filter::escapeJs($gmark['lat']);
            ?>
",
						"lng":          "<?php 
            echo WT_Filter::escapeJs($gmark['lng']);
            ?>
",
						"date":         "<?php 
            echo WT_Filter::escapeJs($gmark['date']);
            ?>
",
						"info":         "<?php 
            echo WT_Filter::escapeJs($gmark['info']);
            ?>
",
						"name":         "<?php 
            echo WT_Filter::escapeJs($gmark['name']);
            ?>
",
						"place":        "<?php 
            echo WT_Filter::escapeJs($gmark['place']);
            ?>
",
						"tooltip":      "<?php 
            echo WT_Filter::escapeJs($gmark['tooltip']);
            ?>
",
						"image":        "<?php 
            echo WT_Filter::escapeJs($gmark['image']);
            ?>
",
						"pl_icon":      "<?php 
            echo WT_Filter::escapeJs($gmark['pl_icon']);
            ?>
",
						"sv_lati":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_lati']);
            ?>
",
						"sv_long":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_long']);
            ?>
",
						"sv_bearing":   "<?php 
            echo WT_Filter::escapeJs($gmark['sv_bearing']);
            ?>
",
						"sv_elevation": "<?php 
            echo WT_Filter::escapeJs($gmark['sv_elevation']);
            ?>
",
						"sv_zoom":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_zoom']);
            ?>
"
					}
					<?php 
        }
        ?>
				];

				// Group the markers by location
				var location_groups = new Array();
				for (var key in locations) {
					if (!location_groups.hasOwnProperty(locations[key].place)) {
						location_groups[locations[key].place] = new Array();
					}
					location_groups[locations[key].place].push(locations[key]);
				}
				// TODO: why doesn't this next line work?
				//var location_groups = <?php 
        echo json_encode($location_groups);
        ?>
;

				// Set the Marker bounds
				var bounds = new google.maps.LatLngBounds ();

				var key;
				// Iterate over each location
				for (key in location_groups) {
					var locations = location_groups[key];
					// Iterate over each marker at this location
					var event_details = '';
					for (var j in locations) {
						var location = locations[j];
						if (location.info && location.name) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span> ' + location.info + '<br><b>' + location.name + '</b><br>' + location.date + '<br></p></td></tr></table>';
						} else if (location.name) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span><br><b>' + location.name + '</b><br>' + location.date + '<br></p></td></tr></table>';
						} else if (location.info) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span> ' + location.info + '<br>' + location.date + '<br></p></td></tr></table>';
						} else {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span><br>' + location.date + '<br></p></td></tr></table>';
						}
					}
					// All locations are the same in each group, so create a marker with the first
					var location = location_groups[key][0];
					var html =
					'<div class="infowindow">' +
						'<div id="gmtabs">' +
							'<ul class="tabs" >' +
								'<li><a href="#event" id="EV"><?php 
        echo WT_I18N::translate('Events');
        ?>
</a></li>' +
								<?php 
        if ($STREETVIEW) {
            ?>
								'<li><a href="#sview" id="SV"><?php 
            echo WT_I18N::translate('Google Street Viewâ„¢');
            ?>
</a></li>' +
								<?php 
        }
        ?>
							'</ul>' +
							'<div class="panes">' +
								'<div id="pane1">' +
									'<h4 id="iwhead">' + location.place + '</h4>' +
									event_details +
								'</div>' +
								<?php 
        if ($STREETVIEW) {
            ?>
								'<div id="pane2">' +
									'<h4 id="iwhead">' + location.place + '</h4>' +
									'<div id="pano"></div>' +
								'</div>' +
								<?php 
        }
        ?>
							'</div>' +
						'</div>' +
					'</div>';

					// create the marker
					var point        = new google.maps.LatLng(location.lat,     location.lng);     // Place Latitude, Longitude
					var sv_point     = new google.maps.LatLng(location.sv_lati, location.sv_long); // StreetView Latitude and Longitide

					var zoomLevel = <?php 
        echo $GM_MAX_ZOOM;
        ?>
;
					var marker    = createMarker(point, html, location.tooltip, location.sv_lati, location.sv_long, location.sv_bearing, location.sv_elevation, location.sv_zoom, sv_point, location.pl_icon);

					// if streetview coordinates are available, use them for marker,
					// else use the place coordinates
					if (sv_point && sv_point != "(0, 0)") {
						var myLatLng = sv_point;
					} else {
						var myLatLng = point;
					}

					// Correct zoom level when only one marker is present
					if (location_groups.length == 1) {
						bounds.extend(myLatLng);
						map.setZoom(zoomLevel);
						map.setCenter(myLatLng);
					} else {
						bounds.extend(myLatLng);
						map.fitBounds(bounds);
						// Correct zoom level when multiple markers have the same coordinates
						var listener1 = google.maps.event.addListenerOnce(map, "idle", function() {
							if (map.getZoom() > zoomLevel) {
								map.setZoom(zoomLevel);
							}
							google.maps.event.removeListener(listener1);
						});
					}
				} // end loop through location markers
			} // end loadMap()

		</script>
		<?php 
        // Create the normal googlemap sidebar of events and children
        echo '<div style="overflow: auto; overflow-x: hidden; overflow-y: auto; height:', $this->getSetting('GM_YSIZE'), 'px;"><table class="facts_table">';
        foreach ($location_groups as $key => $location_group) {
            foreach ($location_group as $gmark) {
                echo '<tr>';
                echo '<td class="facts_label">';
                echo '<a href="#" onclick="myclick(\'', WT_Filter::escapeHtml($key), '\')">', $gmark['fact_label'], '</a></td>';
                echo '<td class="', $gmark['class'], '" style="white-space: normal">';
                if ($gmark['info']) {
                    echo '<span class="field">', WT_Filter::escapeHtml($gmark['info']), '</span><br>';
                }
                if ($gmark['name']) {
                    echo $gmark['name'], '<br>';
                }
                echo $gmark['place'], '<br>';
                if ($gmark['date']) {
                    echo $gmark['date'], '<br>';
                }
                echo '</td>';
                echo '</tr>';
            }
        }
        echo '</table></div><br>';
    }
Example #7
0
 /**
  * Return a JSON structure to a JSON request
  *
  * @param string $list list of JSON requests
  *
  * @return string
  */
 public function getPersons($list)
 {
     $list = explode(';', $list);
     $r = array();
     foreach ($list as $jsonRequest) {
         $firstLetter = substr($jsonRequest, 0, 1);
         $jsonRequest = substr($jsonRequest, 1);
         switch ($firstLetter) {
             case 'c':
                 $fidlist = explode(',', $jsonRequest);
                 $flist = array();
                 foreach ($fidlist as $fid) {
                     $flist[] = WT_Family::getInstance($fid);
                 }
                 $r[] = $this->drawChildren($flist, 1, true);
                 break;
             case 'p':
                 $params = explode('@', $jsonRequest);
                 $fid = $params[0];
                 $order = $params[1];
                 $f = WT_Family::getInstance($fid);
                 if ($f->getHusband()) {
                     $r[] = $this->drawPerson($f->getHusband(), 0, 1, $f, $order);
                 }
                 break;
         }
     }
     return json_encode($r);
 }
Example #8
0
 public function __construct()
 {
     global $SCRIPT_NAME, $MEDIA_DIRECTORY, $WT_SESSION;
     // Our cart is an array of items in the session
     if (!is_array($WT_SESSION->cart)) {
         $WT_SESSION->cart = array();
     }
     if (!array_key_exists(WT_GED_ID, $WT_SESSION->cart)) {
         $WT_SESSION->cart[WT_GED_ID] = array();
     }
     $this->action = WT_Filter::get('action');
     $this->id = WT_Filter::get('id');
     $convert = WT_Filter::get('convert', 'yes|no', 'no');
     $this->Zip = WT_Filter::get('Zip');
     $this->IncludeMedia = WT_Filter::get('IncludeMedia');
     $this->conv_path = WT_Filter::get('conv_path');
     $this->privatize_export = WT_Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor');
     $this->level1 = WT_Filter::getInteger('level1');
     $this->level2 = WT_Filter::getInteger('level2');
     $this->level3 = WT_Filter::getInteger('level3');
     $others = WT_Filter::get('others');
     $this->type = WT_Filter::get('type');
     if (($this->privatize_export == 'none' || $this->privatize_export == 'none') && !WT_USER_GEDCOM_ADMIN) {
         $this->privatize_export = 'visitor';
     }
     if ($this->privatize_export == 'user' && !WT_USER_CAN_ACCESS) {
         $this->privatize_export = 'visitor';
     }
     if ($this->action == 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $this->type = "";
             $obj = WT_GedcomRecord::getInstance($this->id);
             if (is_null($obj)) {
                 $this->id = "";
                 $this->action = "";
             } else {
                 $this->type = strtolower($obj::RECORD_TYPE);
             }
         } else {
             if (empty($this->id)) {
                 $this->action = "";
             }
         }
         if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') {
             $this->action = 'add1';
         }
     }
     if ($this->action == 'add1') {
         $obj = WT_GedcomRecord::getInstance($this->id);
         $this->addClipping($obj);
         if ($this->type == 'sour') {
             if ($others == 'linked') {
                 foreach ($obj->linkedIndividuals('SOUR') as $indi) {
                     $this->addClipping($indi);
                 }
                 foreach ($obj->linkedFamilies('SOUR') as $fam) {
                     $this->addClipping($fam);
                 }
             }
         }
         if ($this->type == 'fam') {
             if ($others == 'parents') {
                 $this->addClipping($obj->getHusband());
                 $this->addClipping($obj->getWife());
             } elseif ($others == "members") {
                 $this->addFamilyMembers(WT_Family::getInstance($this->id));
             } elseif ($others == "descendants") {
                 $this->addFamilyDescendancy(WT_Family::getInstance($this->id));
             }
         } elseif ($this->type == 'indi') {
             if ($others == 'parents') {
                 foreach (WT_Individual::getInstance($this->id)->getChildFamilies() as $family) {
                     $this->addFamilyMembers($family);
                 }
             } elseif ($others == 'ancestors') {
                 $this->addAncestorsToCart(WT_Individual::getInstance($this->id), $this->level1);
             } elseif ($others == 'ancestorsfamilies') {
                 $this->addAncestorsToCartFamilies(WT_Individual::getInstance($this->id), $this->level2);
             } elseif ($others == 'members') {
                 foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) {
                     $this->addFamilyMembers($family);
                 }
             } elseif ($others == 'descendants') {
                 foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) {
                     $this->addClipping($family);
                     $this->addFamilyDescendancy($family, $this->level3);
                 }
             }
             uksort($WT_SESSION->cart[WT_GED_ID], array('WT_Controller_Clippings', 'compareClippings'));
         }
     } elseif ($this->action == 'remove') {
         unset($WT_SESSION->cart[WT_GED_ID][$this->id]);
     } elseif ($this->action == 'empty') {
         $WT_SESSION->cart[WT_GED_ID] = array();
     } elseif ($this->action == 'download') {
         $media = array();
         $mediacount = 0;
         $filetext = gedcom_header(WT_GEDCOM);
         // Include SUBM/SUBN records, if they exist
         $subn = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', WT_GED_ID))->fetchOne();
         if ($subn) {
             $filetext .= $subn . "\n";
         }
         $subm = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', WT_GED_ID))->fetchOne();
         if ($subm) {
             $filetext .= $subm . "\n";
         }
         if ($convert == "yes") {
             $filetext = str_replace("UTF-8", "ANSI", $filetext);
             $filetext = utf8_decode($filetext);
         }
         switch ($this->privatize_export) {
             case 'gedadmin':
                 $access_level = WT_PRIV_NONE;
                 break;
             case 'user':
                 $access_level = WT_PRIV_USER;
                 break;
             case 'visitor':
                 $access_level = WT_PRIV_PUBLIC;
                 break;
             case 'none':
                 $access_level = WT_PRIV_HIDE;
                 break;
         }
         foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) {
             $object = WT_GedcomRecord::getInstance($xref);
             if ($object) {
                 // The object may have been deleted since we added it to the cart....
                 $record = $object->privatizeGedcom($access_level);
                 // Remove links to objects that aren't in the cart
                 preg_match_all('/\\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 $record = convert_media_path($record, $this->conv_path);
                 $savedRecord = $record;
                 // Save this for the "does this file exist" check
                 if ($convert == 'yes') {
                     $record = utf8_decode($record);
                 }
                 switch ($object::RECORD_TYPE) {
                     case 'INDI':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     case 'FAM':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     case 'SOUR':
                         $filetext .= $record . "\n";
                         $filetext .= "1 NOTE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     default:
                         $ft = preg_match_all("/\n\\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER);
                         for ($k = 0; $k < $ft; $k++) {
                             // Skip external files and non-existant files
                             if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) {
                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1]);
                                 $mediacount++;
                             }
                         }
                         $filetext .= trim($record) . "\n";
                         break;
                 }
             }
         }
         if ($this->IncludeMedia == "yes") {
             $this->media_list = $media;
         }
         $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_SERVER_NAME . WT_SCRIPT_PATH . "\n";
         if ($user_id = get_gedcom_setting(WT_GED_ID, 'CONTACT_EMAIL')) {
             $user = User::find($user_id);
             $filetext .= "1 AUTH " . $user->getRealName() . "\n";
         }
         $filetext .= "0 TRLR\n";
         //-- make sure the preferred line endings are used
         $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext);
         $this->download_data = $filetext;
         $this->downloadClipping();
     }
 }
Example #9
0
 public function search($query)
 {
     if (strlen($query) < 2) {
         return '';
     }
     //-- search for INDI names
     $rows = WT_DB::prepare("SELECT i_id AS xref" . " FROM `##individuals`, `##name`" . " WHERE (i_id LIKE ? OR n_sort LIKE ?)" . " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort")->execute(array("%{$query}%", "%{$query}%", WT_GED_ID))->fetchAll();
     $ids = array();
     foreach ($rows as $row) {
         $ids[] = $row->xref;
     }
     $vars = array();
     if (empty($ids)) {
         //-- no match : search for FAM id
         $where = "f_id LIKE ?";
         $vars[] = "%{$query}%";
     } else {
         //-- search for spouses
         $qs = implode(',', array_fill(0, count($ids), '?'));
         $where = "(f_husb IN ({$qs}) OR f_wife IN ({$qs}))";
         $vars = array_merge($vars, $ids, $ids);
     }
     $vars[] = WT_GED_ID;
     $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?")->execute($vars)->fetchAll();
     $out = '<ul>';
     foreach ($rows as $row) {
         $family = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
         if ($family->canShowName()) {
             $out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
             if ($family->canShow()) {
                 $marriage_year = $family->getMarriageYear();
                 if ($marriage_year) {
                     $out .= ' (' . $marriage_year . ')';
                 }
             }
             $out .= '</a></li>';
         }
     }
     $out .= '</ul>';
     return $out;
 }
Example #10
0
 public function linkedFamilies($link)
 {
     $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families`" . " JOIN `##link` ON (f_file=l_file AND f_id=l_from)" . " LEFT JOIN `##name` ON (f_file=n_file AND f_id=n_id AND n_num=0)" . " WHERE f_file=? AND l_type=? AND l_to=?")->execute(array($this->gedcom_id, $link, $this->xref))->fetchAll();
     $list = array();
     foreach ($rows as $row) {
         $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
         if ($record->canShowName()) {
             $list[] = $record;
         }
     }
     return $list;
 }
Example #11
0
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktopid" size="3" value="', $linktoid, '"> ';
         echo print_findindi_link('linktopid');
     } else {
         $record = WT_Individual::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "family") {
     echo WT_I18N::translate('Family'), '</td>';
     echo '<td class="optionbox wrap">';
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktofamid" size="3" value="', $linktoid, '"> ';
         echo print_findfamily_link('linktofamid');
     } else {
         $record = WT_Family::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "source") {
     echo WT_I18N::translate('Source'), "</td>";
     echo '<td  class="optionbox wrap">';
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktosid" size="3" value="', $linktoid, '"> ';
         echo print_findsource_link('linktosid');
     } else {
         $record = WT_Source::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "repository") {
Example #12
0
 function _topTenGrandFamilyQuery($type = 'list', $params = null)
 {
     global $TEXT_DIRECTION;
     if ($params !== null && isset($params[0])) {
         $total = $params[0];
     } else {
         $total = 10;
     }
     $total = (int) $total;
     $rows = self::_runSQL("SELECT SQL_CACHE COUNT(*) AS tot, f_id AS id" . " FROM `##families`" . " JOIN `##link` AS children ON children.l_file = {$this->_ged_id}" . " JOIN `##link` AS mchildren ON mchildren.l_file = {$this->_ged_id}" . " JOIN `##link` AS gchildren ON gchildren.l_file = {$this->_ged_id}" . " WHERE" . " f_file={$this->_ged_id} AND" . " children.l_from=f_id AND" . " children.l_type='CHIL' AND" . " children.l_to=mchildren.l_from AND" . " mchildren.l_type='FAMS' AND" . " mchildren.l_to=gchildren.l_from AND" . " gchildren.l_type='CHIL'" . " GROUP BY id" . " ORDER BY tot DESC" . " LIMIT " . $total);
     if (!isset($rows[0])) {
         return '';
     }
     $top10 = array();
     foreach ($rows as $row) {
         $family = WT_Family::getInstance($row['id']);
         if ($family->canShow()) {
             if ($type == 'list') {
                 $top10[] = '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . WT_I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], WT_I18N::number($row['tot']));
             } else {
                 $top10[] = '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . WT_I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], WT_I18N::number($row['tot']));
             }
         }
     }
     if ($type == 'list') {
         $top10 = join('', $top10);
     } else {
         $top10 = join(';&nbsp; ', $top10);
     }
     if ($TEXT_DIRECTION == 'rtl') {
         $top10 = str_replace(array('[', ']', '(', ')', '+'), array('&rlm;[', '&rlm;]', '&rlm;(', '&rlm;)', '&rlm;+'), $top10);
     }
     if ($type == 'list') {
         return '<ul>' . $top10 . '</ul>';
     }
     return $top10;
 }
Example #13
0
 static function getLatestRecord($xref, $type)
 {
     switch ($type) {
         case 'INDI':
             return WT_Individual::getInstance($xref)->getGedcom();
         case 'FAM':
             return WT_Family::getInstance($xref)->getGedcom();
         case 'SOUR':
             return WT_Source::getInstance($xref)->getGedcom();
         case 'REPO':
             return WT_Repository::getInstance($xref)->getGedcom();
         case 'OBJE':
             return WT_Media::getInstance($xref)->getGedcom();
         case 'NOTE':
             return WT_Note::getInstance($xref)->getGedcom();
         default:
             return WT_GedcomRecord::getInstance($xref)->getGedcom();
     }
 }
Example #14
0
        $record = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
        foreach ($record->getFacts() as $fact) {
            $old_place = $fact->getAttribute('PLAC');
            if (preg_match('/(^|, )' . preg_quote($search, '/') . '$/i', $old_place)) {
                $new_place = preg_replace('/(^|, )' . preg_quote($search, '/') . '$/i', '$1' . $replace, $old_place);
                $changes[$old_place] = $new_place;
                if ($confirm == 'update') {
                    $gedcom = preg_replace('/(\\n2 PLAC (?:.*, )*)' . preg_quote($search, '/') . '(\\n|$)/i', '$1' . $replace . '$2', $fact->getGedcom());
                    $record->updateFact($fact->getFactId(), $gedcom, false);
                }
            }
        }
    }
    $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families`" . " LEFT JOIN `##change` ON (f_id = xref AND f_file=gedcom_id AND status='pending')" . " WHERE COALESCE(new_gedcom, f_gedcom) REGEXP CONCAT('\n2 PLAC ([^\n]*, )*', ?, '(\n|\$)')")->execute(array($search))->fetchAll();
    foreach ($rows as $row) {
        $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
        foreach ($record->getFacts() as $fact) {
            $old_place = $fact->getAttribute('PLAC');
            if (preg_match('/(^|, )' . preg_quote($search, '/') . '$/i', $old_place)) {
                $new_place = preg_replace('/(^|, )' . preg_quote($search, '/') . '$/i', '$1' . $replace, $old_place);
                $changes[$old_place] = $new_place;
                if ($confirm == 'update') {
                    $gedcom = preg_replace('/(\\n2 PLAC (?:.*, )*)' . preg_quote($search, '/') . '(\\n|$)/i', '$1' . $replace . '$2', $fact->getGedcom());
                    $record->updateFact($fact->getFactId(), $gedcom, false);
                }
            }
        }
    }
}
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Administration - place edit'))->pageHeader();
Example #15
0
//-- setup the arrays
$newvars = array();
foreach ($vars as $name => $var) {
    $newvars[$name]['id'] = $var;
    if (!empty($type[$name])) {
        switch ($type[$name]) {
            case 'INDI':
                $record = WT_Individual::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            case 'FAM':
                $record = WT_Family::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            case 'SOUR':
                $record = WT_Source::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            default:
Example #16
0
 if (!WT_Filter::checkCsrf()) {
     Zend_Session::writeClose();
     header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref);
     exit;
 }
 //TODO use CHIL[] instead of CHIL<n>
 //$CHIL      = WT_Filter::postArray('CHIL', WT_REGEX_XREF);
 $CHIL = array();
 for ($i = 0;; ++$i) {
     if (isset($_POST['CHIL' . $i])) {
         $CHIL[] = WT_Filter::post('CHIL' . $i, WT_REGEX_XREF);
     } else {
         break;
     }
 }
 $family = WT_Family::getInstance($xref);
 check_record_access($family);
 $controller->setPageTitle(WT_I18N::translate('Change family members'))->pageHeader();
 // Current family members
 $old_father = $family->getHusband();
 $old_mother = $family->getWife();
 $old_children = $family->getChildren();
 // New family members
 $new_father = WT_Individual::getInstance($HUSB);
 $new_mother = WT_Individual::getInstance($WIFE);
 $new_children = array();
 if (is_array($CHIL)) {
     foreach ($CHIL as $child) {
         $new_children[] = WT_Individual::getInstance($child);
     }
 }
Example #17
0
function get_calendar_events($jd1, $jd2, $facts = '', $ged_id = WT_GED_ID)
{
    // If no facts specified, get all except these
    $skipfacts = "CHAN,BAPL,SLGC,SLGS,ENDL,CENS,RESI,NOTE,ADDR,OBJE,SOUR,PAGE,DATA,TEXT";
    if ($facts != '_TODO') {
        $skipfacts .= ',_TODO';
    }
    $found_facts = array();
    // Events that start or end during the period
    $where = "WHERE (d_julianday1>={$jd1} AND d_julianday1<={$jd2} OR d_julianday2>={$jd1} AND d_julianday2<={$jd2})";
    // Restrict to certain types of fact
    if (empty($facts)) {
        $excl_facts = "'" . preg_replace('/\\W+/', "','", $skipfacts) . "'";
        $where .= " AND d_fact NOT IN ({$excl_facts})";
    } else {
        $incl_facts = "'" . preg_replace('/\\W+/', "','", $facts) . "'";
        $where .= " AND d_fact IN ({$incl_facts})";
    }
    // Only get events from the current gedcom
    $where .= " AND d_file=" . $ged_id;
    // Now fetch these events
    $ind_sql = "SELECT d_gid AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, 'INDI' AS type, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file GROUP BY d_julianday1, d_gid ORDER BY d_julianday1";
    $fam_sql = "SELECT d_gid AS xref, f_file AS gedcom_id, f_gedcom AS gedcom, 'FAM'  AS type, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##families`    {$where} AND d_gid=f_id AND d_file=f_file GROUP BY d_julianday1, d_gid ORDER BY d_julianday1";
    foreach (array($ind_sql, $fam_sql) as $sql) {
        $rows = WT_DB::prepare($sql)->fetchAll();
        foreach ($rows as $row) {
            if ($row->type == 'INDI') {
                $record = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
            } else {
                $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
            }
            $anniv_date = new WT_Date($row->d_type . ' ' . $row->d_day . ' ' . $row->d_month . ' ' . $row->d_year);
            foreach ($record->getFacts(str_replace(' ', '|', $facts)) as $fact) {
                if ($fact->getDate() == $anniv_date) {
                    $fact->anniv = 0;
                    $found_facts[] = $fact;
                }
            }
        }
    }
    return $found_facts;
}
Example #18
0
function export_gedcom($gedcom, $gedout, $exportOptions)
{
    global $GEDCOM;
    // Temporarily switch to the specified GEDCOM
    $oldGEDCOM = $GEDCOM;
    $GEDCOM = $gedcom;
    $ged_id = get_id_from_gedcom($gedcom);
    switch ($exportOptions['privatize']) {
        case 'gedadmin':
            $access_level = WT_PRIV_NONE;
            break;
        case 'user':
            $access_level = WT_PRIV_USER;
            break;
        case 'visitor':
            $access_level = WT_PRIV_PUBLIC;
            break;
        case 'none':
            $access_level = WT_PRIV_HIDE;
            break;
    }
    $head = gedcom_header($gedcom);
    if ($exportOptions['toANSI'] == 'yes') {
        $head = str_replace('UTF-8', 'ANSI', $head);
        $head = utf8_decode($head);
    }
    $head = reformat_record_export($head);
    fwrite($gedout, $head);
    // Buffer the output.  Lots of small fwrite() calls can be very slow when writing large gedcoms.
    $buffer = '';
    // Generate the OBJE/SOUR/REPO/NOTE records first, as their privacy calcualations involve
    // database queries, and we wish to avoid large gaps between queries due to MySQL connection timeouts.
    $tmp_gedcom = '';
    $rows = WT_DB::prepare("SELECT 'OBJE' AS type, m_id AS xref, m_file AS gedcom_id, m_gedcom AS gedcom" . " FROM `##media` WHERE m_file=? ORDER BY m_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Media::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        $rec = convert_media_path($rec, $exportOptions['path']);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom" . " FROM `##sources` WHERE s_file=? ORDER BY s_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Source::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT o_type AS type, o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" . " FROM `##other` WHERE o_file=? AND o_type!='HEAD' AND o_type!='TRLR' ORDER BY o_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        switch ($row->type) {
            case 'NOTE':
                $record = WT_Note::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
            case 'REPO':
                $record = WT_Repository::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
            default:
                $record = WT_GedcomRecord::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
        }
        $rec = $record->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . " FROM `##individuals` WHERE i_file=? ORDER BY i_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $buffer .= reformat_record_export($rec);
        if (strlen($buffer) > 65536) {
            fwrite($gedout, $buffer);
            $buffer = '';
        }
    }
    $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families` WHERE f_file=? ORDER BY f_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $buffer .= reformat_record_export($rec);
        if (strlen($buffer) > 65536) {
            fwrite($gedout, $buffer);
            $buffer = '';
        }
    }
    fwrite($gedout, $buffer);
    fwrite($gedout, $tmp_gedcom);
    fwrite($gedout, '0 TRLR' . WT_EOL);
    $GEDCOM = $oldGEDCOM;
}