예제 #1
0
파일: settings.php 프로젝트: Slini11/okapi
 /**
  * Initialize self::$SETTINGS.
  */
 private static function load_settings()
 {
     try {
         # This is an external code and it MAY generate E_NOTICEs.
         # We have to temporarilly disable our default error handler.
         OkapiErrorHandler::disable();
         require_once $GLOBALS['rootpath'] . "okapi_settings.php";
         $ref = get_okapi_settings();
         OkapiErrorHandler::reenable();
     } catch (Exception $e) {
         throw new Exception("Could not import <rootpath>/okapi_settings.php:\n" . $e->getMessage());
     }
     self::$SETTINGS = self::$DEFAULT_SETTINGS;
     foreach (self::$SETTINGS as $key => $_) {
         if (isset($ref[$key])) {
             self::$SETTINGS[$key] = $ref[$key];
         }
     }
     self::verify(self::$SETTINGS);
 }
예제 #2
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);
 }
예제 #3
0
파일: facade.php 프로젝트: 4Vs/oc-server3
 /**
  * You will probably want to call that with FALSE when using Facade
  * in buggy, legacy OC code. This will disable OKAPI's default behavior
  * of treating NOTICEs as errors.
  */
 public static function disable_error_handling()
 {
     OkapiErrorHandler::disable();
 }
예제 #4
0
    if ($set_id === null) {
        # Read the searchdata file into a temporary table.
        $filepath = \okapi\Settings::get('VAR_DIR') . "/searchdata/" . $searchdata;
        \okapi\Db::execute("\n            create temporary table temp_" . $searchdata . " (\n                cache_id integer primary key\n            ) engine=memory\n        ");
        if (file_exists($filepath)) {
            \okapi\Db::execute("\n                load data local infile '{$filepath}'\n                into table temp_" . $searchdata . "\n                fields terminated by ' '\n                lines terminated by '\\n'\n                (cache_id)\n            ");
        }
        # Tell OKAPI to import the table into its own internal structures.
        # Cache it for two hours.
        $set_info = \okapi\Facade::import_search_set("temp_" . $searchdata, 7200, 7200);
        $set_id = $set_info['set_id'];
        \okapi\Cache::set($cache_key, $set_id, 7200);
    }
    $params['set_and'] = $set_id;
    $params['status'] = "Available|Temporarily unavailable|Archived";
    \okapi\OkapiErrorHandler::disable();
} else {
    # Mode 1 - without "searchdata".
    # h_ignored - convert to OKAPI's "exclude_ignored".
    if ($_GET['h_ignored'] == "true") {
        $params['exclude_ignored'] = "true";
    }
    # h_avail, h_temp_unavail, h_arch ("hide available" etc.) - convert to
    # OKAPI's "status" filter.
    $tmp = array();
    if ($_GET['h_avail'] != "true") {
        $tmp[] = "Available";
    }
    if ($_GET['h_temp_unavail'] != "true") {
        $tmp[] = "Temporarily unavailable";
    }