]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/ErrorController.php
routes profile
[syj.git] / application / controllers / ErrorController.php
index db283ab86d48844a3983f55316c0c0a0a0ccd695..0a6c46868f402bef9e45771c31a9781b4942dbc2 100644 (file)
@@ -1,23 +1,16 @@
 <?php
-/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+/*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
     and is published under the AGPL license. */
 
 class ErrorController extends Zend_Controller_Action
 {
     protected function httpError($code) {
         $this->getResponse()->setHttpResponseCode($code);
-        $this->view->message = Zend_Http_Response::responseCodeAsText($code);
     }
 
     public function init() {
-        $this->view->jslocales = null;
-        $this->view->headScript()->exchangeArray(array());
-        $this->view->headLink()->exchangeArray(array());
-        $this->view->headTitle()->exchangeArray(array());
-        $this->view->headStyle()->exchangeArray(array());
-
-        $this->view->headLink()->appendStylesheet('css/generic.css');
-        $this->view->headLink()->appendStylesheet('css/error.css');
+        $this->_helper->SyjReset->resetPlaceHolders();
+        $this->_helper->SyjMedias->addStyleSheets('error');
     }
 
     public function errorAction() {
@@ -35,6 +28,8 @@ class ErrorController extends Zend_Controller_Action
                     $error_code = 400; // Bad Request
                 } else if ($error->exception instanceof Syj_Exception_Forbidden) {
                     $error_code = 403; // Forbidden
+                } else if ($error->exception instanceof Syj_Exception_NotImplemented) {
+                    $error_code = 501; // Not Implemented
                 } else if ($error->exception instanceof Syj_Exception_NotFound) {
                     $error_code = $error->exception->getCode();
                 }
@@ -47,8 +42,13 @@ class ErrorController extends Zend_Controller_Action
             $log->crit($this->view->message, $error->exception);
         }
 
-        if ($error_code != 404 and $error_code != 410 and $error->request->isXmlHttpRequest()) {
+        if ($error_code == 400 and $error->request->isXmlHttpRequest()) {
             return $this->_helper->json(array('message' => $error->exception->getMessage()));
+        } else if ($error->exception instanceof Syj_Exception_InvalidGeomUpload) {
+            // invalid file upload: we will redirect to main page
+            $this->_helper->SyjReset->resetPlaceHolders();
+            $this->_request->setControllerName('idx')->setActionName('error')->setDispatched(false);
+            return;
         }
 
         // conditionally display exceptions