Esempio n. 1
0
 public function getPath()
 {
     $idx = $this->getRequest()->getUserParam('idx');
     $path = new Syj_Model_Path();
     $pathMapper = new Syj_Model_PathMapper();
     if (!$pathMapper->find($idx, $path)) {
         if ($pathMapper->hasexisted($idx)) {
             throw new Syj_Exception_NotFound('Gone', 410);
         } else {
             throw new Syj_Exception_NotFound('Not Found', 404);
         }
     }
     $user = $this->_helper->SyjUserManager->current();
     if (!$path->isCreator($user)) {
         throw new Syj_Exception_Forbidden();
     }
     return $path;
 }
Esempio n. 2
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     $idx = $request->idx;
     $pathMapper = new Syj_Model_PathMapper();
     $path = new Syj_Model_Path();
     $api = $this->_helper->SyjApi;
     $ext = "";
     $parts = explode('.', $idx);
     if (count($parts) >= 2) {
         $ext = end($parts);
         if (in_array($ext, array('kml', 'gpx', 'json'))) {
             $idx = implode('.', explode('.', $idx, -1));
         } else {
             $ext = "";
         }
     }
     if (!$pathMapper->find($idx, $path)) {
         if (!$pathMapper->findByTitle($idx, $path)) {
             if ($pathMapper->hasexisted($idx)) {
                 $api->setCode(410);
             } else {
                 $api->setCode(404);
             }
             return;
         }
     }
     switch ($ext) {
         case 'kml':
             $this->kml($path);
             break;
         case 'gpx':
             $this->gpx($path);
             break;
         case 'json':
         default:
             $this->json($path);
             return;
             break;
     }
 }
Esempio n. 3
0
 public function indexAction()
 {
     $this->_initForms();
     $url = $this->getRequest()->getUserParam('url');
     if (isset($url)) {
         $this->view->geomform->setAction("");
         $pathMapper = new Syj_Model_PathMapper();
         $path = new Syj_Model_Path();
         if (!$pathMapper->findByUrl($url, $path)) {
             if (is_numeric($url) and $pathMapper->hasexisted($url)) {
                 $this->view->message = $this->view->translate("route has been deleted");
                 throw new Syj_Exception_NotFound('Gone', 410);
             } else {
                 $this->view->message = $this->view->translate("route does not exist");
                 throw new Syj_Exception_NotFound('Not Found', 404);
             }
         }
         if ($this->getRequest()->getQuery('format') == 'raw') {
             $this->rawmode($path);
             return;
         }
         $title = $path->displayTitle;
         $this->view->path = $path;
         $jsgeom = new phptojs\JsObject('gInitialGeom', array('data' => (string) $path->geom));
         $this->view->headScript()->prependScript((string) $jsgeom);
         $this->view->loginform->login_geom_id->setValue((string) $path->id);
         $this->view->geomform->geom_title->setValue($path->title);
         $this->view->profileActive = $this->_hasAltiProfile($path);
     } else {
         $this->_setInitialPos();
         $title = "Show your journey";
     }
     $this->_jsLoggedInfo(isset($url) ? $path : null);
     $this->_jsLocaleStrings();
     if (isset($url) and $path->creator) {
         $this->view->jslocales['geomAttribution'] = $this->view->translate('route by <strong>%s</strong>', (string) $path->creator->pseudo);
     }
     $this->view->headTitle($title);
     $this->view->headMeta()->appendName('description', $this->view->translate('website to share routes'));
     $this->view->loggedUser = $this->_helper->SyjUserManager->current();
 }
Esempio n. 4
0
 public function indexAction()
 {
     $url = $this->getRequest()->getUserParam('url');
     if (!isset($url)) {
         throw new Syj_Exception_NotFound('Not Found', 404);
     }
     $pathMapper = new Syj_Model_PathMapper();
     $path = new Syj_Model_Path();
     if (!$pathMapper->findByUrl($url, $path)) {
         if (is_numeric($url) and $pathMapper->hasexisted($url)) {
             throw new Syj_Exception_NotFound('Gone', 410);
         } else {
             throw new Syj_Exception_NotFound('Not Found', 404);
         }
     }
     $size = $this->getRequest()->getQuery('size', 'big');
     if ($size == 'small') {
         $width = 300;
         $height = 225;
     } else {
         $width = 800;
         $height = 600;
         $size = 'big';
     }
     $file = $path->getProfileCache($size);
     if (file_exists($file)) {
         if (filesize($file) == 0) {
             throw new Syj_Exception_NotImplemented("could not compute altitude profile");
         }
         $this->sendFile($file);
         return;
     }
     try {
         $service = $this->_helper->SyjAltiService->service();
         /* we accept 2% of invalid values in the profile */
         $profile = $path->getAltiProfile($service, 2 / 100);
     } catch (Syj_Exception_NotImplemented $e) {
         @touch($file);
         throw $e;
     }
     $canvas = $this->drawProfile($profile, $width, $height);
     $canvas->draw($file);
     $this->sendFile($file);
 }