Example #1
0
function displayAllCachesOfPowerTrail(\lib\Objects\PowerTrail\PowerTrail $powerTrail)
{
    isset($_SESSION['user_id']) ? $userId = $_SESSION['user_id'] : ($userId = -9999);
    $powerTrailCachesUserLogsByCache = $powerTrail->getPowerTrailCachesLogsForCurrentUser();
    $cacheTypesIcons = cache::getCacheIconsSet();
    $pTrailCaches = $powerTrail->getGeocaches();
    $cacheRows = '';
    /* @var $geocache \lib\Objects\Geocache\Geocache */
    foreach ($pTrailCaches as $geocache) {
        // avoid crash js on quotas (');
        $cacheName = str_replace("'", ''', $geocache->getCacheName());
        if (isset($powerTrailCachesUserLogsByCache[$geocache->getCacheId()])) {
            $image = $cacheTypesIcons[$geocache->getCacheType()]['iconSet'][1]['iconSmallFound'];
        } elseif ($geocache->getOwner()->getUserId() == $userId) {
            $image = $cacheTypesIcons[$geocache->getCacheType()]['iconSet'][1]['iconSmallOwner'];
        } else {
            $image = $cacheTypesIcons[$geocache->getCacheType()]['iconSet'][1]['iconSmall'];
        }
        $cacheRows .= '[' . $geocache->getCoordinates()->getLatitude() . "," . $geocache->getCoordinates()->getLongitude() . ",'<a href=" . $geocache->getWaypointId() . " target=_new>" . $cacheName . "</a>'," . "'{$image}','" . $cacheName . "',],";
    }
    $cacheRows = rtrim($cacheRows, ",");
    return $cacheRows;
}