Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class load
- {
- protected $View, $route, $layout, $model;
- public function __construct()
- {
- $this->route = new route();
- echo "<br>" . CURRENT_ROUTE;
- echo $this->route->GetRoute(CURRENT_ROUTE);
- if (CURRENT_ROUTE != "" && $this->route->GetRoute(CURRENT_ROUTE)) {
- $this->View = $this->route->GetRoute(CURRENT_ROUTE)["View"];
- $this->layout = isset($this->route->GetRoute(CURRENT_ROUTE)["Layout"]) ? $this->route->GetRoute(CURRENT_ROUTE)["Layout"] : "layout";
- $this->model = isset($this->route->GetRoute(CURRENT_ROUTE)["model"]) ? $this->route->GetRoute(CURRENT_ROUTE)["model"] : "null";
- //echo $this->layout;
- } else if (CURRENT_ROUTE != "" && !$this->route->GetRoute(CURRENT_ROUTE)) {
- header("location: " . WEB_ROOT . " 404/?error=" . CURRENT_ROUTE);
- return false;
- } else {
- header("location: " . WEB_ROOT . " Home");
- }
- }
- public function Render()
- {
- $viewbag = $this;
- $modelPath = SYSTEM_ROOT . "/models/" . $this->model . ".php";
- if (file_exists($modelPath)) {
- include_once $modelPath;
- } else {
- die("Error model not found!");
- }
- $layoutPath = SYSTEM_ROOT . "/views/_shared/" . $this->layout . ".php";
- if (file_exists($layoutPath)) {
- include_once $layoutPath;
- } else {
- die("Error layout not found!");
- }
- }
- public function GetView()
- {
- $path = SYSTEM_ROOT . "/views/" . $this->View . ".php";
- if (file_exists($path)) {
- return $path;
- } else {
- die("Error view not found");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement