Exemple #1
0
 private function get_facts()
 {
     global $controller;
     if ($this->facts === null) {
         $facts = $controller->record->getFacts();
         foreach ($controller->record->getSpouseFamilies() as $family) {
             if ($family->canShow()) {
                 foreach ($family->getFacts() as $fact) {
                     $facts[] = $fact;
                 }
             }
         }
         $this->facts = array();
         foreach ($facts as $fact) {
             if (preg_match('/(?:^1|\\n\\d) OBJE @' . WT_REGEX_XREF . '@/', $fact->getGedcom())) {
                 $this->facts[] = $fact;
             }
         }
         sort_facts($this->facts);
     }
     return $this->facts;
 }
Exemple #2
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>';
    }
Exemple #3
0
    // at a scale of 25 or higher, show every year
    $mod = 25 / $controller->scale;
    if ($mod < 1) {
        $mod = 1;
    }
    for ($i = $controller->baseyear + 1; $i < $controller->topyear; $i++) {
        if ($i % $mod == 0) {
            echo "<div id=\"scale{$i}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: {$basexoffset}" : "right: {$basexoffset}") . "px; top:" . ($baseyoffset + ($i - $controller->baseyear) * $controller->scale - $controller->scale / 2) . "px; font-size: 7pt; text-align:" . ($TEXT_DIRECTION === "ltr" ? "left" : "right") . ";\">";
            echo $i . '—';
            echo '</div>';
        }
    }
    echo "<div id=\"scale{$controller->topyear}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: {$basexoffset}" : "right: {$basexoffset}") . "px; top:" . ($baseyoffset + ($controller->topyear - $controller->baseyear) * $controller->scale) . "px; font-size: 7pt; text-align:" . ($TEXT_DIRECTION == "ltr" ? "left" : "right") . ";\">";
    echo $controller->topyear . '—';
    echo '</div>';
    sort_facts($controller->indifacts);
    $factcount = 0;
    foreach ($controller->indifacts as $fact) {
        $controller->print_time_fact($fact);
        $factcount++;
    }
    // print the age boxes
    foreach ($controller->people as $p => $indi) {
        $pid = $indi->getXref();
        $ageyoffset = $baseyoffset + $controller->bheight * $p;
        $col = $p % 6;
        ?>
		<div id="agebox<?php 
        echo $p;
        ?>
" style="cursor:move; position:absolute; <?php 
Exemple #4
0
 function fillTL($ar, $top)
 {
     global $maxX, $zindex;
     $zindex = count($ar);
     $rows = array();
     $modFix = 0;
     if ($this->modTest == 1) {
         $modFix = 9 * $this->birthMod;
     }
     //base case
     if (count($ar) == 0) {
         return $top;
     }
     $maxY = $top;
     foreach ($ar as $value) {
         //Creates appropriate color scheme to show relationships
         $this->currentsex = $value->getSex();
         if ($this->currentsex == "M") {
             $this->Mcolorindex++;
             if (!isset($this->malecolorR[$this->Mcolorindex])) {
                 $this->Mcolorindex = 0;
             }
             $this->malecolorR[$this->Mcolorindex];
             $this->Mcolorindex++;
             if (!isset($this->malecolorG[$this->Mcolorindex])) {
                 $this->Mcolorindex = 0;
             }
             $this->malecolorG[$this->Mcolorindex];
             $red = dechex($this->malecolorR[$this->Mcolorindex]);
             $green = dechex($this->malecolorR[$this->Mcolorindex]);
             if (strlen($red) < 2) {
                 $red = "0" . $red;
             }
             if (strlen($green) < 2) {
                 $green = "0" . $green;
             }
             $this->color = "#" . $red . $green . dechex($this->malecolorB);
         } elseif ($this->currentsex == "F") {
             $this->Fcolorindex++;
             if (!isset($this->femalecolorG[$this->Fcolorindex])) {
                 $this->Fcolorindex = 0;
             }
             $this->femalecolorG[$this->Fcolorindex];
             $this->Fcolorindex++;
             if (!isset($this->femalecolorB[$this->Fcolorindex])) {
                 $this->Fcolorindex = 0;
             }
             $this->femalecolorB[$this->Fcolorindex];
             $this->color = "#" . dechex($this->femalecolorR) . dechex($this->femalecolorG[$this->Fcolorindex]) . dechex($this->femalecolorB[$this->Fcolorindex]);
         } else {
             $this->color = $this->colors[$this->colorindex];
         }
         //set start position and size of person-box according to zoomfactor
         $bdate = $value->getEstimatedBirthDate();
         $ddate = $value->getEstimatedDeathDate();
         $birthYear = $bdate->gregorianYear();
         $deathYear = $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y');
         $width = ($deathYear - $birthYear) * $this->zoomfactor;
         $height = 2 * $this->zoomfactor;
         $startPos = ($birthYear - $this->timelineMinYear) * $this->zoomfactor + 14 + $modFix;
         $minlength = mb_strlen(strip_tags($value->getFullName())) * $this->zoomfactor;
         if ($startPos > 15) {
             $startPos = ($birthYear - $this->timelineMinYear) * $this->zoomfactor + 15;
             $width = ($deathYear - $birthYear) * $this->zoomfactor - 2;
         }
         //set minimum width for single year lifespans
         if ($width < 10) {
             $width = 10;
         }
         $lifespan = "<span dir=\"ltr\">{$birthYear}-</span>";
         $deathReal = $value->getDeathDate()->isOK();
         $birthReal = $value->getBirthDate()->isOK();
         if ($value->isDead() && $deathReal) {
             $lifespan .= "<span dir=\"ltr\">{$deathYear}</span>";
         }
         $lifespannumeral = $deathYear - $birthYear;
         //-- calculate a good Y top value
         $Y = $top;
         $Z = $zindex;
         $ready = false;
         while (!$ready) {
             if (!isset($rows[$Y])) {
                 $ready = true;
                 $rows[$Y]["x1"] = $startPos;
                 $rows[$Y]["x2"] = $startPos + $width;
                 $rows[$Y]["z"] = $zindex;
             } else {
                 if ($rows[$Y]["x1"] > $startPos + $width) {
                     $ready = true;
                     $rows[$Y]["x1"] = $startPos;
                     $Z = $rows[$Y]["z"];
                 } elseif ($rows[$Y]["x2"] < $startPos) {
                     $ready = true;
                     $rows[$Y]["x2"] = $startPos + $width;
                     $Z = $rows[$Y]["z"];
                 } else {
                     //move down 25 pixels
                     if ($this->zoomfactor > 10) {
                         $Y += 25 + $this->zoomfactor;
                     } else {
                         $Y += 25;
                     }
                 }
             }
         }
         //Need to calculate each event and the spacing between them
         // event1 distance will be event - birthyear   that will be the distance. then each distance will chain off that
         //$event[][]  = {"Cell 1 will hold events"}{"cell2 will hold time between that and the next value"};
         $facts = $value->getFacts();
         foreach ($value->getSpouseFamilies() as $family) {
             foreach ($family->getFacts() as $fact) {
                 $facts[] = $fact;
             }
         }
         $unparsedEvents = array();
         foreach ($facts as $fact) {
             if (!in_array($fact->getTag(), $this->nonfacts)) {
                 $unparsedEvents[] = $fact;
             }
         }
         sort_facts($unparsedEvents);
         $eventinformation = array();
         foreach ($unparsedEvents as $val) {
             $date = $val->getDate();
             if (!empty($date)) {
                 $fact = $val->getTag();
                 $yearsin = $date->date1->y - $birthYear;
                 if ($lifespannumeral == 0) {
                     $lifespannumeral = 1;
                 }
                 $eventwidth = $yearsin / $lifespannumeral * 100;
                 // percent of the lifespan before the event occured used for determining div spacing
                 // figure out some schema
                 $evntwdth = $eventwidth . "%";
                 //-- if the fact is a generic EVENt then get the qualifying TYPE
                 if ($fact == "EVEN") {
                     $fact = $val->getAttribute('TYPE');
                 }
                 $trans = WT_Gedcom_Tag::getLabel($fact);
                 if (isset($eventinformation[$evntwdth])) {
                     $eventinformation[$evntwdth] .= '<br>' . $trans . '<br>' . strip_tags($date->Display(false, '', NULL, false)) . ' ' . $val->getPlace()->getFullName();
                 } else {
                     $eventinformation[$evntwdth] = $fact . '-fact, ' . $trans . '<br>' . strip_tags($date->Display(false, '', NULL, false)) . ' ' . $val->getPlace()->getFullName();
                 }
             }
         }
         $bdate = $value->getEstimatedBirthDate();
         $ddate = $value->getEstimatedDeathDate();
         if ($width > $minlength + 110) {
             echo "<div id=\"bar_", $value->getXref(), "\" style=\"position: absolute; top:", $Y, "px; left:", $startPos, "px; width:", $width, "px; height:", $height, "px; background-color:", $this->color, "; border: solid blue 1px; z-index:{$Z};\">";
             foreach ($eventinformation as $evtwidth => $val) {
                 echo "<div style=\"position:absolute; left:", $evtwidth, ";\"><a class=\"showit\" href=\"#\" style=\"top:-2px; font-size:10px;\"><b>";
                 $text = explode("-fact, ", $val);
                 $fact = $text[0];
                 echo '</b><span>', self::getAbbreviation($fact), '</span></a></div>';
             }
             $indiName = $value->getFullName();
             echo '<table><tr><td width="15"><a class="showit" href="#"><b>';
             echo self::getAbbreviation('BIRT');
             echo '</b><span>', $value->getSexImage(), $indiName, '<br>', WT_Gedcom_Tag::getLabel('BIRT'), ' ', strip_tags($bdate->Display(false)), ' ', $value->getBirthPlace(), '</span></a>', '<td align="left" width="100%"><a href="', $value->getHtmlUrl(), '">', $value->getSexImage(), $indiName, '  ', $lifespan, ' </a></td>', '<td width="15">';
             if ($value->isDead()) {
                 if ($deathReal || $value->isDead()) {
                     echo '<a class="showit" href="#"><b>';
                     echo self::getAbbreviation('DEAT');
                     if (!$deathReal) {
                         echo '*';
                     }
                     echo '</b><span>' . $value->getSexImage() . $indiName . '<br>' . WT_Gedcom_Tag::getLabel('DEAT') . ' ' . strip_tags($ddate->Display(false)) . ' ' . $value->getDeathPlace() . '</span></a>';
                 }
             }
             echo '</td></tr></table>';
             echo '</div>';
         } else {
             if ($width > $minlength + 5) {
                 echo '<div style="text-align: left; position: absolute; top:', $Y, 'px; left:', $startPos, 'px; width:', $width, 'px; height:', $height, 'px; background-color:', $this->color, '; border: solid blue 1px; z-index:', $Z, '">';
                 foreach ($eventinformation as $evtwidth => $val) {
                     echo '<div style="position:absolute; left:', $evtwidth, ' "><a class="showit" href="#" style="top:-2px; font-size:10px;"><b>';
                     $text = explode("-fact,", $val);
                     $fact = $text[0];
                     echo '</b><span>' . self::getAbbreviation($fact) . '</span></a></div>';
                 }
                 $indiName = $value->getFullName();
                 echo '<table dir="ltr"><tr><td width="15"><a class="showit" href="#"><b>';
                 echo self::getAbbreviation('BIRT');
                 if (!$birthReal) {
                     echo '*';
                 }
                 echo '</b><span>' . $value->getSexImage() . $indiName . '<br>' . WT_Gedcom_Tag::getLabel('BIRT') . ' ' . strip_tags($bdate->Display(false)) . ' ' . $value->getBirthPlace() . '</span></a></td>' . '<td align="left" width="100%"><a href="' . $value->getHtmlUrl() . '">' . $value->getSexImage() . $indiName . '</a></td>' . '<td width="15">';
                 if ($value->isDead()) {
                     if ($deathReal || $value->isDead()) {
                         echo '<a class="showit" href="#"><b>';
                         echo self::getAbbreviation('DEAT');
                         if (!$deathReal) {
                             echo "*";
                         }
                         echo '</b><span>' . $value->getSexImage() . $indiName . '<br>' . WT_Gedcom_Tag::getLabel('DEAT') . ' ' . strip_tags($ddate->Display(false)) . ' ' . $value->getDeathPlace() . '</span></a>';
                     }
                 }
                 echo '</td></tr></table>';
                 echo '</div>';
             } else {
                 echo '<div style="text-align: left; position: absolute;top:', $Y, 'px; left:', $startPos, 'px;width:', $width, 'px; height:', $height, 'px; background-color:', $this->color, '; border: solid blue 1px; z-index:', $Z, '">';
                 $indiName = $value->getFullName();
                 echo '<a class="showit" href="' . $value->getHtmlUrl() . '"><b>';
                 echo self::getAbbreviation('BIRT');
                 echo '</b><span>' . $value->getSexImage() . $indiName . '<br>' . WT_Gedcom_Tag::getLabel('BIRT') . ' ' . strip_tags($bdate->Display(false)) . ' ' . $value->getBirthPlace() . '<br>';
                 foreach ($eventinformation as $val) {
                     $text = explode('-fact,', $val);
                     $val = $text[1];
                     echo $val . "<br>";
                 }
                 if ($value->isDead() && $deathReal) {
                     echo WT_Gedcom_Tag::getLabel('DEAT') . " " . strip_tags($ddate->Display(false)) . " " . $value->getDeathPlace();
                 }
                 echo '</span></a>';
                 echo '</div>';
             }
         }
         $zindex--;
         if ($maxX < $startPos + $width) {
             $maxX = $startPos + $width;
         }
         if ($maxY < $Y) {
             $maxY = $Y;
         }
     }
     return $maxY;
 }
 /**
  * get the individual facts shown on tab 1
  * @return array
  */
 function getIndiFacts()
 {
     $indifacts = $this->indi->getIndiFacts();
     sort_facts($indifacts);
     return $indifacts;
 }
Exemple #6
0
 public function getTabContent()
 {
     global $EXPAND_RELATIVES_EVENTS, $controller;
     $EXPAND_HISTO_EVENTS = false;
     $indifacts = array();
     // The individual’s own facts
     foreach ($controller->record->getFacts() as $fact) {
         switch ($fact->getTag()) {
             case 'SEX':
             case 'NAME':
             case 'SOUR':
             case 'OBJE':
             case 'NOTE':
             case 'FAMC':
             case 'FAMS':
                 break;
             default:
                 if (!array_key_exists('extra_info', WT_Module::getActiveSidebars()) || !extra_info_WT_Module::showFact($fact)) {
                     $indifacts[] = $fact;
                 }
                 break;
         }
     }
     // Add spouse-family facts
     foreach ($controller->record->getSpouseFamilies() as $family) {
         foreach ($family->getFacts() as $fact) {
             switch ($fact->getTag()) {
                 case 'SOUR':
                 case 'NOTE':
                 case 'OBJE':
                 case 'CHAN':
                 case '_UID':
                 case 'RIN':
                 case 'HUSB':
                 case 'WIFE':
                 case 'CHIL':
                     break;
                 default:
                     $indifacts[] = $fact;
                     break;
             }
         }
         $spouse = $family->getSpouse($controller->record);
         if ($spouse) {
             foreach (self::spouse_facts($controller->record, $spouse) as $fact) {
                 $indifacts[] = $fact;
             }
         }
         foreach (self::child_facts($controller->record, $family, '_CHIL', '') as $fact) {
             $indifacts[] = $fact;
         }
     }
     foreach (self::parent_facts($controller->record, 1) as $fact) {
         $indifacts[] = $fact;
     }
     foreach (self::historical_facts($controller->record) as $fact) {
         $indifacts[] = $fact;
     }
     foreach (self::associate_facts($controller->record) as $fact) {
         $indifacts[] = $fact;
     }
     sort_facts($indifacts);
     ob_start();
     echo '<table class="facts_table">';
     echo '<tbody>';
     if (!$indifacts) {
         echo '<tr><td colspan="2" class="facts_value">', WT_I18N::translate('There are no facts for this individual.'), '</td></tr>';
     }
     echo '<tr><td colspan="2" class="descriptionbox rela"><form action="?"><input id="checkbox_rela_facts" type="checkbox"';
     if ($EXPAND_RELATIVES_EVENTS) {
         echo ' checked="checked"';
     }
     echo ' onclick="jQuery(\'tr.rela\').toggle();"><label for="checkbox_rela_facts">', WT_I18N::translate('Events of close relatives'), '</label>';
     if (file_exists(WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
         echo ' <input id="checkbox_histo" type="checkbox"';
         if ($EXPAND_HISTO_EVENTS) {
             echo ' checked="checked"';
         }
         echo ' onclick="jQuery(\'tr.histo\').toggle();"><label for="checkbox_histo">', WT_I18N::translate('Historical facts'), '</label>';
     }
     echo '</form></td></tr>';
     foreach ($indifacts as $fact) {
         print_fact($fact, $controller->record);
     }
     //-- new fact link
     if ($controller->record->canEdit()) {
         print_add_new_fact($controller->record->getXref(), $indifacts, 'INDI');
     }
     echo '</tbody>';
     echo '</table>';
     if (!$EXPAND_RELATIVES_EVENTS) {
         echo '<script>jQuery("tr.rela").toggle();</script>';
     }
     if (!$EXPAND_HISTO_EVENTS) {
         echo '<script>jQuery("tr.histo").toggle();</script>';
     }
     return '<div id="' . $this->getName() . '_content">' . ob_get_clean() . '</div>';
 }
/**
 * print the facts table for a family
 *
 * @param string $famid family gedcom ID
 * @param int $sosa optional child sosa number
 */
function print_family_facts(&$family, $sosa = 0)
{
    global $pgv_lang, $pbwidth, $pbheight, $view;
    global $nonfacts, $factarray;
    global $TEXT_DIRECTION, $GEDCOM, $SHOW_ID_NUMBERS;
    global $show_changes, $pgv_changes;
    global $linkToID;
    $famid = $family->getXref();
    // -- if both parents are displayable then print the marriage facts
    if ($family->canDisplayDetails()) {
        $linkToID = $famid;
        // -- Tell addmedia.php what to link to
        // -- array of GEDCOM elements that will be found but should not be displayed
        $nonfacts = array("FAMS", "FAMC", "MAY", "BLOB", "HUSB", "WIFE", "CHIL", "");
        // -- find all the fact information
        $indifacts = $family->getFacts();
        if (count($indifacts) > 0) {
            sort_facts($indifacts);
            print "\n\t<span class=\"subheaders\">" . $pgv_lang["family_group_info"];
            if ($SHOW_ID_NUMBERS and $famid != "") {
                print "&nbsp;&nbsp;&nbsp;({$famid})";
            }
            print "</span><br />\n\t<table class=\"facts_table\">";
            /* @var $value Event */
            foreach ($indifacts as $key => $value) {
                if ($value->getTag() != "SOUR" && $value->getTag() != "OBJE" && $value->getTag() != "NOTE") {
                    print_fact($value);
                }
            }
            // do not print otheritems for sosa
            if ($sosa == 0) {
                foreach ($indifacts as $key => $value) {
                    $fact = $value->getTag();
                    // -- handle special source fact case
                    if ($fact == "SOUR") {
                        print_main_sources($value->getGedComRecord(), 1, $famid, $value->getLineNumber());
                    } else {
                        if ($fact == "NOTE") {
                            print_main_notes($value->getGedComRecord(), 1, $famid, $value->getLineNumber());
                        }
                    }
                }
                // NOTE: Print the media
                print_main_media($famid);
            }
        } else {
            if ($sosa == 0) {
                print "\n\t<span class=\"subheaders\">" . $pgv_lang["family_group_info"];
                if ($SHOW_ID_NUMBERS and $famid != "") {
                    print "&nbsp;&nbsp;&nbsp;({$famid})";
                }
                print "</span><br />\n\t";
            }
            print "<table class=\"facts_table\">";
            if ($sosa == 0) {
                print "<tr><td class=\"messagebox\" colspan=\"2\">";
                print $pgv_lang["no_family_facts"];
                print "</td></tr>\n";
            }
        }
        // -- new fact link
        if ($view != "preview" && $sosa == 0 && PGV_USER_CAN_EDIT) {
            print_add_new_fact($famid, $indifacts, "FAM");
            // -- new note
            print "<tr><td class=\"descriptionbox\">";
            print_help_link("add_note_help", "qm", "add_note_lbl");
            print $pgv_lang["add_note_lbl"] . "</td>";
            print "<td class=\"optionbox\">";
            print "<a href=\"javascript:;\" onclick=\"return add_new_record('{$famid}','NOTE');\">" . $pgv_lang["add_note"] . "</a>";
            print "<br />\n";
            print "</td></tr>\n";
            // -- new shared note
            print "<tr><td class=\"descriptionbox\">";
            print_help_link("add_shared_note_help", "qm", "add_shared_note_lbl");
            print $pgv_lang["add_shared_note_lbl"] . "</td>";
            print "<td class=\"optionbox\">";
            print "<a href=\"javascript:;\" onclick=\"return add_new_record('{$famid}','SHARED_NOTE');\">" . $pgv_lang["add_shared_note"] . "</a>";
            print "<br />\n";
            print "</td></tr>\n";
            // -- new media
            print "<tr><td class=\"descriptionbox\">";
            print_help_link("add_media_help", "qm", "add_media_lbl");
            print $pgv_lang["add_media_lbl"] . "</td>";
            print "<td class=\"optionbox\">";
            print "<a href=\"javascript: " . $pgv_lang["add_media_lbl"] . "\" onclick=\"window.open('addmedia.php?action=showmediaform&linktoid={$famid}', '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); return false;\">" . $pgv_lang["add_media"] . "</a>";
            print "<br />\n";
            print "<a href=\"javascript:;\" onclick=\"window.open('inverselink.php?linktoid={$famid}&linkto=family', '_blank', 'top=50,left=50,width=400,height=300,resizable=1,scrollbars=1'); return false;\">" . $pgv_lang["link_to_existing_media"] . "</a>";
            print "</td></tr>\n";
            // -- new source citation
            print "<tr><td class=\"descriptionbox\">";
            print_help_link("add_source_help", "qm", "add_source_lbl");
            print $pgv_lang["add_source_lbl"] . "</td>";
            print "<td class=\"optionbox\">";
            print "<a href=\"javascript:;\" onclick=\"return add_new_record('{$famid}','SOUR');\">" . $pgv_lang["add_source"] . "</a>";
            print "<br />\n";
            print "</td></tr>\n";
            // -- end new objects
        }
        print "\n\t</table>\n";
    }
}
Exemple #8
0
 /**
  * return a list of facts
  *
  * @param bool $includeFileName
  *
  * @return array
  */
 function getFacts($includeFileName = true)
 {
     $facts = $this->record->getFacts();
     // Add some dummy facts to show additional information
     if ($this->record->fileExists()) {
         // get height and width of image, when available
         $imgsize = $this->record->getImageAttributes();
         if (!empty($imgsize['WxH'])) {
             $facts[] = new WT_Fact('1 __IMAGE_SIZE__ ' . $imgsize['WxH'], $this->record, 0);
         }
         //Prints the file size
         $facts[] = new WT_Fact('1 __FILE_SIZE__ ' . $this->record->getFilesize(), $this->record, 0);
     }
     sort_facts($facts);
     return $facts;
 }
Exemple #9
0
/**
 * @param array $attrs an array of key value pairs for the attributes
 *
 * @see  FactsEHandler()
 */
function FactsSHandler($attrs)
{
    // @deprecated
    global $repeats, $repeatsStack, $gedrec, $parser, $repeatBytes, $processRepeats, $vars;
    $processRepeats++;
    if ($processRepeats > 1) {
        return;
    }
    array_push($repeatsStack, array($repeats, $repeatBytes));
    $repeats = array();
    $repeatBytes = xml_get_current_line_number($parser);
    $id = "";
    $match = array();
    if (preg_match("/0 @(.+)@/", $gedrec, $match)) {
        $id = $match[1];
    }
    $tag = "";
    if (isset($attrs['ignore'])) {
        $tag .= $attrs['ignore'];
    }
    if (preg_match("/\\\$(.+)/", $tag, $match)) {
        $tag = $vars[$match[1]]['id'];
    }
    $record = WT_GedcomRecord::getInstance($id);
    if (empty($attrs['diff']) && !empty($id)) {
        $facts = $record->getFacts();
        sort_facts($facts);
        $repeats = array();
        $nonfacts = explode(',', $tag);
        foreach ($facts as $event) {
            if (!in_array($event->getTag(), $nonfacts)) {
                $repeats[] = $event->getGedcom();
            }
        }
    } else {
        foreach ($record->getFacts() as $fact) {
            if ($fact->isNew() && $fact->getTag() != 'CHAN') {
                $repeats[] = $fact->getGedcom();
            }
        }
    }
}
 function fillTL($ar, $int, $top)
 {
     global $maxX, $zindex, $pgv_lang, $factarray, $factAbbrev;
     $zindex = count($ar);
     $rows = array();
     $modFix = 0;
     if ($this->modTest == 1) {
         $modFix = 9 * $this->birthMod;
     }
     //base case
     if (count($ar) == 0) {
         return $top;
     }
     $maxY = $top;
     foreach ($ar as $key => $value) {
         //Creates appropriate color scheme to show relationships
         $this->currentsex = $value->getSex();
         if ($this->currentsex == "M") {
             $this->Mcolorindex++;
             if (!isset($this->malecolorR[$this->Mcolorindex])) {
                 $this->Mcolorindex = 0;
             }
             $this->malecolorR[$this->Mcolorindex];
             $this->Mcolorindex++;
             if (!isset($this->malecolorG[$this->Mcolorindex])) {
                 $this->Mcolorindex = 0;
             }
             $this->malecolorG[$this->Mcolorindex];
             $red = dechex($this->malecolorR[$this->Mcolorindex]);
             $green = dechex($this->malecolorR[$this->Mcolorindex]);
             if (strlen($red) < 2) {
                 $red = "0" . $red;
             }
             if (strlen($green) < 2) {
                 $green = "0" . $green;
             }
             $this->color = "#" . $red . $green . dechex($this->malecolorB);
         } else {
             if ($this->currentsex == "F") {
                 $this->Fcolorindex++;
                 if (!isset($this->femalecolorG[$this->Fcolorindex])) {
                     $this->Fcolorindex = 0;
                 }
                 $this->femalecolorG[$this->Fcolorindex];
                 $this->Fcolorindex++;
                 if (!isset($this->femalecolorB[$this->Fcolorindex])) {
                     $this->Fcolorindex = 0;
                 }
                 $this->femalecolorB[$this->Fcolorindex];
                 $this->color = "#" . dechex($this->femalecolorR) . dechex($this->femalecolorG[$this->Fcolorindex]) . dechex($this->femalecolorB[$this->Fcolorindex]);
             } else {
                 $this->color = $this->colors[$this->colorindex];
             }
         }
         //set start position and size of person-box according to zoomfactor
         /* @var $value Person */
         $bdate = $value->getEstimatedBirthDate();
         $ddate = $value->getEstimatedDeathDate();
         $birthYear = $bdate->gregorianYear();
         $deathYear = $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y');
         $width = ($deathYear - $birthYear) * $this->zoomfactor;
         $height = 2 * $this->zoomfactor;
         $startPos = ($birthYear - $this->timelineMinYear) * $this->zoomfactor + 14 + $modFix;
         if (stristr($value->getFullName(), "starredname")) {
             $minlength = (UTF8_strlen($value->getFullName()) - 34) * $this->zoomfactor;
         } else {
             $minlength = UTF8_strlen($value->getFullName()) * $this->zoomfactor;
         }
         if ($startPos > 15) {
             $startPos = ($birthYear - $this->timelineMinYear) * $this->zoomfactor + 15 + $modFix;
             $startPos = ($birthYear - $this->timelineMinYear) * $this->zoomfactor + 15;
             $width = ($deathYear - $birthYear) * $this->zoomfactor - 2;
         }
         //set start position to deathyear
         $int = $deathYear;
         //set minimum width for single year lifespans
         if ($width < 10) {
             $width = 10;
             $int = $birthYear + 1;
         }
         $lifespan = "<span dir=\"ltr\">{$birthYear}-</span>";
         $deathReal = $value->getDeathDate()->isOK();
         $birthReal = $value->getBirthDate()->isOK();
         if ($value->isDead() && $deathReal) {
             $lifespan .= "<span dir=\"ltr\">{$deathYear}</span>";
         }
         $lifespannumeral = $deathYear - $birthYear;
         //-- calculate a good Y top value
         $Y = $top;
         $Z = $zindex;
         $ready = false;
         while (!$ready) {
             if (!isset($rows[$Y])) {
                 $ready = true;
                 $rows[$Y]["x1"] = $startPos;
                 $rows[$Y]["x2"] = $startPos + $width;
                 $rows[$Y]["z"] = $zindex;
             } else {
                 if ($rows[$Y]["x1"] > $startPos + $width) {
                     $ready = true;
                     $rows[$Y]["x1"] = $startPos;
                     $Z = $rows[$Y]["z"];
                 } else {
                     if ($rows[$Y]["x2"] < $startPos) {
                         $ready = true;
                         $rows[$Y]["x2"] = $startPos + $width;
                         $Z = $rows[$Y]["z"];
                     } else {
                         //move down 25 pixels
                         if ($this->zoomfactor > 10) {
                             $Y += 25 + $this->zoomfactor;
                         } else {
                             $Y += 25;
                         }
                     }
                 }
             }
         }
         //Need to calculate each event and the spacing between them
         // event1 distance will be event - birthyear   that will be the distance. then each distance will chain off that
         //$event[][]  = {"Cell 1 will hold events"}{"cell2 will hold time between that and the next value"};
         //$value->add_historical_facts();
         $value->add_family_facts(false);
         $unparsedEvents = $value->getIndiFacts();
         sort_facts($unparsedEvents);
         $eventinformation = array();
         $eventspacing = array();
         foreach ($unparsedEvents as $index => $val) {
             $date = $val->getDate();
             if (!empty($date)) {
                 $fact = $val->getTag();
                 $yearsin = $date->date1->y - $birthYear;
                 if ($lifespannumeral == 0) {
                     $lifespannumeral = 1;
                 }
                 $eventwidth = $yearsin / $lifespannumeral * 100;
                 // percent of the lifespan before the event occured used for determining div spacing
                 // figure out some schema
                 $evntwdth = $eventwidth . "%";
                 //-- if the fact is a generic EVENt then get the qualifying TYPE
                 if ($fact == "EVEN") {
                     $fact = $val->getType();
                 }
                 $place = $val->getPlace();
                 $trans = $fact;
                 if (isset($factarray[$fact])) {
                     $trans = $factarray[$fact];
                 } else {
                     if (isset($pgv_lang[$fact])) {
                         $trans = $pgv_lang[$fact];
                     }
                 }
                 if (isset($eventinformation[$evntwdth])) {
                     $eventinformation[$evntwdth] .= "<br />\n" . $trans . "<br />\n" . strip_tags($date->Display(false, '', NULL, false)) . " " . $place;
                 } else {
                     $eventinformation[$evntwdth] = $fact . "-fact," . $trans . "<br />\n" . strip_tags($date->Display(false, '', NULL, false)) . " " . $place;
                 }
             }
         }
         $bdate = $value->getEstimatedBirthDate();
         $ddate = $value->getEstimatedDeathDate();
         if ($width > $minlength + 110) {
             echo "\n<div id=\"bar_" . $value->getXref() . "\" style=\"position: absolute; top:" . $Y . "px; left:" . $startPos . "px; width:" . $width . "px; height:" . $height . "px; background-color:" . $this->color . "; border: solid blue 1px; z-index:{$Z};\">";
             foreach ($eventinformation as $evtwidth => $val) {
                 print "<div style=\"position:absolute; left:" . $evtwidth . ";\"><a class=\"showit\" href=\"#\" style=\"top:-2px; font-size:10px;\"><b>";
                 $text = explode("-fact,", $val);
                 $fact = $text[0];
                 $val = $text[1];
                 if (isset($factAbbrev[$fact])) {
                     print $factAbbrev[$fact];
                 } else {
                     print get_first_letter($val);
                 }
                 print "</b><span>" . PrintReady($val) . "</span></a></div>";
             }
             $indiName = PrintReady(str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $value->getFullName()));
             print "\n\t<table><tr>\n\t\t<td width=\"15\"><a class=\"showit\" href=\"#\"><b>";
             if (isset($factAbbrev["BIRT"])) {
                 print $factAbbrev["BIRT"];
             } else {
                 print get_first_letter($factarray["BIRT"]);
             }
             if (!$birthReal) {
                 print "*";
             }
             print "</b><span>" . $value->getSexImage() . $indiName . "<br/>" . $factarray["BIRT"] . " " . strip_tags($bdate->Display(false)) . " " . PrintReady($value->getBirthPlace()) . "</span></a></td>" . "\n\t\t<td align=\"left\" width=\"100%\"><a href=\"" . encode_url($value->getLinkUrl()) . "\">" . $value->getSexImage() . $indiName . ":  {$lifespan} </a></td>" . "\n\t\t<td width=\"15\">";
             if ($value->isDead()) {
                 if ($deathReal || $value->isDead()) {
                     print "<a class=\"showit\" href=\"#\"><b>";
                     if (isset($factAbbrev["DEAT"])) {
                         print $factAbbrev["DEAT"];
                     } else {
                         print get_first_letter($factarray["DEAT"]);
                     }
                     if (!$deathReal) {
                         print "*";
                     }
                     print "</b><span>" . $value->getSexImage() . $indiName . "<br/>" . $factarray["DEAT"] . " " . strip_tags($ddate->Display(false)) . " " . PrintReady($value->getDeathPlace()) . "</span></a>";
                 }
             }
             print "</td></tr></table>";
             echo '</div>';
         } else {
             if ($width > $minlength + 5) {
                 echo "\n<div style=\"text-align: left; position: absolute; top:" . $Y . "px; left:" . $startPos . "px; width:" . $width . "px; height:" . $height . "px; background-color:" . $this->color . "; border: solid blue 1px; z-index:{$Z};\">";
                 foreach ($eventinformation as $evtwidth => $val) {
                     print "<div style=\"position:absolute; left:" . $evtwidth . " \"><a class=\"showit\" href=\"#\" style=\"top:-2px; font-size:10px;\"><b>";
                     $text = explode("-fact,", $val);
                     $fact = $text[0];
                     $val = $text[1];
                     if (isset($factAbbrev[$fact])) {
                         print $factAbbrev[$fact];
                     } else {
                         print get_first_letter($val);
                     }
                     print "</b><span>" . PrintReady($val) . "</span></a></div>";
                 }
                 $indiName = PrintReady(str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $value->getFullName()));
                 print "\n\t<table dir=\"ltr\"><tr>\n\t\t<td width=\"15\"><a class=\"showit\" href=\"#\"><b>";
                 if (isset($factAbbrev["BIRT"])) {
                     print $factAbbrev["BIRT"];
                 } else {
                     print get_first_letter($factarray["BIRT"]);
                 }
                 if (!$birthReal) {
                     print "*";
                 }
                 print "</b><span>" . $value->getSexImage() . $indiName . "<br/>" . $factarray["BIRT"] . " " . strip_tags($bdate->Display(false)) . " " . PrintReady($value->getBirthPlace()) . "</span></a></td>" . "<td align=\"left\" width=\"100%\"><a href=\"" . encode_url($value->getLinkUrl()) . "\">" . $value->getSexImage() . $indiName . "</a></td>" . "\n\t\t<td width=\"15\">";
                 if ($value->isDead()) {
                     if ($deathReal || $value->isDead()) {
                         print "<a class=\"showit\" href=\"#\"><b>";
                         if (isset($factAbbrev["DEAT"])) {
                             print $factAbbrev["DEAT"];
                         } else {
                             print get_first_letter($factarray["DEAT"]);
                         }
                         if (!$deathReal) {
                             print "*";
                         }
                         print "</b><span>" . $value->getSexImage() . $indiName . "<br/>" . $factarray["DEAT"] . " " . strip_tags($ddate->Display(false)) . " " . PrintReady($value->getDeathPlace()) . "</span></a>";
                     }
                 }
                 print "</td></tr></table>";
                 echo '</div>';
             } else {
                 echo "\n<div style=\"text-align: left; position: absolute;top:" . $Y . "px; left:" . $startPos . "px;width:" . $width . "px; height:" . $height . "px; background-color:" . $this->color . "; border: solid blue 1px; z-index:{$Z};\">";
                 $indiName = PrintReady(str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $value->getFullName()));
                 print "<a class=\"showit\" href=\"" . encode_url($value->getLinkUrl()) . "\"><b>";
                 if (isset($factAbbrev["BIRT"])) {
                     print $factAbbrev["BIRT"];
                 } else {
                     print get_first_letter($factarray["BIRT"]);
                 }
                 if (!$birthReal) {
                     print "*";
                 }
                 print "</b><span>" . $value->getSexImage() . $indiName . "<br/>" . $factarray["BIRT"] . " " . strip_tags($bdate->Display(false)) . " " . PrintReady($value->getBirthPlace()) . "<br/>";
                 foreach ($eventinformation as $evtwidth => $val) {
                     $text = explode("-fact,", $val);
                     $val = $text[1];
                     print $val . "<br />\n";
                 }
                 if ($value->isDead() && $deathReal) {
                     print $factarray["DEAT"] . " " . strip_tags($ddate->Display(false)) . " " . PrintReady($value->getDeathPlace());
                 }
                 print "</span></a>";
                 echo '</div>';
             }
         }
         $zindex--;
         if ($maxX < $startPos + $width) {
             $maxX = $startPos + $width;
         }
         if ($maxY < $Y) {
             $maxY = $Y;
         }
     }
     return $maxY;
 }
            if (in_array($fact, $famaddfacts)) {
                $newreqd = array();
                foreach ($famreqdfacts as $r => $rfact) {
                    if ($rfact != $fact) {
                        $newreqd[] = $rfact;
                    }
                }
                $famreqdfacts = $newreqd;
                $famfacts[] = $eventObj;
            }
        }
        foreach ($famreqdfacts as $ind => $fact) {
            $newEvent = new Event("1 {$fact}\n");
            $famfacts[] = $newEvent;
        }
        sort_facts($famfacts);
        $spid = "";
        if ($parents) {
            if ($pid != $parents["HUSB"]) {
                $spid = $parents["HUSB"];
            } else {
                $spid = $parents["WIFE"];
            }
        }
        // NOTE: Father
        ?>
	<tr><td class="topbottombar" colspan="4">
<?php 
        echo $pgv_lang['father'], ' ';
        $person = Person::getInstance($parents['HUSB']);
        if ($person) {
Exemple #12
0
 /**
  * The facts and events for this record.
  *
  * @param string $filter
  * @param bool   $sort
  * @param int    $access_level
  * @param bool   $override     Include private records, to allow us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES.
  *
  * @return WT_Fact[]
  */
 public function getFacts($filter = null, $sort = false, $access_level = WT_USER_ACCESS_LEVEL, $override = false)
 {
     $facts = array();
     if ($this->canShow($access_level) || $override) {
         foreach ($this->facts as $fact) {
             if (($filter == null || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) {
                 $facts[] = $fact;
             }
         }
     }
     if ($sort) {
         sort_facts($facts);
     }
     return $facts;
 }
Exemple #13
0
 /**
  * return a list of facts
  * @return array
  */
 function getFacts($includeFileName = true)
 {
     global $pgv_changes, $GEDCOM, $pgv_lang;
     $ignore = array("TITL", "FILE");
     if ($this->show_changes) {
         $ignore = array();
     } else {
         if (PGV_USER_GEDCOM_ADMIN) {
             $ignore = array("TITL");
         }
     }
     $facts = $this->mediaobject->getFacts($ignore);
     sort_facts($facts);
     //		if ($includeFileName) $facts[] = new Event("1 FILE ".$this->mediaobject->getFilename());
     $mediaType = $this->mediaobject->getMediatype();
     if (isset($pgv_lang["TYPE__" . $mediaType])) {
         $facts[] = new Event("1 TYPE " . $pgv_lang["TYPE__" . $mediaType]);
     } else {
         $facts[] = new Event("1 TYPE " . $pgv_lang["TYPE__other"]);
     }
     if (isset($pgv_changes[$this->pid . "_" . $GEDCOM]) && $this->show_changes) {
         $newrec = find_updated_record($this->pid);
         $newmedia = new Media($newrec);
         $newfacts = $newmedia->getFacts($ignore);
         if ($includeFileName) {
             $newfacts[] = new Event("1 TYPE " . $pgv_lang["TYPE__" . $mediaType]);
         }
         $newfacts[] = new Event("1 FORM " . $newmedia->getFiletype());
         $mediaType = $newmedia->getMediatype();
         if (isset($pgv_lang["TYPE__" . $mediaType])) {
             $newfacts[] = new Event("1 TYPE " . $mediaType);
         } else {
             $newfacts[] = new Event("1 TYPE " . $pgv_lang["TYPE__other"]);
         }
         //-- loop through new facts and add them to the list if they are any changes
         //-- compare new and old facts of the Personal Fact and Details tab 1
         for ($i = 0; $i < count($facts); $i++) {
             $found = false;
             foreach ($newfacts as $indexval => $newfact) {
                 if (trim($newfact->gedcomRecord) == trim($facts[$i]->gedcomRecord)) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $facts[$i]->gedcomRecord .= "\nPGV_OLD\n";
             }
         }
         foreach ($newfacts as $indexval => $newfact) {
             $found = false;
             foreach ($facts as $indexval => $fact) {
                 if (trim($fact->gedcomRecord) == trim($newfact->gedcomRecord)) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $newfact->gedcomRecord .= "\nPGV_NEW\n";
                 $facts[] = $newfact;
             }
         }
     }
     if ($this->mediaobject->fileExists()) {
         // get height and width of image, when available
         if ($this->mediaobject->getWidth()) {
             $facts[] = new Event("1 EVEN " . '<span dir="ltr">' . $this->mediaobject->getWidth() . " x " . $this->mediaobject->getHeight() . '</span>' . "\n2 TYPE image_size");
         }
         //Prints the file size
         //Rounds the size of the image to 2 decimal places
         $facts[] = new Event("1 EVEN " . '<span dir="ltr">' . round($this->mediaobject->getFilesizeraw() / 1024, 2) . " kb" . '</span>' . "\n2 TYPE file_size");
     }
     sort_facts($facts);
     return $facts;
 }
Exemple #14
0
 public function printFamilyFacts()
 {
     global $linkToID;
     $linkToID = $this->record->getXref();
     // -- Tell addmedia.php what to link to
     $indifacts = $this->record->getFacts();
     if ($indifacts) {
         sort_facts($indifacts);
         foreach ($indifacts as $fact) {
             print_fact($fact, $this->record);
         }
     } else {
         echo '<tr><td class="messagebox" colspan="2">', WT_I18N::translate('No facts for this family.'), '</td></tr>';
     }
     if (WT_USER_CAN_EDIT) {
         print_add_new_fact($this->record->getXref(), $indifacts, 'FAM');
         echo '<tr><td class="descriptionbox">';
         echo WT_Gedcom_Tag::getLabel('NOTE');
         echo '</td><td class="optionbox">';
         echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','NOTE');\">", WT_I18N::translate('Add a new note'), '</a>';
         echo help_link('add_note');
         echo '</td></tr>';
         echo '<tr><td class="descriptionbox">';
         echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
         echo '</td><td class="optionbox">';
         echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SHARED_NOTE');\">", WT_I18N::translate('Add a new shared note'), '</a>';
         echo help_link('add_shared_note');
         echo '</td></tr>';
         if (get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) {
             echo '<tr><td class="descriptionbox">';
             echo WT_Gedcom_Tag::getLabel('OBJE');
             echo '</td><td class="optionbox">';
             echo "<a href=\"#\" onclick=\"window.open('addmedia.php?action=showmediaform&amp;linktoid=" . $this->record->getXref() . "', '_blank', edit_window_specs); return false;\">", WT_I18N::translate('Add a new media object'), '</a>';
             echo help_link('OBJE');
             echo '<br>';
             echo "<a href=\"#\" onclick=\"window.open('inverselink.php?linktoid=" . $this->record->getXref() . "&amp;linkto=family', '_blank', find_window_specs); return false;\">", WT_I18N::translate('Link to an existing media object'), '</a>';
             echo '</td></tr>';
         }
         echo '<tr><td class="descriptionbox">';
         echo WT_Gedcom_Tag::getLabel('SOUR');
         echo '</td><td class="optionbox">';
         echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SOUR');\">", WT_I18N::translate('Add a new source citation'), '</a>';
         echo help_link('add_source');
         echo '</td></tr>';
     }
 }
Exemple #15
0
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package PhpGedView
 * @version $Id$
 */
require 'config.php';
header("Content-Type: text/html; charset={$CHARACTER_SET}");
$pid = safe_GET_xref('pid');
$person = Person::getInstance($pid);
if (!$person->canDisplayDetails()) {
    return $pgv_lang['private'];
}
$nonfacts = array("SEX", "FAMS", "FAMC", "NAME", "TITL", "NOTE", "SOUR", "SSN", "OBJE", "HUSB", "WIFE", "CHIL", "ALIA", "ADDR", "PHON", "SUBM", "_EMAIL", "CHAN", "URL", "EMAIL", "WWW", "RESI", "_UID", "_TODO", "_PGV_OBJS");
$person->add_family_facts(false);
$subfacts = $person->getIndiFacts();
sort_facts($subfacts);
$f2 = 0;
/* @var $event Event */
foreach ($subfacts as $indexval => $event) {
    if ($event->canShowDetails()) {
        if ($f2 > 0) {
            print "<br />\n";
        }
        $f2++;
        // handle ASSO record
        if ($event->getTag() == 'ASSO') {
            print_asso_rela_record($pid, $event->getGedComRecord(), false);
            continue;
        }
        $fact = $event->getTag();
        $details = $event->getDetail();
/**
* @todo add info
* @param array $attrs an array of key value pairs for the attributes
* @see PGVRFactsEHandler()
*/
function PGVRFactsSHandler($attrs)
{
    global $repeats, $repeatsStack, $gedrec, $parser, $parserStack, $repeatBytes, $processRepeats, $vars;
    $processRepeats++;
    if ($processRepeats > 1) {
        return;
    }
    $families = 1;
    if (isset($attrs["families"])) {
        $families = $attrs["families"];
    }
    array_push($repeatsStack, array($repeats, $repeatBytes));
    $repeats = array();
    $repeatBytes = xml_get_current_line_number($parser);
    $id = "";
    $gmatch = array();
    $gt = preg_match("/0 @(.+)@/", $gedrec, $gmatch);
    if ($gt > 0) {
        $id = $gmatch[1];
    }
    $tag = "";
    if (isset($attrs["ignore"])) {
        $tag .= $attrs["ignore"];
    }
    $match = array();
    $ct = preg_match("/\\\$(.+)/", $tag, $match);
    if ($ct > 0) {
        $tag = $vars[$match[1]]["id"];
    }
    if (empty($attrs["diff"]) && !empty($id)) {
        $record = GedcomRecord::getInstance($id);
        $facts = $record->getFacts(explode(",", $tag));
        if (!is_array($facts)) {
            $facts = array($facts);
        }
        sort_facts($facts);
        $repeats = array();
        foreach ($facts as $event) {
            if (strpos($tag . ",", $event->getTag()) === false) {
                $repeats[] = $event->getGedComRecord();
            }
        }
    } else {
        global $nonfacts;
        $nonfacts = preg_split("/[\\s,;:]/", $tag);
        $record = new GedcomRecord($gedrec);
        switch ($record->getType()) {
            case 'INDI':
                $record = new Person($gedrec);
                break;
            case 'FAM':
                $record = new Family($gedrec);
                break;
            case 'SOUR':
                $record = new Source($gedrec);
                break;
            case 'REPO':
                $record = new Repository($gedrec);
                break;
            case 'NOTE':
                $record = new Note($gedrec);
                break;
        }
        $oldrecord = GedcomRecord::getInstance($record->getXref());
        $oldrecord->diffMerge($record);
        $facts = $oldrecord->getFacts();
        foreach ($facts as $fact) {
            if (strstr($fact->getGedcomRecord(), "PGV_NEW") !== false) {
                $repeats[] = $fact->getGedcomRecord();
            }
        }
    }
}