From 74b4814e9cfbe9e1400c81ad302c2e9cb9d73202 Mon Sep 17 00:00:00 2001 From: robertall Date: Wed, 2 Jul 2008 12:42:15 +0000 Subject: [PATCH] [MDL-15426] Distinguish latlong value being zero from no value --- mod/data/field/latlong/field.class.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index d5688e69148..c5ef25a62ea 100755 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -97,10 +97,13 @@ class data_field_latlong extends data_field_base { function display_browse_field($recordid, $template) { global $CFG; if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) { - $lat = empty($content->content)? '':$content->content; - $long = empty($content->content1)? '':$content->content1; - if (empty($lat) or empty($long)) { - return ''; + $lat = $content->content; + if (strlen($lat) < 1) { + return false; + } + $long = $content->content1; + if (strlen($long) < 1) { + return false; } if($lat < 0) { $compasslat = sprintf('%01.4f', -$lat) . '°S'; @@ -157,15 +160,21 @@ class data_field_latlong extends data_field_base { $content = new object; $content->fieldid = $this->field->id; $content->recordid = $recordid; + $value = trim($value); + if (strlen($value) > 0) { + $value = floatval($value); + } else { + $value = null; + } $names = explode('_', $name); switch ($names[2]) { case 0: // update lat - $content->content = (float)$value; + $content->content = $value; break; case 1: // update long - $content->content1 = (float)$value; + $content->content1 = $value; break; default: break;