diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-05-14 13:50:49 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-05-14 13:50:49 +0000 |
commit | 1119cf74af4e3fdc0b81e0667ba7f76f25313cc3 (patch) | |
tree | c08e719f5857618ac9d31ba71c346e463c05d024 /engine/lib/location.php | |
parent | cc2793708d645c7409576dd8cfca255eecfd01b6 (diff) | |
download | elgg-1119cf74af4e3fdc0b81e0667ba7f76f25313cc3.tar.gz elgg-1119cf74af4e3fdc0b81e0667ba7f76f25313cc3.tar.bz2 |
Fixed geocode stuff + version bump
git-svn-id: https://code.elgg.org/elgg/trunk@3289 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/location.php')
-rw-r--r-- | engine/lib/location.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/engine/lib/location.php b/engine/lib/location.php index 482a241b4..69e2fe2b1 100644 --- a/engine/lib/location.php +++ b/engine/lib/location.php @@ -59,23 +59,30 @@ { global $CONFIG; + // Handle cases where we are passed an array (shouldn't be but can happen if location is a tag field) + if (is_array($location)) + $location = implode(', ', $location); + $location = sanitise_string($location); // Look for cached version $cached_location = get_data_row("SELECT * from {$CONFIG->dbprefix}geocode_cache WHERE location='$location'"); - // Trigger geocode event + if ($cached_location) + return array('lat' => $cached_location->lat, 'long' => $cached_location->long); + + // Trigger geocode event if not cached $return = false; - $return = trigger_plugin_hook('geocode', 'location', array('location' => $location, $return)); + $return = trigger_plugin_hook('geocode', 'location', array('location' => $location), $return); // If returned, cache and return value if (($return) && (is_array($return))) { - $lat = (int)$return['lat']; - $long = (int)$return['long']; + $lat = (float)$return['lat']; + $long = (float)$return['long']; // Put into cache at the end of the page since we don't really care that much - execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (lat, long) VALUES ({$lat}, {$long}) ON DUPLICATE KEY UPDATE lat={$lat} long={$long}"); + execute_delayed_write_query("INSERT DELAYED INTO {$CONFIG->dbprefix}geocode_cache (location, lat, `long`) VALUES ('$location', '{$lat}', '{$long}') ON DUPLICATE KEY UPDATE lat='{$lat}', `long`='{$long}'"); } return $return; |