private function pedigreeMap() { global $controller, $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS; // Default is show for both of these. $hideflags = WT_Filter::get('hideflags'); $hidelines = WT_Filter::get('hidelines'); $controller = new WT_Controller_Pedigree(); // Start of internal configuration variables // Limit this to match available number of icons. // 8 generations equals 255 individuals $MAX_PEDIGREE_GENERATIONS = min($MAX_PEDIGREE_GENERATIONS, 8); // End of internal configuration variables $controller->setPageTitle(WT_I18N::translate('Pedigree map of %s', $controller->getPersonName()))->pageHeader()->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();'); echo '<link type="text/css" href="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/css/wt_v3_googlemap.css" rel="stylesheet">'; echo '<div id="pedigreemap-page"> <h2>', $controller->getPageTitle(), '</h2>'; // -- print the form to change the number of displayed generations ?> <form name="people" method="get" action="?"> <input type="hidden" name="ged" value="<?php echo WT_Filter::escapeHtml(WT_GEDCOM); ?> "> <input type="hidden" name="mod" value="googlemap"> <input type="hidden" name="mod_action" value="pedigree_map"> <table class="list_table" width="555"> <tr> <td class="descriptionbox wrap"> <?php echo WT_I18N::translate('Individual'); ?> </td> <td class="descriptionbox wrap"> <?php echo WT_I18N::translate('Generations'); ?> </td> <td class="descriptionbox wrap"> <?php echo WT_I18N::translate('Hide flags'), help_link('PEDIGREE_MAP_hideflags', 'googlemap'); ?> </td> <td class="descriptionbox wrap"> <?php echo WT_I18N::translate('Hide lines'), help_link('PEDIGREE_MAP_hidelines', 'googlemap'); ?> </td> </tr> <tr> <td class="optionbox"> <input class="pedigree_form" data-autocomplete-type="INDI" type="text" id="rootid" name="rootid" size="3" value="<?php echo $controller->root->getXref(); ?> "> <?php echo print_findindi_link('rootid'); ?> </td> <td class="optionbox"> <select name="PEDIGREE_GENERATIONS"> <?php for ($p = 3; $p <= $MAX_PEDIGREE_GENERATIONS; $p++) { echo '<option value="', $p, '" '; if ($p == $controller->PEDIGREE_GENERATIONS) { echo 'selected="selected"'; } echo '>', $p, '</option>'; } ?> </select> </td> <td class="optionbox"> <?php echo '<input name="hideflags" type="checkbox"'; if ($hideflags) { echo ' checked="checked"'; } echo '>'; ?> </td> <td class="optionbox"> <?php echo '<input name="hidelines" type="checkbox"'; if ($hidelines) { echo ' checked="checked"'; } echo '>'; ?> </td> </tr> <tr> <td class="topbottombar" colspan="5"> <input type="submit" value="<?php echo WT_I18N::translate('View'); ?> "> </td> </tr> </table> </form> <!-- end of form --> <!-- count records by type --> <?php $curgen = 1; $priv = 0; $count = 0; $miscount = 0; $missing = ''; $latlongval = array(); $lat = array(); $lon = array(); for ($i = 0; $i < $controller->treesize; $i++) { // -- check to see if we have moved to the next generation if ($i + 1 >= pow(2, $curgen)) { $curgen++; } $person = WT_Individual::getInstance($controller->treeid[$i]); if (!empty($person)) { $name = $person->getFullName(); if ($name == WT_I18N::translate('Private')) { $priv++; } $place = $person->getBirthPlace(); if (empty($place)) { $latlongval[$i] = null; } else { $latlongval[$i] = $this->getLatitudeAndLongitudeFromPlaceLocation($person->getBirthPlace()); } if ($latlongval[$i]) { $lat[$i] = str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval[$i]->pl_lati); $lon[$i] = str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval[$i]->pl_long); if ($lat[$i] != null && $lon[$i] != null) { $count++; } else { // The place is in the table but has empty values if ($name) { if ($missing) { $missing .= ', '; } $missing .= '<a href="' . $person->getHtmlUrl() . '">' . $name . '</a>'; $miscount++; } } } else { // There was no place, or not listed in the map table if ($name) { if ($missing) { $missing .= ', '; } $missing .= '<a href="' . $person->getHtmlUrl() . '">' . $name . '</a>'; $miscount++; } } } } //<!-- end of count records by type --> //<!-- start of map display --> echo '<div id="pedigreemap_chart">'; echo '<table class="tabs_table" cellspacing="0" cellpadding="0" border="0" width="100%">'; echo '<tr>'; echo '<td valign="top">'; echo '<div id="pm_map" style="border: 1px solid gray; height: ', $this->getSetting('GM_YSIZE'), 'px; font-size: 0.9em;'; echo '"><i class="icon-loading-large"></i></div>'; if (Auth::isAdmin()) { echo '<table width="100%">'; echo '<tr><td align="left">'; echo '<a href="module.php?mod=googlemap&mod_action=admin_config">', WT_I18N::translate('Google Maps™ preferences'), '</a>'; echo '</td>'; echo '<td align="center">'; echo '<a href="module.php?mod=googlemap&mod_action=admin_places">', WT_I18N::translate('Geographic data'), '</a>'; echo '</td>'; echo '<td align="right">'; echo '<a href="module.php?mod=googlemap&mod_action=admin_placecheck">', WT_I18N::translate('Place check'), '</a>'; echo '</td></tr>'; echo '</table>'; } echo '</td><td width="15px"> </td>'; echo '<td width="310px" valign="top">'; echo '<div id="side_bar" style="width:300px; font-size:0.9em; overflow:auto; overflow-x:hidden; overflow-y:auto; height:', $this->getSetting('GM_YSIZE'), 'px;"></div></td>'; echo '</tr>'; echo '</table>'; // display info under map echo '<hr>'; echo '<table cellspacing="0" cellpadding="0" border="0" width="100%">'; echo '<tr>'; echo '<td valign="top">'; // print summary statistics if (isset($curgen)) { $total = pow(2, $curgen) - 1; echo WT_I18N::plural('%1$d individual displayed, out of the normal total of %2$d, from %3$d generations.', '%1$d individuals displayed, out of the normal total of %2$d, from %3$d generations.', $count, $count, $total, $curgen), '<br>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td valign="top">'; if ($priv) { echo WT_I18N::plural('%s individual is private.', '%s individuals are private.', $priv, $priv), '<br>'; } if ($count + $priv != $total) { if ($miscount == 0) { echo WT_I18N::translate('No ancestors in the database.'), "<br>"; } else { echo WT_I18N::plural('%1$d individual is missing birthplace map coordinates: %2$s.', '%1$d individuals are missing birthplace map coordinates: %2$s.', $miscount, $miscount, $missing), '<br>'; } } } echo '</td>'; echo '</tr>'; echo '</table>'; echo '</div>'; // close #pedigreemap_chart echo '</div>'; // close #pedigreemap-page ?> <!-- end of map display --> <!-- Start of map scripts --> <?php echo '<script src="', $this->googleMapsScript(), '"></script>'; $controller->addInlineJavascript($this->pedigreeMapJavascript($hideflags, $hidelines)); }
$controller->addInlineJavascript(' jQuery("html").css("overflow","visible"); // workaround for chrome v37 canvas bugs content_div = document.getElementById("content"); if (content_div) { content_div.style.height="' . ($maxyoffset + 30) . 'px"; } jQuery("#childarrow").on("click", "a", function(e) { e.preventDefault(); jQuery("#childbox").toggle(); }); // Draw joining lines in <canvas> // need to be able to read styles from style.css files function getStyle(oElm, strCssRule){ var strValue = ""; if(document.defaultView && document.defaultView.getComputedStyle){ strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); } else if(oElm.currentStyle){ strCssRule = strCssRule.replace(/\\-(\\w)/g, function (strMatch, p1){ return p1.toUpperCase(); }); strValue = oElm.currentStyle[strCssRule]; } return strValue; } // Set variables var c=document.getElementById("pedigree_canvas"); var ctx=c.getContext("2d"); var textdirection = "' . $TEXT_DIRECTION . '"; var talloffset = ' . $talloffset . '; var canvaswidth = ' . $canvaswidth . '; var offset_x = 20; var offset_y = ' . $controller->pbheight . '/2+' . $controller->linewidth . '; var lineDrawx = new Array("' . join(array_reverse($lineDrawx), '","') . '"); var lineDrawy = new Array("' . join(array_reverse($lineDrawy), '","') . '"); var offset_x2 = ' . $controller->pbwidth . '/2+' . $controller->linewidth . '; var offset_y2 = ' . $controller->pbheight . '*2; var lineDrawx2 = new Array("' . join($lineDrawx, '","') . '"); var lineDrawy2 = new Array("' . join($lineDrawy, '","') . '"); var maxjoins = Math.pow(2,' . $PEDIGREE_GENERATIONS . '); //Draw the lines if (talloffset < 2) { // landscape and portrait styles for (var i = 0; i <= maxjoins-3; i++) { if(i%2==0){ if (textdirection == "rtl") { ctx.moveTo(canvaswidth-lineDrawx[i],lineDrawy[i]-0+offset_y+offset_x/2); ctx.lineTo(canvaswidth-lineDrawx[i]+offset_x,lineDrawy[i]-0+offset_y+offset_x/2); ctx.lineTo(canvaswidth-lineDrawx[i+1]+offset_x,lineDrawy[i+1]-0+offset_y-offset_x/2); ctx.lineTo(canvaswidth-lineDrawx[i+1],lineDrawy[i+1]-0+offset_y-offset_x/2); } else { ctx.moveTo(lineDrawx[i],lineDrawy[i]-0+offset_y+offset_x/2); ctx.lineTo(lineDrawx[i]-offset_x,lineDrawy[i]-0+offset_y+offset_x/2); ctx.lineTo(lineDrawx[i+1]-offset_x,lineDrawy[i+1]-0+offset_y-offset_x/2); ctx.lineTo(lineDrawx[i+1],lineDrawy[i+1]-0+offset_y-offset_x/2); } } } } if (talloffset == 2) { // oldest at top for (var i = 0; i <= maxjoins; i++) { if(i%2!=0){ if (textdirection == "rtl") { ctx.moveTo(lineDrawx2[i]-0+offset_x2-offset_x,lineDrawy2[i]); ctx.lineTo(lineDrawx2[i]-0+offset_x2-offset_x,lineDrawy2[i]-0+offset_y2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]-0+offset_y2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]); } else { ctx.moveTo(lineDrawx2[i]-0+offset_x2-offset_x/2,lineDrawy2[i]); ctx.lineTo(lineDrawx2[i]-0+offset_x2-offset_x/2,lineDrawy2[i]-0+offset_y2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]-0+offset_y2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]); } } } } if (talloffset == 3) { // oldest at bottom for (var i = 0; i <= maxjoins; i++) { if(i%2!=0){ ctx.moveTo(lineDrawx2[i]-0+offset_x2-offset_x,lineDrawy2[i]); ctx.lineTo(lineDrawx2[i]-0+offset_x2-offset_x,lineDrawy2[i]-offset_y2/2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]-offset_y2/2); ctx.lineTo(lineDrawx2[i+1]-0+offset_x2+offset_x/2,lineDrawy2[i]); } } } // Set line styles ctx.strokeStyle = getStyle(document.getElementById("pedigree_canvas"), "color"); ctx.lineWidth = ' . $controller->linewidth . '; ctx.shadowColor = "' . $controller->shadowcolor . '"; ctx.shadowBlur = ' . $controller->shadowblur . '; ctx.shadowOffsetX = ' . $controller->shadowoffsetX . '; ctx.shadowOffsetY = ' . $controller->shadowoffsetY . '; ctx.stroke(); ');