<?php include_once __DIR__ . "/classes/includes.php"; session_start(); try { // Try creating output from request $controller = new Controller($_REQUEST['url']); $model = new Model($controller); $view = new View($controller, $model); $view->assignVar("controller", $controller); echo $view->createOutput(); } catch (Exception $e) { // Catch possible exceptions $exception = new View(); $exception->setTemplate("error/exception"); $exception->assignVar("e", $e); echo $exception->createOutput(); }
public function getElements($area) { // Get output of elements of requested area // Building output recursive by creating a view instance in this view $content = ""; if (isset($this->elements[$area])) { foreach ($this->elements[$area] as $element) { $view = new View($this->controller, $this->model, $this); if (!isset($element['type'])) { throw new Exception("No template type set!"); } $view->setTemplate('element/' . $element['type']); $view->assignVars($this->vars); $view->assignVar('element', $element); if (is_array($element['parameters'])) { $view->assignParams($element['parameters']); } if (isset($element['_children'])) { $view->setElements($element['_children']); } $content .= $view->createOutput(); } } return $content; }