[MDL-15426] Distinguish latlong value being zero from no value

This commit is contained in:
robertall
2008-07-02 12:42:15 +00:00
parent 79cc2bf137
commit 74b4814e9c
+15 -6
View File
@@ -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;