public static function getInstance() { if (NULL === self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Handle a POST request for this map save ressource * @param Request request * @return Response */ function post($request) { $response = new Response($request); if (isset($_POST['map'])) { // Remove those slashes if (get_magic_quotes_gpc()) { $map = stripslashes($_POST['map']); } else { $map = $_POST['map']; } $map_obj = json_decode($map); $geocacheManager = GeocacheManager::getInstance(); $geocaches = $geocacheManager->parseGeocaches($map_obj->{"geocaches"}); foreach ($geocaches as $geocache) { $geocache->save(); } $ownWaypoints = $geocacheManager->parseOwnWaypoints($map_obj->{"costumMarkers"}); foreach ($ownWaypoints as $ownWaypoint) { $ownWaypoint->save(); } $response->code = Response::OK; $response->addHeader('Content-type', 'text/plain'); $response->body = print_r($map, true); } else { $response->code = Response::BADREQUEST; } return $response; }
function post($request) { $response = new Response($request); if (isset($_POST['tour'])) { // Remove those slashes if (get_magic_quotes_gpc()) { $tour = stripslashes($_POST['tour']); } else { $tour = $_POST['tour']; } $tour_obj = json_decode($tour); $entitymanager = GeocacheManager::getInstance(); //~ print_r($tour_obj); $data = array(); $data['name'] = $tour_obj->name; $data['webcode'] = isset($tour_obj->webcode) ? $tour_obj->webcode : $this->get_new_webcode(); $data['geocaches'] = $entitymanager->parseGeocaches($tour_obj->geocaches); $data['ownWaypoints'] = $entitymanager->parseOwnWaypoints($tour_obj->costumMarkers); $tour = new Tour($data); $tour->save(); $response->code = Response::OK; $response->addHeader('Content-type', 'text/plain'); $response->body = $tour->__toJSON(); } else { $response->code = Response::BADREQUEST; } return $response; }
function __construct($paramaters) { if (isset($paramaters['webcode'])) { $this->webcode = $paramaters['webcode']; } $this->tm = TemplateManager::getInstance(); $this->em = GeocacheManager::getInstance(); }
function __construct($paramaters) { foreach ($paramaters as $key => $value) { $this->{$key} = $value; } $this->tm = TemplateManager::getInstance(); $this->em = GeocacheManager::getInstance(); }
function get($request) { $response = new Response($request); $entitymanager = GeocacheManager::getInstance(); $tour = $entitymanager->fetchTour($this->webcode); $body = $tour->__toJSON(); /* if(!isset($tour)){ // tour nicht in DB enthalten -> Frage bei appengine an. // $jsonurl = "http://192.168.178.10:8888/api/tour/".$this->webcode."/json"; $jsonurl = "http://gctour-spot.appspot.com/api/tour/".$this->webcode."/json"; $json = @file_get_contents($jsonurl,0,null,null); if($json !== false){ // internal server error etc. $json_output = json_decode($json); if(@$json_output->webcode === $this->webcode){ // tour not on server $body = json_encode($json_output); } else { // weder in db von madd.in noch GAE eine tour zum Webcode gefunden! $output = array(); $output['type'] = "error"; $output['message'] = "no tour"; $output['webcode'] = $this->webcode; $body = json_encode((object)$output); } } else { // damn appengine throws some error $output = array(); $output['type'] = "error"; $output['message'] = "no tour"; $output['webcode'] = $this->webcode; $body = json_encode((object)$output); } } else { $body = $tour->__toJSON(); }*/ $response->code = Response::OK; $response->addHeader('Content-type', 'text/html'); $response->addHeader('charset', 'utf-8'); $response->body = $body; /* $body = $tour->__toJSON(); */ //~ $response->code = Response::OK; //~ $response->addHeader('Content-type', 'text/plain'); //~ $response->body = json_encode($tour); return $response; }
function get($request) { // admin Only Utilities::checkAdmin(); $db = Database::obtain(); $response = new Response($request); $this->tm->smarty->assign('title', 'Admin Infos Tours'); $no_tours = $db->query_first("SELECT count(*) AS no FROM " . TABLE_TOURS); $no_tours = $no_tours['no']; $last_page = ceil($no_tours / $this->rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($this->page < 1) { $this->page = 1; } elseif ($this->page > $last_page) { $this->page = $last_page; } $max = 'LIMIT ' . ($this->page - 1) * $this->rows . ',' . $this->rows; $tours = $db->fetch_array("SELECT * FROM `" . TABLE_TOURS . "` " . $max); $this->tm->smarty->assign('lastpage', $last_page); $this->tm->smarty->assign('pagenum', $this->page); $em = GeocacheManager::getInstance(); $tours_obj = array(); foreach ($tours as $tour) { $tours_obj[] = $geocacheManager = $em->fetchTour($tour['webcode']); } $this->tm->smarty->assign('tours', $tours_obj); $body = $this->tm->render('admin_info_tour'); $response->code = Response::OK; $response->addHeader('Content-type', 'text/html'); $response->body = $body; return $response; }