From: danstowell Date: Sat, 12 Aug 2006 17:36:22 +0000 (+0000) Subject: Now latlong data types allow you to choose which labels appear in Google Earth X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3af692dba0d30d6c1ab31eb9fcc135a60d7b0831;p=moodle.git Now latlong data types allow you to choose which labels appear in Google Earth --- diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index 0d18e14cbf..2748bb7484 100755 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -41,6 +41,12 @@ class data_field_latlong extends data_field_base { + // Parameter data used: + // "param1" is a comma-separated list of the linkout service names that are enabled for this instance + // "param2" indicates the label that will be used in generating Google Earth KML files: -1 for item #, -2 for lat/long, positive number for the (text) field to use. + + + function data_field_latlong($field=0, $data=0) { parent::data_field_base($field, $data); } diff --git a/mod/data/field/latlong/kml.php b/mod/data/field/latlong/kml.php index d1170958ea..5e00a2419f 100644 --- a/mod/data/field/latlong/kml.php +++ b/mod/data/field/latlong/kml.php @@ -78,12 +78,11 @@ if (isteacher($course->id)) { header('Content-type: application/vnd.google-earth.kml+xml kml'); header('Content-Disposition: attachment; filename="moodleearth-'.$d.'-'.$rid.'-'.$fieldid.'.kml"'); -//print_r($record); echo data_latlong_kml_top(); if($rid) { // List one single item - $pm->name = "Item #$rid"; + $pm->name = data_latlong_kml_get_item_name($content, $field); $pm->description = "<a href='$CFG->wwwroot/mod/data/view.php?d=$d&rid=$rid'>Item #$rid</a> in Moodle data activity"; $pm->long = $content->content1; $pm->lat = $content->content; @@ -92,14 +91,18 @@ if($rid) { // List one single item $contents = get_records('data_content', 'fieldid', $fieldid); + echo ''; + foreach($contents as $content) { - $pm->name = "Item #$content->recordid"; + $pm->name = data_latlong_kml_get_item_name($content, $field); $pm->description = "<a href='$CFG->wwwroot/mod/data/view.php?d=$d&rid=$content->recordid'>Item #$content->recordid</a> in Moodle data activity"; $pm->long = $content->content1; $pm->lat = $content->content; echo data_latlong_kml_placemark($pm); } + echo ''; + } echo data_latlong_kml_bottom(); @@ -110,7 +113,7 @@ echo data_latlong_kml_bottom(); function data_latlong_kml_top() { return ' - + '; } @@ -136,6 +139,23 @@ function data_latlong_kml_placemark($pm) { } function data_latlong_kml_bottom() { - return ''; + return ''; } +function data_latlong_kml_get_item_name($content, $field) { + // $field->param2 contains the user-specified labelling method + + $name = ''; + + if($field->param2 > 0) { + $name = htmlspecialchars(get_field('data_content', 'content', 'fieldid', $field->param2, 'recordid', $content->recordid)); + }elseif($field->param2 == -2) { + $name = $content->content . ', ' . $content->content1; + } + if($name=='') { // Done this way so that "item #" is the default that catches any problems + $name = get_string('entry', 'data') . " #$content->recordid"; + } + + + return $name; +} diff --git a/mod/data/field/latlong/mod.html b/mod/data/field/latlong/mod.html index 03adc77391..d0d0c078ea 100755 --- a/mod/data/field/latlong/mod.html +++ b/mod/data/field/latlong/mod.html @@ -10,7 +10,7 @@ : - field->param1)); foreach($this->linkoutservices as $servicename=>$serviceurl) { @@ -21,4 +21,24 @@ + + : + + + +