/** * Creates the Javascript array for current locations. It is array of objects. Is there a better way to output JS in Moodle? * @param array Current Locations * @param integer $courseid * @return string The script including script tags */ function map_create_locations_js($locations, $courseid) { global $CFG; $script = ""; foreach ($locations as $location) { if ($location->showcode == "1") { if ($script != "") { $script .= ","; } if (map_isStudentLocation($location)) { $locType = "'student'"; $picHTML = addslashes_js(print_user_picture($location->userid, $courseid, $location->user->picture, 250, true)); $locDescription = addslashes_js($location->user->description); } else { $locType = "'extra'"; $picHTML = ""; $locDescription = addslashes_js($location->text); $location->title = addslashes_js($location->title); } $script .= "{userid: '{$location->userid}',latitude: '{$location->latitude}',longitude: '{$location->longitude}',city: '" . addslashes_js($location->city) . "',state: '" . addslashes_js($location->state) . "',country: '{$location->country}',title: '" . addslashes_js($location->title) . "',text: '" . $locDescription . "',firstname: '" . addslashes_js($location->user->firstname) . "',lastname: '" . addslashes_js($location->user->lastname) . "',description: '" . $locDescription . "',picHTML: '" . $picHTML . "',type: {$locType}}"; //$script .= "{userid: '$location->userid',latitude: '$location->latitude',longitude: '$location->longitude',city: '$location->city',state: '$location->state',country: '$location->country'}"; } } if ($script == "") { return ""; } $script = "<script type='text/javascript'>var locations = [{$script}];var baseMapURL = '{$CFG->wwwroot}/mod/map/';</script>"; return $script; }
// $Id: report.php,v 1.1 2008/08/13 17:05:47 arborrow Exp $ require_once "../../config.php"; require_once "lib.php"; require_once "map_security_check.php"; print_header_simple(format_string($map->name), "", "<a href=\"index.php?id={$course->id}\">{$strmaps}</a> -> " . format_string($map->name), "", "", true, "", navmenu($course, $cm)); require_once "handle_groups.php"; //echo "currentGroup=" .$currentGroup . " groupmode=" . $groupmode . " memberOfGroup=" . $memberOfGroup; echo '<div class="clearer"></div>'; if ($map->text) { print_box(format_text($map->text, $map->format), 'generalbox', 'intro'); } $map_locations = map_get_locations($map->id, $currentGroup); if ($map_locations) { $table->head = array(get_string("name"), get_string("location"), get_string("uploadedby", "map")); foreach ($map_locations as $location) { if (map_isStudentLocation($location)) { $studentLocations[] = array($location->user->firstname . " " . $location->user->lastname, map_addressString($location), ""); } else { $otherLocations[] = array($location->title, map_addressString($location), $location->user->firstname . " " . $location->user->lastname); } } echo "<br />"; $table->data = array(); if (isset($studentLocations)) { $table->data[] = array(get_string("studnetlocations", "map")); $table->data = array_merge($table->data, $studentLocations); } if (isset($otherLocations)) { $table->data[] = array(get_string("otherlocations", "map")); $table->data = array_merge($table->data, $otherLocations); }