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
 $chkuserid = isset($usr['userid']) ? $usr['userid'] : $_SERVER["REMOTE_ADDR"];
 // note the visit of this user
 $query2 = "INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`, `last_visited`) VALUES (:1, :2, 1, NOW()) ON DUPLICATE KEY UPDATE `count`=`count`+1";
 $dbc->multiVariableQuery($query2, $cache_id, $chkuserid);
 if ($chkuserid != $owner_id) {
     // increment the counter for this cache
     $query3 = "INSERT INTO `cache_visits` (`cache_id`, `user_id_ip`, `count`, `last_visited`) VALUES (:1, '0', 1, NOW()) ON DUPLICATE KEY UPDATE `count`=`count`+1, `last_visited`=NOW()";
     $dbc->multiVariableQuery($query3, $cache_id);
 }
 // end visit-counter
 // hide coordinates when user is not logged in
 if ($usr == true || !$hide_coords) {
     $coords = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_latToDegreeStr($geocache->getCoordinates()->getLatitude()), ENT_COMPAT, 'UTF-8')) . '&nbsp;' . mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_lonToDegreeStr($geocache->getCoordinates()->getLongitude()), ENT_COMPAT, 'UTF-8'));
     $coords2 = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_latToDegreeStr($geocache->getCoordinates()->getLatitude(), 0), ENT_COMPAT, 'UTF-8')) . '&nbsp;' . mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_lonToDegreeStr($geocache->getCoordinates()->getLongitude(), 0), ENT_COMPAT, 'UTF-8'));
     $coords3 = mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_latToDegreeStr($geocache->getCoordinates()->getLatitude(), 2), ENT_COMPAT, 'UTF-8')) . '&nbsp;' . mb_ereg_replace(" ", "&nbsp;", htmlspecialchars(help_lonToDegreeStr($geocache->getCoordinates()->getLongitude(), 2), ENT_COMPAT, 'UTF-8'));
     $coords_other = "<a href=\"#\" onclick=\"javascript:window.open('http://www.opencaching.pl/coordinates.php?lat=" . $geocache->getCoordinates()->getLatitude() . "&amp;lon=" . $geocache->getCoordinates()->getLongitude() . "&amp;popup=y&amp;wp=" . htmlspecialchars($geocache->getWaypointId(), ENT_COMPAT, 'UTF-8') . "','Koordinatenumrechnung','width=240,height=334,resizable=yes,scrollbars=1')\">" . tr('coords_other') . "</a>";
 } else {
     $coords = tr('hidden_coords');
     $coords_other = "";
 }
 if ($geocache->getCacheType() == GeoCache::TYPE_EVENT) {
     $cache_stats = '';
 } else {
     if ($geocache->getFounds() + $geocache->getNotFounds() + $geocache->getNotesCount() != 0) {
         $cache_stats = "<a class =\"links2\" href=\"javascript:void(0)\" onmouseover=\"Tip('" . tr('show_statictics_cache') . "', BALLOON, true, ABOVE, false, OFFSETX, -17, PADDING, 8, WIDTH, -240)\" onmouseout=\"UnTip()\" onclick=\"javascript:window.open('cache_stats.php?cacheid=" . $geocache->getCacheId() . "&amp;popup=y','Cache_Statistics','width=500,height=750,resizable=yes,scrollbars=1')\"><img src=\"tpl/stdstyle/images/blue/stat1.png\" alt=\"Statystyka skrzynki\" title=\"Statystyka skrzynki\" /></a>";
     } else {
         $cache_stats = "<a class =\"links2\" href=\"javascript:void(0)\" onmouseover=\"Tip('" . tr('not_stat_cache') . "', BALLOON, true, ABOVE, false, OFFSETX, -17, PADDING, 8, WIDTH, -240)\" onmouseout=\"UnTip()\"><img src=\"tpl/stdstyle/images/blue/stat1.png\" alt=\"\" title=\"\" /></a>";
     }
 }
 if (!isset($map_msg)) {
     $map_msg = '';