Advertisement
ExeQue

Untitled

Nov 21st, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2.  
  3. class load
  4. {
  5.     protected $View, $route, $layout, $model;
  6.  
  7.     public function __construct()
  8.     {
  9.         $this->route = new route();
  10.  
  11.         echo "<br>" . CURRENT_ROUTE;
  12.         echo $this->route->GetRoute(CURRENT_ROUTE);
  13.  
  14.         if (CURRENT_ROUTE != "" && $this->route->GetRoute(CURRENT_ROUTE)) {
  15.             $this->View = $this->route->GetRoute(CURRENT_ROUTE)["View"];
  16.             $this->layout = isset($this->route->GetRoute(CURRENT_ROUTE)["Layout"]) ? $this->route->GetRoute(CURRENT_ROUTE)["Layout"] : "layout";
  17.             $this->model = isset($this->route->GetRoute(CURRENT_ROUTE)["model"]) ? $this->route->GetRoute(CURRENT_ROUTE)["model"] : "null";
  18.             //echo $this->layout;
  19.         } else if (CURRENT_ROUTE != "" && !$this->route->GetRoute(CURRENT_ROUTE)) {
  20.             header("location: " . WEB_ROOT . " 404/?error=" . CURRENT_ROUTE);
  21.             return false;
  22.         } else {
  23.             header("location: " . WEB_ROOT . " Home");
  24.         }
  25.     }
  26.  
  27.     public function Render()
  28.     {
  29.         $viewbag = $this;
  30.  
  31.         $modelPath = SYSTEM_ROOT . "/models/" . $this->model . ".php";
  32.         if (file_exists($modelPath)) {
  33.             include_once $modelPath;
  34.         } else {
  35.             die("Error model not found!");
  36.         }
  37.  
  38.  
  39.         $layoutPath = SYSTEM_ROOT . "/views/_shared/" . $this->layout . ".php";
  40.         if (file_exists($layoutPath)) {
  41.             include_once $layoutPath;
  42.         } else {
  43.             die("Error layout not found!");
  44.         }
  45.  
  46.     }
  47.  
  48.     public function GetView()
  49.     {
  50.         $path = SYSTEM_ROOT . "/views/" . $this->View . ".php";
  51.         if (file_exists($path)) {
  52.             return $path;
  53.         } else {
  54.             die("Error view not found");
  55.         }
  56.  
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement