* $Id$ */ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); exit; } if (file_exists(WT_ROOT.'modules/googlemap/defaultconfig.php')) { require WT_ROOT.'modules/googlemap/defaultconfig.php'; require WT_ROOT.'modules/googlemap/googlemap.php'; } require_once WT_ROOT.'includes/classes/class_stats.php'; $stats = new stats($GEDCOM); function check_exist_table() { global $TBLPREFIX; return WT_DB::table_exists("{$TBLPREFIX}placelocation"); } function get_place_list_loc($parent_id, $inactive=false) { global $display, $TBLPREFIX; if ($inactive) { $rows= WT_DB::prepare("SELECT pl_id, pl_place, pl_lati, pl_long, pl_zoom, pl_icon FROM {$TBLPREFIX}placelocation WHERE pl_parent_id=? ORDER BY pl_place") ->execute(array($parent_id)) ->fetchAll(); } else { $rows= WT_DB::prepare( "SELECT DISTINCT pl_id, pl_place, pl_lati, pl_long, pl_zoom, pl_icon". " FROM {$TBLPREFIX}placelocation". " INNER JOIN {$TBLPREFIX}places ON {$TBLPREFIX}placelocation.pl_place={$TBLPREFIX}places.p_place AND {$TBLPREFIX}placelocation.pl_level={$TBLPREFIX}places.p_level". " WHERE pl_parent_id=? ORDER BY pl_place" ) ->execute(array($parent_id)) ->fetchAll(); } $placelist=array(); foreach ($rows as $row) { $placelist[]=array("place_id"=>$row->pl_id, "place"=>$row->pl_place, "lati"=>$row->pl_lati, "long"=>$row->pl_long, "zoom"=>$row->pl_zoom, "icon"=>$row->pl_icon); } return $placelist; } function place_id_to_hierarchy($id) { global $TBLPREFIX; $statement= WT_DB::prepare("SELECT pl_parent_id, pl_place FROM {$TBLPREFIX}placelocation WHERE pl_id=?"); $arr=array(); while ($id!=0) { $row=$statement->execute(array($id))->fetchOneRow(); $arr=array($id=>$row->pl_place)+$arr; $id=$row->pl_parent_id; } return $arr; } function get_placeid($place) { global $TBLPREFIX; $par = explode (",", $place); $par = array_reverse($par); $place_id = 0; if (check_exist_table()) { for($i=0; $i $placename) { $pl_id= WT_DB::prepare("SELECT pl_id FROM {$TBLPREFIX}placelocation WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place") ->execute(array($i, $place_id, $placename)) ->fetchOne(); if (!empty($pl_id)) break; } if (empty($pl_id)) break; $place_id = $pl_id; } } return $place_id; } function get_p_id($place) { global $TBLPREFIX; $par = explode (",", $place); $par = array_reverse($par); $place_id = 0; for($i=0; $i $placename) { $pl_id= WT_DB::prepare("SELECT p_id FROM {$TBLPREFIX}places WHERE p_level=? AND p_parent_id=? AND p_file=? AND p_place LIKE ? ORDER BY p_place") ->execute(array($i, $place_id, WT_GED_ID, $placename)) ->fetchOne(); if (!empty($pl_id)) break; } if (empty($pl_id)) break; $place_id = $pl_id; } return $place_id; } function set_placeid_map($level, $parent) { if (!isset($levelm)) { $levelm=0; } $fullplace = ""; if ($level==0) $levelm=0; else { for ($i=1; $i<=$level; $i++) { $fullplace .= $parent[$level-$i].", "; } $fullplace = substr($fullplace, 0, -2); $levelm = get_p_id($fullplace); } return $levelm; } function set_levelm($level, $parent) { if (!isset($levelm)) { $levelm=0; } $fullplace = ""; if ($level==0) $levelm=0; else { for ($i=1; $i<=$level; $i++) { if ($parent[$level-$i]!="") $fullplace .= $parent[$level-$i].", "; else $fullplace .= "Unknown, "; } $fullplace = substr($fullplace, 0, -2); $levelm = get_placeid($fullplace); } return $levelm; } function create_map() { global $GOOGLEMAP_API_KEY, $GOOGLEMAP_PH_XSIZE, $GOOGLEMAP_PH_YSIZE, $GOOGLEMAP_MAP_TYPE, $TEXT_DIRECTION; // create the map // echo "\n

\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo "
"; ?> "; echo "
\n"; echo "", i18n::translate('Manage GoogleMap configuration'), ""; echo "\n"; echo "", i18n::translate('Edit geographic place locations'), ""; echo "\n"; echo "", i18n::translate('Place Check'), ""; echo "
\n"; } echo ""; } function check_were_am_i($numls, $levelm) { $where_am_i=place_id_to_hierarchy($levelm); $i=$numls+1; if (!isset($levelo)) { $levelo[0]=0; } foreach (array_reverse($where_am_i, true) as $id=>$place2) { $levelo[$i]=$id; $i--; } return $levelo; } function check_place($place_names, $place) { if ($place == "Unknown") $place=""; if (in_array($place, $place_names)) { return true; } } function print_how_many_people($level, $parent) { global $GEDCOM, $stats; $place_count_indi = 0; $place_count_fam = 0; if (!isset($parent[$level-1])) $parent[$level-1]=""; $p_id = set_placeid_map($level, $parent); $indi = $stats->_statsPlaces('INDI', false, $p_id); $fam = $stats->_statsPlaces('FAM', false, $p_id); if (!empty($indi)) { foreach ($indi as $place) { $place_count_indi=$place['tot']; } } if (!empty($fam)) { foreach ($fam as $place) { $place_count_fam=$place['tot']; } } echo "

", i18n::translate('Individuals'), ": ", $place_count_indi, ", ", i18n::translate('Families'), ": ", $place_count_fam; } function print_gm_markers($place2, $level, $parent, $levelm, $linklevels, $placelevels, $lastlevel=false){ global $GOOGLEMAP_COORD, $GOOGLEMAP_PH_MARKER, $GM_DISP_SHORT_PLACE, $GM_DISP_COUNT; if (($place2['lati'] == NULL) || ($place2['long'] == NULL) || (($place2['lati'] == "0") && ($place2['long'] == "0"))) { echo "var icon_type = new GIcon();\n"; echo " icon_type.image = \"modules/googlemap/images/marker_yellow.png\";\n"; echo " icon_type.shadow = \"modules/googlemap/images/shadow50.png\";\n"; echo " icon_type.iconSize = new GSize(20, 34);\n"; echo " icon_type.shadowSize = new GSize(37, 34);\n"; echo " icon_type.iconAnchor = new GPoint(6, 20);\n"; echo " icon_type.infoWindowAnchor = new GPoint(5, 1);\n"; echo "var point = new GLatLng(0, 0);\n"; if ($lastlevel) echo "var marker = createMarker(point, \"

"; else { echo "var marker = createMarker(point, \"
\", icon_type, \"", str_replace(array('‎', '‏'), array(WT_UTF8_LRM, WT_UTF8_RLM), PrintReady(addslashes($place2['place']))), "\");\n"; } else { $lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $place2['lati']); $long = str_replace(array('E', 'W', ','), array('', '-', '.'), $place2['long']); //delete leading zero if ($lati >= 0) { $lati = abs($lati); } elseif ($lati < 0) { $lati = "-".abs($lati); } if ($long >= 0) { $long = abs($long); } elseif ($long < 0) { $long = "-".abs($long); } // flags by kiwi_pgv if (($place2["icon"] == NULL) || ($place2['icon'] == "") || ($GOOGLEMAP_PH_MARKER != "G_FLAG")) { echo "var icon_type = new GIcon(G_DEFAULT_ICON);\n"; } else { echo "var icon_type = new GIcon();\n"; echo " icon_type.image = \"", $place2['icon'], "\";\n"; echo " icon_type.shadow = \"modules/googlemap/images/flag_shadow.png\";\n"; echo " icon_type.iconSize = new GSize(25, 15);\n"; echo " icon_type.shadowSize = new GSize(35, 45);\n"; echo " icon_type.iconAnchor = new GPoint(1, 45);\n"; echo " icon_type.infoWindowAnchor = new GPoint(5, 1);\n"; } echo "var point = new GLatLng({$lati}, {$long});\n"; if ($lastlevel) { echo "var marker = createMarker(point, \"\", icon_type, \"", $temp, "\");\n"; } } echo "place_map.addOverlay(marker);\n"; echo "bounds.extend(point);\n"; } function create_buttons($numfound, $level) { ?>