function call_okapi($usr, $waypoints, $lang, $file_base_name, $zip_part) { $okapi_response = \okapi\Facade::service_call('services/caches/formatters/ggz', $usr['userid'], array('cache_codes' => $waypoints, 'langpref' => $lang, 'ns_ground' => 'true', 'ns_ox' => 'true', 'images' => 'none', 'attrs' => 'ox:tags', 'trackables' => 'desc:count', 'alt_wpts' => 'true', 'recommendations' => 'desc:count', 'latest_logs' => 'true', 'lpc' => 'all', 'my_notes' => isset($usr) ? "desc:text" : "none", 'location_source' => 'alt_wpt:user-coords', 'location_change_prefix' => '(F)')); // Modifying OKAPI's default HTTP Response headers. $okapi_response->content_disposition = 'attachment; filename=' . $file_base_name . ($zip_part != 0 ? '-' . $zip_part : '') . '.ggz'; return $okapi_response; }
function call_okapi($usr, $waypoints, $lang, $file_base_name, $zip_part) { $okapi_params = array('cache_codes' => $waypoints, 'langpref' => $lang, 'location_source' => 'alt_wpt:user-coords', 'location_change_prefix' => '(F)'); // TODO: limit log entries per geocache? if (isset($_GET['format'])) { $okapi_params['caches_format'] = $_GET['format']; } $okapi_response = \okapi\Facade::service_call('services/caches/formatters/garmin', $usr['userid'], $okapi_params); // Modifying OKAPI's default HTTP Response headers. $okapi_response->content_disposition = 'attachment; filename=' . $file_base_name . ($zip_part != 0 ? '-' . $zip_part : '') . '.zip'; return $okapi_response; }
/** * Call OKAPI, parse response and display the results * @param array $params - params of the cache to search and display */ private function htmlFormat(array $params) { //call OKAPI $okapi_resp = \okapi\Facade::service_call('services/caches/shortcuts/search_and_retrieve', $this->user_id, $params); if (!is_a($okapi_resp, "ArrayObject")) { // strange OKAPI return !? error_log(__METHOD__ . ": ERROR: strange OKAPI response - not an ArrayObject"); exit(0); } \okapi\OkapiErrorHandler::disable(); if ($okapi_resp->count() == 0) { // no caches found exit(0); } // get the first object from the list $arrayCopy = $okapi_resp->getArrayCopy(); $geoCache = new \lib\Objects\GeoCache\GeoCache(array('okapiRow' => array_pop($arrayCopy))); //generate the results if ($this->screenWidth < 400) { tpl_set_tplname('map/map_cacheinfo_small'); } else { tpl_set_tplname('map/map_cacheinfo'); } tpl_set_var('cache_lat', $geoCache->getCoordinates()->getLatitude()); tpl_set_var('cache_lon', $geoCache->getCoordinates()->getLongitude()); tpl_set_var('cache_name', $geoCache->getCacheName()); tpl_set_var('cache_icon', $geoCache->getCacheIcon()); $is_event = $geoCache->getCacheType() == $geoCache::TYPE_EVENT ? '1' : '0'; // be aware: booleans not working here tpl_set_var('is_event', $is_event, false); $is_scored = $geoCache->getRatingId() != 0 && $geoCache->getRatingVotes() > 2 ? '1' : '0'; tpl_set_var('is_scored', $is_scored, false); tpl_set_var('rating_desc', tr($geoCache->getRatingDesc())); $is_recommended = $geoCache->getRecommendations() > 0 ? '1' : '0'; tpl_set_var('is_recommended', $is_recommended, false); tpl_set_var('cache_recommendations', $geoCache->getRecommendations(), false); tpl_set_var('cache_code', $geoCache->getWaypointId()); tpl_set_var('cache_founds', $geoCache->getFounds()); tpl_set_var('cache_not_founds', $geoCache->getNotFounds()); tpl_set_var('cache_rating_votes', $geoCache->getRatingVotes()); tpl_set_var('cache_willattends', $geoCache->getWillattends()); tpl_set_var('cache_url', $geoCache->getCacheUrl()); tpl_set_var('user_name', $geoCache->getOwner()->getUserName()); tpl_set_var('user_profile', $geoCache->getOwner()->getProfileUrl()); tpl_set_var('cache_size_desc', tr($geoCache->getSizeDesc())); $is_powertrail_part = $geoCache->isPowerTrailPart() ? '1' : '0'; tpl_set_var('is_powertrail_part', $is_powertrail_part, false); if ($geoCache->isPowerTrailPart()) { tpl_set_var('pt_name', $geoCache->getPowerTrail()->getName()); tpl_set_var('pt_image', $geoCache->getPowerTrail()->getImage()); tpl_set_var('pt_icon', $geoCache->getPowerTrail()->getFootIcon()); tpl_set_var('pt_url', $geoCache->getPowerTrail()->getPowerTrailUrl()); } $is_titled = $geoCache->isTitled() ? 'true' : 'false'; tpl_set_var('is_titled', $is_titled, false); //tpl_set_var('is_titled', $geoCache->isTitled(), false); // make the template and send it out tpl_BuildTemplate(false, false, true); }
$queryid = $database->lastInsertId(); } $links_content = ''; $forlimit = intval($caches_count / $okapi_max_caches) + 1; for ($i = 1; $i <= $forlimit; $i++) { $zipname = 'ocpl' . $queryid . '.zip?startat=0&count=max&zip=1&zippart=' . $i . (isset($_REQUEST['okapidebug']) ? '&okapidebug' : ''); $links_content .= '<li><a class="links" href="' . $zipname . '" title="Garmin ZIP file (part ' . $i . ')">ocpl' . $queryid . '-' . $i . '.zip</a></li>'; } tpl_set_var('zip_links', $links_content); tpl_BuildTemplate(); } else { require_once $rootpath . 'okapi/facade.php'; try { $waypoints = implode("|", $waypoints_tab); // TODO: why the langpref is fixed to pl? shouldn't it depend on current user/session language? $okapi_response = \okapi\Facade::service_call('services/caches/formatters/garmin', $usr['userid'], array('cache_codes' => $waypoints, 'langpref' => 'pl', 'location_source' => 'alt_wpt:user-coords', 'location_change_prefix' => '(F)')); // Modifying OKAPI's default HTTP Response headers. $okapi_response->content_type = 'application/zip'; $okapi_response->content_disposition = 'attachment; filename=myroute.zip'; // This outputs headers and the ZIP file. $okapi_response->display(); } catch (\okapi\BadRequest $e) { # In case of bad requests, simply output OKAPI's error response. # In case of other, internal errors, don't catch the error. This # will cause OKAPI's default error hangler to kick in (so the admins # will get informed). header('Content-Type: text/plain'); echo $e; } } exit;