Beispiel #1
0
 /**
  * Call OKAPI, parse response and display the results
  * @param array $params - params of the cache to search and display
  */
 private function htmlFormat(array $params)
 {
     $ocConfig = \lib\Objects\OcConfig\OcConfig::instance();
     //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('start_date', $geoCache->getDatePlaced()->format($ocConfig->getDateFormat()));
     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);
 }
Beispiel #2
0
     } else {
         $time_hours = floor($geocache->getSearchTime());
         $time_min = ($geocache->getSearchTime() - $time_hours) * 60;
         $time_min = sprintf('%02d', round($time_min, 1));
         tpl_set_var('search_time', $time_hours . ':' . $time_min . ' h');
     }
     if ($geocache->getWayLenght() == null || $geocache->getWayLenght() == 0) {
         tpl_set_var('way_length', tr('not_available'));
     } else {
         tpl_set_var('way_length', sprintf('%01.2f km', $geocache->getWayLenght()));
     }
 }
 tpl_set_var('country', htmlspecialchars($geocacheLocation['adm1']), ENT_COMPAT, 'UTF-8');
 //        tpl_set_var('cache_log_pw', (($cache_record['logpw'] == NULL) || ($cache_record['logpw'] == '')) ? '' : $cache_log_pw);
 tpl_set_var('nocrypt', $no_crypt);
 $hidden_date = $geocache->getDatePlaced()->format($applicationContainer->getOcConfig()->getDateFormat());
 tpl_set_var('hidden_date', $hidden_date);
 $listed_on = array();
 if ($usr !== false && $usr['userFounds'] >= $config['otherSites_minfinds']) {
     $geocacheOtherWaypoints = $geocache->getOtherWaypointIds();
     if ($geocacheOtherWaypoints['ge'] != '' && $config['otherSites_gpsgames_org'] == 1) {
         $listed_on[] = '<a href="http://geocaching.gpsgames.org/cgi-bin/ge.pl?wp=' . $geocacheOtherWaypoints['ge'] . '" target="_blank">GPSgames.org (' . $geocacheOtherWaypoints['ge'] . ')</a>';
     }
     if ($geocacheOtherWaypoints['tc'] != '' && $config['otherSites_terracaching_com'] == 1) {
         $listed_on[] = '<a href="http://play.terracaching.com/Cache/' . $geocacheOtherWaypoints['tc'] . '" target="_blank">Terracaching.com (' . $geocacheOtherWaypoints['tc'] . ')</a>';
     }
     if ($geocacheOtherWaypoints['nc'] != '' && $config['otherSites_navicache_com'] == 1) {
         $wpnc = hexdec(mb_substr($geocacheOtherWaypoints['nc'], 1));
         $listed_on[] = '<a href="http://www.navicache.com/cgi-bin/db/displaycache2.pl?CacheID=' . $wpnc . '" target="_blank">Navicache.com (' . $wpnc . ')</a>';
     }
     if ($geocacheOtherWaypoints['gc'] != '' && $config['otherSites_geocaching_com'] == 1) {