]> dev.renevier.net Git - syj.git/blob - application/controllers/GeomController.php
redirection after path creation is decided by server (php), not guessed by client...
[syj.git] / application / controllers / GeomController.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class GeomController extends Zend_Controller_Action
6 {
7
8     public function indexAction() {
9         $request = $this->getRequest();
10         $response = $this->getResponse();
11
12         $idx = $request->idx;
13         $pathMapper = new Syj_Model_PathMapper();
14         $path = new Syj_Model_Path();
15
16         $api = $this->_helper->SyjApi;
17
18         if (!$pathMapper->find($idx, $path)) {
19             if ($pathMapper->hasexisted($idx)) {
20                 $api->setCode(410);
21             } else {
22                 $api->setCode(404);
23             }
24             return;
25         }
26
27         $data = array('geom' => (string)$path->geom,
28                   'title' => (string)$path->displayTitle);
29         if ($path->creator) {
30             $data['creator'] = (string)$path->creator->pseudo;
31         }
32
33         $api->setCheckIfNoneMatch(true)->setBodyJson($data);
34     }
35 }