diff --git a/Application/Views/errors/view.500.php b/Application/Views/errors/view.500.php new file mode 100644 index 0000000..16d330a --- /dev/null +++ b/Application/Views/errors/view.500.php @@ -0,0 +1,95 @@ +. + * + * @author TechFuze + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + * @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/) + * @license http://opensource.org/licenses/GPL-3.0 GPLv3 License + * + * @link http://fuzeworks.techfuze.net + * @since Version 0.0.1 + * + * @version Version 0.0.1 + */ +?> + + + + Page not found + + + + +
+
+
+ + + +
+
+
+ + + \ No newline at end of file diff --git a/Core/System/class.layout.php b/Core/System/class.layout.php index e9f8eff..7a97544 100644 --- a/Core/System/class.layout.php +++ b/Core/System/class.layout.php @@ -35,6 +35,7 @@ namespace FuzeWorks; use FuzeWorks\TemplateEngine\JSONEngine; use FuzeWorks\TemplateEngine\PHPEngine; use FuzeWorks\TemplateEngine\SmartyEngine; +use FuzeWorks\TemplateEngine\LatteEngine; use FuzeWorks\TemplateEngine\TemplateEngine; /** @@ -479,6 +480,7 @@ class Layout self::registerEngine(new PHPEngine(), 'PHP', array('php')); self::registerEngine(new JsonEngine(), 'JSON', array('json')); self::registerEngine(new SmartyEngine(), 'Smarty', array('tpl')); + self::registerEngine(new LatteEngine(), 'Latte', array('latte')); self::$engines_loaded = true; } } @@ -528,6 +530,7 @@ namespace FuzeWorks\TemplateEngine; use FuzeWorks\LayoutException; use Smarty; +use Latte\Engine as Latte; /** * Interface that all Template Engines must follow. @@ -752,6 +755,74 @@ class SmartyEngine implements TemplateEngine } } +/** + * Wrapper for the Latte Engine from Nette Framework. + * + * @author Abel Hoogeveen + * @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net) + */ +class LatteEngine implements TemplateEngine +{ + + /** + * Instance of the Latte Engine + * + * @var Latte\Engine The Latte Engine to be used + */ + protected $latte; + + /** + * Set the directory of the current template. + * + * @param string $directory Template Directory + */ + public function setDirectory($directory) + { + if (class_exists('\Latte\Engine', true)) + { + // If possible, load Latte\Engine + $this->latte = new Latte; + $this->latte->setTempDirectory(realpath('Application'.DS.'Cache')); + } + else + { + throw new LayoutException("Could not load LatteEngine. Is it installed or Composer not loaded?", 1); + } + } + + /** + * Handle and retrieve a template file. + * + * @param string $file Template File + * @param array $assigned_variables All the variables used in this view + * + * @return string Output of the template + */ + public function get($file, $assigned_variables) + { + $this->latte->render($file, $assigned_variables); + } + + /** + * Retrieve the file extensions that this template engine uses. + * + * @return array All used extensions. eg: array('php') + */ + public function getFileExtensions() + { + return array('latte'); + } + + /** + * Reset the template engine to its default state, so it can be used again clean. + */ + public function reset() + { + // If possible, load Latte\Engine + $this->latte = null; + } +} + /** * Template Engine that exports all assigned variables as JSON. * diff --git a/Core/System/class.logger.php b/Core/System/class.logger.php index 5500040..5bb3c23 100644 --- a/Core/System/class.logger.php +++ b/Core/System/class.logger.php @@ -205,7 +205,6 @@ class Logger { // Log it! Factory::getInstance()->output->set_output(''); self::errorHandler($errno, $errstr, $errfile, $errline); - if (self::$useTracy === false) { self::http_error('500'); @@ -249,6 +248,11 @@ class Logger { $context = $exception->getTraceAsString(); self::logError('Exception thrown: ' . $message . ' | ' . $code, null, $file, $line); + // And return a 500 because this error was fatal + if (self::$useTracy === false) + { + self::http_error('500'); + } } /** @@ -592,6 +596,7 @@ class Logger { // Try and load the view, if impossible, load HTTP code instead. try { + Layout::reset(); Layout::view($view); } catch (LayoutException $exception) { // No error page could be found, just echo the result diff --git a/composer.json b/composer.json index 7605b86..6aa6bc7 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,8 @@ "ext-curl": "*", "ext-json": "*", "smarty/smarty": "~3.1", - "tracy/tracy": "*" + "tracy/tracy": "*", + "latte/latte": "*" }, "require-dev": { "phpunit/phpunit": "5.3.*",