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)
 {
     //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);
 }
Beispiel #2
0
 }
 if ($npac == "0") {
     tpl_set_var('hidenpa_start', '<!--');
     tpl_set_var('hidenpa_end', '-->');
     tpl_set_var('npa_content', '');
 } else {
     tpl_set_var('hidenpa_start', '');
     tpl_set_var('hidenpa_end', '');
     tpl_set_var('npa_content', $npa_content);
 }
 $icons = $geocache->dictionary->getCacheTypeIcons();
 //cache data
 list($iconname) = getCacheIcon($usr['userid'], $geocache->getCacheId(), $geocache->getStatus(), $geocache->getOwner()->getUserId(), $icons[$geocache->getCacheType()]['icon']);
 list($lat_dir, $lat_h, $lat_min) = help_latToArray($geocache->getCoordinates()->getLatitude());
 list($lon_dir, $lon_h, $lon_min) = help_lonToArray($geocache->getCoordinates()->getLongitude());
 $tpl_subtitle = htmlspecialchars($geocache->getCacheName(), ENT_COMPAT, 'UTF-8') . ' - ';
 $map_msg = mb_ereg_replace("{target}", urlencode("viewcache.php?cacheid=" . $cache_id), tr('map_msg'));
 tpl_set_var('googlemap_key', $googlemap_key);
 tpl_set_var('map_msg', $map_msg);
 tpl_set_var('typeLetter', typeToLetter($geocache->getCacheType()));
 tpl_set_var('cacheid_urlencode', htmlspecialchars(urlencode($cache_id), ENT_COMPAT, 'UTF-8'));
 tpl_set_var('cachename', htmlspecialchars($geocache->getCacheName(), ENT_COMPAT, 'UTF-8'));
 if ($geocache->isTitled()) {
     $ntitled_cache = $titled_cache_period_prefix . '_titled_cache';
     tpl_set_var('icon_titled', '<img src="tpl/stdstyle/images/free_icons/award_star_gold_1.png" class="icon16" alt="' . tr($ntitled_cache) . '" title="' . tr($ntitled_cache) . '"/>');
 } else {
     tpl_set_var('icon_titled', '');
 }
 // cache type Mobile add calculate distance
 if ($geocache->getCacheType() == GeoCache::TYPE_MOVING) {
     tpl_set_var('moved_icon', $moved_icon);