summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Meaney <larry_meaney@iname.com>2011-02-23 05:35:58 +0000
committerLarry Meaney <larry_meaney@iname.com>2011-02-23 05:35:58 +0000
commit529943c9294f3a14309132ea35c38f893b828247 (patch)
treefa661d65881a2e61128f49fd3e9ec3a5d508e88c
parent7da981675b263a2ef69d4b4510be287adf0f6017 (diff)
downloadwebtrees-529943c9294f3a14309132ea35c38f893b828247.tar.gz
webtrees-529943c9294f3a14309132ea35c38f893b828247.tar.bz2
webtrees-529943c9294f3a14309132ea35c38f893b828247.zip
* better handling of current level in hierarchy
* code defensively to prevent page from crashing
-rw-r--r--modules/googlemap/placehierarchy.php34
1 files changed, 30 insertions, 4 deletions
diff --git a/modules/googlemap/placehierarchy.php b/modules/googlemap/placehierarchy.php
index aa03cf134e..15629ac62f 100644
--- a/modules/googlemap/placehierarchy.php
+++ b/modules/googlemap/placehierarchy.php
@@ -635,8 +635,28 @@ function map_scripts($numfound, $level, $parent, $linklevels, $placelevels, $pla
$placeidlist=array();
// if ($numfound==0 && $level>0) {
if (isset($levelo[($level-1)])) { // ** BH not sure yet what this if statement is for ... TODO **
- // there are no sub-places under this place, therefore, show the current place on the map
- $placeidlist[] = $levelm;
+ // show the current place on the map
+
+ $place = WT_DB::prepare("SELECT pl_id as place_id, pl_place as place, pl_lati as lati, pl_long, pl_zoom as zoom, pl_icon as icon FROM ##placelocation WHERE pl_id=?")
+ ->execute(array($levelm))
+ ->fetch(PDO::FETCH_ASSOC);
+
+ if ($place) {
+ // re-calculate the hierarchy information required to display the current place
+ $thisloc = $parent;
+ $xx = array_pop($thisloc);
+ $thislevel = $level-1 ;
+ $thislinklevels = substr($linklevels,0,strrpos($linklevels,'&amp;'));
+ if (strpos($placelevels,',',1)) {
+ $thisplacelevels = substr($placelevels,strpos($placelevels,',',1));
+ } else {
+ // this is the top level, remove everything
+ $thisplacelevels = '';
+ }
+
+ $place['long'] = $place['pl_long']; // mysql won't allow us to name this "long" in the select statement
+ print_gm_markers($place, $thislevel, $thisloc, $place['place_id'], $thislinklevels, $thisplacelevels);
+ }
}
// } else {
// sub-places exist for this place, display them
@@ -649,8 +669,14 @@ function map_scripts($numfound, $level, $parent, $linklevels, $placelevels, $pla
// }
if ($placeidlist) {
- $placeidlist=array_unique($placeidlist);
-
+ // flip the array (thus removing duplicates)
+ $placeidlist=array_flip($placeidlist);
+ // remove entry for parent location, plotted above
+ unset($placeidlist[$levelm]);
+ }
+ if ($placeidlist) {
+ // the keys are all we care about (this reverses the earlier array_flip, and ensures there are no "holes" in the array)
+ $placeidlist=array_keys($placeidlist);
// note: this implode/array_fill code generates one '?' for each entry in the $placeidlist array
$placelist =
WT_DB::prepare('SELECT pl_id as place_id, pl_place as place, pl_lati as lati, pl_long, pl_zoom as zoom, pl_icon as icon FROM `##placelocation` WHERE pl_id IN ('.implode(',', array_fill(0, count($placeidlist), '?')).')')