X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=application%2Fcontrollers%2FPathController.php;h=cdd067b6f4ba2b43722f7256d32d19fd2dd506e3;hb=c1aeb7538786d8c9f3b3337c0b71e21ef89d9c77;hp=b521a2688f9f6f86d8c378e5098d8de57664d761;hpb=1d1b5940442782d78f796d8608e63328e2e8783b;p=syj.git diff --git a/application/controllers/PathController.php b/application/controllers/PathController.php index b521a26..cdd067b 100644 --- a/application/controllers/PathController.php +++ b/application/controllers/PathController.php @@ -16,22 +16,28 @@ class PathController extends Zend_Controller_Action $path->creatorIp = $this->getRequest()->getClientIp(true); $this->save($path, $formData); - $data = array('redirect' => "idx/" . (string)$path->id); - $this->_helper->SyjApi->setCode(201)->setBodyJson($data); + + $redirecturl = "idx/" . (string)$path->id; + if ($this->getRequest()->isXmlHttpRequest()) { + $data = array('redirect' => $redirecturl); + $this->_helper->SyjApi->setCode(201)->setBodyJson($data); + } else { + $this->_helper->SyjApi->setRedirect($redirecturl, 303); + } } public function updateAction() { $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom'); $path = $this->getPath(); $this->save($path, $formData); - $this->_helper->SyjApi->setCode(204); + $this->_helper->SyjApi->setCode(200); // we should use 204, but ie mangles 204 to 1223 } public function deleteAction() { $path = $this->getPath(); $pathMapper = new Syj_Model_PathMapper(); $pathMapper->delete ($path); - $this->_helper->SyjApi->setCode(204); + $this->_helper->SyjApi->setCode(200); // we should use 204, but ie mangles 204 to 1223 } public function getPath() { @@ -55,12 +61,22 @@ class PathController extends Zend_Controller_Action public function save(Syj_Model_Path $path, $formData) { /* setting geom property */ - $decoder = new gisconverter\WKT(); - try { - $geom = $decoder->geomFromText($formData["geom_data"]); - } catch (gisconverter\CustomException $e) { - throw new Syj_Exception_Request(); + $geom = null; + foreach (array("WKT", "KML", "GPX", "geoJSON") as $dectype) { + $classname = 'gisconverter\\' . $dectype; + $decoder = new $classname(); + try { + $geom = $decoder->geomFromText($formData["geom_data"]); + } catch (Exception $e) { + } + if ($geom) { + break; + } } + if (!$geom) { + throw new Syj_Exception_InvalidGeomUpload(); + } + if ($geom::name != "LineString") { throw new Syj_Exception_Request(); }