";
echo "";
switch ($action) {
case 'go':
//Identify gedcom file
echo "", 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 {$TBLPREFIX}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 {$TBLPREFIX}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 "
", i18n::translate('GEDCOM File Place Data (2 PLAC tag)'), "
";
$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 {$TBLPREFIX}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.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(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]="
".$placestr2."
\n";
if ($row['pl_lati']=='0'){
$lati[$z]="
".$row['pl_lati']."
";
} else if ($row['pl_lati']!='') {
$lati[$z]="
".$row['pl_lati']."
";
} else {
$lati[$z]="
X
";$matched[$x]++;
}
if ($row['pl_long']=='0'){
$long[$z]="
".$row['pl_long']."
";
} else if ($row['pl_long']!='') {
$long[$z]="
".$row['pl_long']."
";
} else {
$long[$z]="
X
";$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==1) {
$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 "
";
break;
default:
// Do not run until user selects a gedcom/place/etc.
// Instead, show some useful help info.
echo "
", 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'), "