requireAdminLogin() ->setPageTitle(WT_I18N::translate('Place Check')) ->pageHeader(); $target=$openinnew ? 'target="_blank"' : ''; echo '', '', '', '', '
', WT_I18N::translate('Google Maps configuration'), '', '', WT_I18N::translate('Edit geographic place locations'), '', '', WT_I18N::translate('Place Check'), '', help_link('GOOGLEMAP_PLACECHECK','googlemap'), '
'; //Start of User Defined options echo ''; echo ''; echo ''; echo ''; //Show Filter table if (!isset ($_POST['matching'])) {$matching=false;} else {$matching=true;} echo ''; echo ''; echo ''; echo ''; echo '
'; echo ''; echo ''; //Option box to select gedcom echo ''; echo ''; //Option box for 'Open in new window' echo ''; echo ''; //Option box to select Country within Gedcom echo ''; echo ''; //Option box to select level 2 place within the selected Country if ($country!='XYZ') { echo ''; echo ''; } echo '
', WT_I18N::translate('PlaceCheck List Options'), '
', WT_I18N::translate('Family tree'), '
', WT_I18N::translate('Open links in'), '
', WT_I18N::translate('Country'), '
', /* I18N: Part of a country, state/region/county */ WT_I18N::translate('Subdivision'), '
'; echo '
'; echo ''; echo ''; echo '
'; echo WT_I18N::translate('List filtering options'), help_link('PLACECHECK_FILTER','googlemap'); echo '
'; echo WT_I18N::translate('Include fully matched places: '), help_link('PLACECHECK_MATCH','googlemap'); echo '
'; echo '
'; echo ''; echo '
'; echo '
'; switch ($action) { case 'go': //Identify gedcom file echo "
", WT_I18N::translate('Place list for GEDCOM file'), ": ", htmlspecialchars(get_gedcom_setting($gedcom_id, 'title')), "
"; //Select all '2 PLAC ' tags in the file and create array $place_list=array(); $ged_data=WT_DB::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_gedcom LIKE ? AND i_file=?") ->execute(array("%\n2 PLAC %", $gedcom_id)) ->fetchOneColumn(); foreach ($ged_data as $ged_datum) { preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); foreach ($matches[1] as $match) { $place_list[$match]=true; } } $ged_data=WT_DB::prepare("SELECT f_gedcom FROM `##families` WHERE f_gedcom LIKE ? AND f_file=?") ->execute(array("%\n2 PLAC %", $gedcom_id)) ->fetchOneColumn(); foreach ($ged_data as $ged_datum) { preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); foreach ($matches[1] as $match) { $place_list[$match]=true; } } // Unique list of places $place_list=array_keys($place_list); // Apply_filter if ($country=='XYZ') { $filter='.*$'; } else { $filter=preg_quote($country).'$'; if ($state!='XYZ') { $filter=preg_quote($state).', '.$filter; } } $place_list=preg_grep('/'.$filter.'/', $place_list); //sort the array, limit to unique values, and count them $place_parts=array(); usort($place_list, "utf8_strcasecmp"); $i=count($place_list); //calculate maximum no. of levels to display $x=0; $max=0; while ($x<$i) { $levels=explode(",", $place_list[$x]); $parts=count($levels); if ($parts>$max) $max=$parts; $x++;} $x=0; //scripts for edit, add and refresh ?> "; echo ""; echo ""; echo ""; echo ""; while ($cols<$max) { if ($cols == 0) { echo ""; } else { echo ""; } $cols++; } echo ""; $cols=0; while ($cols<$max) { echo ""; $cols++; } echo ""; $countrows=0; while ($x<$i) { $placestr=""; $levels=explode(",", $place_list[$x]); $parts=count($levels); $levels=array_reverse($levels); $placestr.="$ppart) { $ppart=urlencode(trim($ppart)); $placestr.="parent[$pindex]=".$ppart."&"; } $placestr.="level=".count($levels); $placestr.="\">".$place_list[$x].""; $gedplace=""; $z=0; $y=0; $id=0; $level=0; $matched[$x]=0;// used to exclude places where the gedcom place is matched at all levels $mapstr_edit=""; $mapstr7="')\">"; $mapstr8=""; while ($z<$parts) { if ($levels[$z]==' ' || $levels[$z]=='') $levels[$z]="unknown";// GoogleMap module uses "unknown" while GEDCOM uses , , $levels[$z]=rtrim(ltrim($levels[$z])); $placelist=create_possible_place_names($levels[$z], $z+1); // add the necessary prefix/postfix values to the place name foreach ($placelist as $key=>$placename) { $row= WT_DB::prepare("SELECT pl_id, pl_place, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place") ->execute(array($z, $id, $placename)) ->fetchOneRow(PDO::FETCH_ASSOC); if (!empty($row['pl_id'])) { $row['pl_placerequested']=$levels[$z]; // keep the actual place name that was requested so we can display that instead of what is in the db break; } } if ($row['pl_id']!='') { $id=$row['pl_id']; } if ($row['pl_place']!='') { $placestr2=$mapstr_edit.$id."&level=".$level.$mapstr3.$mapstr5.WT_I18N::translate('Zoom=').$row['pl_zoom'].$mapstr6.$row['pl_placerequested'].$mapstr8; if ($row['pl_place']=='unknown') $matched[$x]++; } else { if ($levels[$z]=="unknown") { $placestr2=$mapstr_add.$id."&level=".$level.$mapstr3.$mapstr7."".rtrim(ltrim(WT_I18N::translate('unknown')))."".$mapstr8;$matched[$x]++; } else { $placestr2=$mapstr_add.$id."&place_name=".urlencode($levels[$z])."&level=".$level.$mapstr3.$mapstr7.''.rtrim(ltrim($levels[$z])).''.$mapstr8;$matched[$x]++; } } $plac[$z]="\n"; if ($row['pl_lati']=='0') { $lati[$z]=""; } else if ($row['pl_lati']!='') { $lati[$z]=""; } else { $lati[$z]="";$matched[$x]++; } if ($row['pl_long']=='0') { $long[$z]=""; } else if ($row['pl_long']!='') { $long[$z]=""; } else { $long[$z]="";$matched[$x]++; } $level++; $mapstr3=$mapstr3."&parent[".$z."]=".addslashes(PrintReady($row['pl_placerequested'])); $mapstr4=$mapstr4."&parent[".$z."]=".addslashes(PrintReady(rtrim(ltrim($levels[$z])))); $z++; } if ($matching) { $matched[$x]=1; } if ($matched[$x]!=0) { echo $gedplace; $z=0; while ($z<$max) { if ($z<$parts) { echo $plac[$z]; echo $lati[$z]; echo $long[$z]; } else { echo "";} $z++; } echo ""; $countrows++; } $x++; } // echo final row of table echo "
", WT_I18N::translate('GEDCOM File Place Data
(2 PLAC tag)'), "
", WT_I18N::translate('GoogleMap Places Table Data'), "
", PrintReady(WT_I18N::translate('Country')), "", PrintReady(WT_I18N::translate('Level')), " ", $cols+1, "
", WT_Gedcom_Tag::getLabel('PLAC'), "", WT_I18N::translate('Latitude'), "", WT_I18N::translate('Longitude'), "
".$placestr."".$placestr2."".$row['pl_lati']."".$row['pl_lati']."X".$row['pl_long']."".$row['pl_long']."X   
", /* I18N: A count of places */ WT_I18N::translate('Total places: %s', WT_I18N::number($countrows)), "
"; break; default: // Do not run until user selects a gedcom/place/etc. // Instead, show some useful help info. echo "
", WT_I18N::translate('This will list all the places from the selected GEDCOM file. By default this will NOT INCLUDE places that are fully matched between the GEDCOM file and the GoogleMap tables'), "
"; break; }