/** * AJAX Hook * * @return array() Keys: success | value | error */ public function dispatchAjax() { // Setup return array $arrReturn = array("success" => true, "value" => "", "error" => "", "lang" => $GLOBALS['TL_LANGUAGE']); // Try to load the geolocation container from session or cookie if (($booLoadBySession = $this->loadCookie()) == false) { if (($booLoadByCookie = $this->loadSession()) == false) { $this->objUserGeolocation = new GeolocationContainer(); $this->objUserGeolocation->setTrackRunning(GeolocationContainer::LOCATION_W3C); } } try { // Chose function switch ($this->Input->post("action")) { /** * Set geolocation for user. * Try to get the lat/lon from lookup service. * Write all information into session. */ case "GeoSetLocation": $arrReturn = $this->ajaxSetLocation($arrReturn); break; /** * Set error msg from js script. */ /** * Set error msg from js script. */ case "GeoSetError": $arrReturn = $this->ajaxSetError($arrReturn); break; /** * Change location by user settings */ /** * Change location by user settings */ case "GeoChangeLocation": $arrReturn = $this->ajaxChangeLocation($arrReturn); break; default: return false; } // Save in Session $this->saveSession(); $this->saveCookie(); } catch (Exception $exc) { $arrReturn["success"] = false; $arrReturn["error"] = "Unknown error."; $this->log($exc->getMessage(), __CLASS__ . " | " . __FUNCTION__, TL_ERROR); } // Return answer return $arrReturn; }