diff --git a/application/languages/en.ini b/application/languages/en.ini index b81a5aa..b959a5a 100644 --- a/application/languages/en.ini +++ b/application/languages/en.ini @@ -12,6 +12,8 @@ START_TXT = "Welcome to fiktivkod.org. ...." ABOUT_TXT = "Fiktiv (fiktivkod.org) is ... that started ..." BLOG_TXT = "We at fiktivkod use this blog to tell our stories about happy times and maybe not so happy experience ... " - -ERROR_404 = "Oops, something went wrong" +ERROR_404 = "The page could not be found" +ERROR_404_TXT = "The page you are trying to visit does not exist." +ERROR_500 = "Oops, something went wrong" +ERROR_500_TXT = "We will look into it as soon as we can." ERROR_TXT_WHAT = "The following went wrong" \ No newline at end of file diff --git a/application/languages/se.ini b/application/languages/se.ini index ffc2d64..9c85ff9 100644 --- a/application/languages/se.ini +++ b/application/languages/se.ini @@ -12,7 +12,10 @@ START_TXT = "Välkommen till fiktivkod.org. ...." ABOUT_TXT = "Fiktiv (fiktivkod.org) är ... som startade ..." BLOG_TXT = "Här på bloggen delar vi med oss av våra erfarenheter och andra dumheter ... " -ERROR_404 = "Oops, något blev fel" +ERROR_404 = "Sidan kunde inte visas" +ERROR_404_TXT = "Sidan du försöker besöka existerar inte." +ERROR_500 = "Oops, något blev fel" +ERROR_500_TXT = "Vi kollar på detta så fort vi kan." ERROR_TXT_WHAT = "Följande har gått fel" class = klass diff --git a/application/modules/default/controllers/ErrorController.php b/application/modules/default/controllers/ErrorController.php index c66fbf1..33f26f3 100644 --- a/application/modules/default/controllers/ErrorController.php +++ b/application/modules/default/controllers/ErrorController.php @@ -4,11 +4,31 @@ class ErrorController extends Zend_Controller_Action { public function errorAction() { - $this->view->args = $this->_request->getParams(); + $error = $this->_getParam('error_handler'); - $this->view->error = $this->_request->getParam('error_handler'); + // display debug information if we are in a developer environment. + if (ini_get('display_errors')) { + $this->_helper->layout->setLayout('clean'); + $this->view->error = $error; + $this->render('debug'); + return; + } - + switch($error->type) { + // 404 - Page not found + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION : + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER : + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE : + $this->_forward('page-not-found'); + break; + // 500 - Application error + default : + $this->getResponse()->setHttpResponseCode(500); + } + } + public function pageNotFoundAction() + { + $this->getResponse()->setHttpResponseCode(404); } } \ No newline at end of file diff --git a/application/modules/default/views/layout/clean.phtml b/application/modules/default/views/layout/clean.phtml new file mode 100644 index 0000000..66c9b10 --- /dev/null +++ b/application/modules/default/views/layout/clean.phtml @@ -0,0 +1,13 @@ + + + + headTitle() . "\n"?> + headMeta() . "\n"?> + + + + layout()->content?> + + + \ No newline at end of file diff --git a/application/modules/default/views/scripts/error/debug.phtml b/application/modules/default/views/scripts/error/debug.phtml new file mode 100644 index 0000000..2abb593 --- /dev/null +++ b/application/modules/default/views/scripts/error/debug.phtml @@ -0,0 +1,8 @@ +

An error occured

+ +Message: error->exception->getMessage()?> + +

Stack trace:

+
+error->exception->getTraceAsString()?>
+
\ No newline at end of file diff --git a/application/modules/default/views/scripts/error/error.phtml b/application/modules/default/views/scripts/error/error.phtml index 34a0bd1..68b3648 100644 --- a/application/modules/default/views/scripts/error/error.phtml +++ b/application/modules/default/views/scripts/error/error.phtml @@ -1,20 +1,2 @@ -

translate('ERROR_404') ?>

- -

- translate('ERROR_TXT_WHAT') ?>: error->exception->getMessage() ?> -

- - - - - - - -error->exception->getTrace() as $call): ?> - - - - - - -
translate('u:class') ?>translate('u:function') ?>translate('u:line') ?>
\ No newline at end of file +

translate('ERROR_500') ?>

+

translate('ERROR_500_TXT') ?>

\ No newline at end of file diff --git a/application/modules/default/views/scripts/error/page-not-found.phtml b/application/modules/default/views/scripts/error/page-not-found.phtml new file mode 100644 index 0000000..c1b176a --- /dev/null +++ b/application/modules/default/views/scripts/error/page-not-found.phtml @@ -0,0 +1,3 @@ + +

translate('ERROR_404') ?>

+

translate('ERROR_404_TXT') ?>

\ No newline at end of file