diff --git a/classes/Xodx/Application.php b/classes/Xodx/Application.php index ce16121..07b4891 100644 --- a/classes/Xodx/Application.php +++ b/classes/Xodx/Application.php @@ -10,51 +10,56 @@ class Xodx_Application extends Saft_Application public function run() { parent::run(); - // TODO: parse request uri to determine correct controller + try { + $bootstrap = $this->getBootstrap(); - $bootstrap = $this->getBootstrap(); + $appController = $this->getController('Xodx_ApplicationController'); + $appController->authenticate(); - $appController = $this->getController('Xodx_ApplicationController'); - $appController->authenticate(); + /** + * Prepare Template + */ + $this->_layout->setLayout('templates/layout.phtml'); + $this->_layout->addMenu('templates/menu.phtml'); - /** - * Prepare Template - */ - $this->_layout->setLayout('templates/layout.phtml'); - $this->_layout->addMenu('templates/menu.phtml'); + $request = $bootstrap->getResource('request'); - $request = $bootstrap->getResource('request'); + if ($request->hasValue('c')) { + $requestController = ucfirst(strtolower($request->getValue('c'))); // 'get' + } else { + $requestController = ucfirst(strtolower('index')); + } - if ($request->hasValue('c')) { - $requestController = ucfirst(strtolower($request->getValue('c'))); // 'get' - } else { - $requestController = ucfirst(strtolower('index')); - } - - if ($request->hasValue('a')) { - $requestAction = strtolower($request->getValue('a')); + if ($request->hasValue('a')) { + $requestAction = strtolower($request->getValue('a')); - } else { - $requestAction = 'index'; - } + } else { + $requestAction = 'index'; + } - $controllerName = $this->_appNamespace . $requestController . 'Controller'; + $controllerName = $this->_appNamespace . $requestController . 'Controller'; - $actionName = $requestAction . 'Action'; - $controller = $this->getController($controllerName); - $this->_layout = $controller->$actionName($this->_layout); + $actionName = $requestAction . 'Action'; + $controller = $this->getController($controllerName); + $this->_layout = $controller->$actionName($this->_layout); - $userController = $this->getController('Xodx_UserController'); - $user = $userController->getUser(); + $userController = $this->getController('Xodx_UserController'); + $user = $userController->getUser(); - $this->_layout->username = $user->getName(); - $this->_layout->notifications = $userController->getNotifications($user->getUri()); + $this->_layout->username = $user->getName(); + $this->_layout->notifications = $userController->getNotifications($user->getUri()); - $config = $bootstrap->getResource('config'); - if (isset($config['debug']) && $config['debug'] == false) { - $this->_layout->disableDebug(); + $config = $bootstrap->getResource('config'); + if (isset($config['debug']) && $config['debug'] == false) { + $this->_layout->disableDebug(); + } + } catch (Exception $e) { + $this->_layout->setLayout('templates/errorlayout.phtml'); + $this->_layout->errorType = 'Application Error'; + $this->_layout->exception = $e; + $this->_layout->back = $this->getBaseUri(); + $this->_layout->addContent('templates/error.phtml'); } - $this->_layout->render(); } } diff --git a/templates/error.phtml b/templates/error.phtml index 9165c7e..5270197 100644 --- a/templates/error.phtml +++ b/templates/error.phtml @@ -1,4 +1,21 @@ -

Error

-
+errorType)) : ?> +

errorType ?>

+ +

Error

+ +
+ exception, 'Exception')): ?> + exception->getMessage() ?> in exception->getFile()) . '@l.' . $this->exception->getLine() ?> +
    + exception->getTrace() as $item): ?> +
  1. + +
+ exception ?> +
+

If you think reporting this error can help improving this software, please create a new issue on our GitHub page.

+back)) : ?> + Back to Start + diff --git a/templates/errorlayout.phtml b/templates/errorlayout.phtml new file mode 100644 index 0000000..cf8df43 --- /dev/null +++ b/templates/errorlayout.phtml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + +
+ _contentFiles as $contentFile) { + include $contentFile; + } + ?> +
+ + _debug && !empty($this->_debugLog)) : ?> + +
+

Debuglog:

+
+_debugLog ?>
+        
+
+ + + +