| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- $user = Core::$user;
- $tests = $user->getPendingTests();
- $locations = Location::load(array_column($tests, "location_id"));
- $dts = date("d/m/Y H:i:s");
- $dts_slug = date("Ymd-His");
- header("Content-Type: text/xml; charset=utf-8");
- header("Content-Disposition: attachment; filename=tests-$dts_slug.kml");
- $xml = simplexml_load_file(ROOT_DIR . "/files/empty.kml");
- $folder_node = $xml->addChild("Folder");
- $folder_node->addChild("name", __("Tests"));
- $folder_node->addChild("open", 1);
- $folder_node->addChild("description", sprintf(__("Test locations as of %s"), $dts));
- foreach($locations as $location) {
- $placemark_node = $folder_node->addChild("Placemark");
- $placemark_node->addChild("name", htmlspecialchars($location->name));
- $placemark_node->addChild("description", htmlspecialchars($location->getDisplayAddress()));
- $point_node = $placemark_node->addChild("Point");
- $point_node->addChild("coordinates", $location->longitude . "," . $location->latitude);
- }
- echo $xml->asXML();
- ?>
|