1
0

tests_tester_kml.php 1001 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. $user = Core::$user;
  3. $tests = $user->getPendingTests();
  4. $locations = Location::load(array_column($tests, "location_id"));
  5. $dts = date("d/m/Y H:i:s");
  6. $dts_slug = date("Ymd-His");
  7. header("Content-Type: text/xml; charset=utf-8");
  8. header("Content-Disposition: attachment; filename=tests-$dts_slug.kml");
  9. $xml = simplexml_load_file(ROOT_DIR . "/files/empty.kml");
  10. $folder_node = $xml->addChild("Folder");
  11. $folder_node->addChild("name", __("Tests"));
  12. $folder_node->addChild("open", 1);
  13. $folder_node->addChild("description", sprintf(__("Test locations as of %s"), $dts));
  14. foreach($locations as $location) {
  15. $placemark_node = $folder_node->addChild("Placemark");
  16. $placemark_node->addChild("name", htmlspecialchars($location->name));
  17. $placemark_node->addChild("description", htmlspecialchars($location->getDisplayAddress()));
  18. $point_node = $placemark_node->addChild("Point");
  19. $point_node->addChild("coordinates", $location->longitude . "," . $location->latitude);
  20. }
  21. echo $xml->asXML();
  22. ?>