public function __construct($params) { View::$root = dirname(__FILE__) . "/../tpl/"; $this->params = $params; $this->root = dirname(__FILE__) . "/../"; $this->siteURL = "http://" . $_SERVER["HTTP_HOST"]; $this->initMysql(); if ($this->isLogin()) { $this->run(); } else { $this->renderLayout(view("login.html", array("registerMessage" => $this->registerMessage))); } }
public function __construct($path, $data, $root = "") { if ($root != "") { View::$root = $root; } $cache = View::get($path); if (!$cache) { $path = View::$root . $path; $fh = @fopen($path, "r"); if (!$fh) { throw new ErrorException("Missing file '" . $path . "'."); } $this->tplFileContent = fread($fh, filesize($path)); fclose($fh); View::add($path, $this->tplFileContent); } else { $this->tplFileContent = $cache; } $this->vars = $data; }
<?php require dirname(__FILE__) . "/modules/Autoloader/Autoloader.php"; $F->loadModule("Router", "View", "TestWidget"); $F->loadResource("resources/*", "utils/ErrorHandler/index.php"); /******************************************************/ View::$root = dirname(__FILE__); View::$forEachView = array("globalVar" => "global variable"); class CheckSession { public function __construct($params) { var_dump("Controller CheckSession run"); } } class ControllerHome { public function __construct($params) { die(view("/tpl/home.html", array("titleOfThePage" => "Fabrico test", "title" => "Fabrico", "content" => "It works!"))); } } class ControllerUsers { public function __construct($params) { $userId = isset($params["id"]) ? $params["id"] : "none (please add something after /users/)"; die(view("/tpl/users.html", array("titleOfThePage" => "Fabrico test", "title" => "Users", "content" => "The user id is: " . $userId))); } } // test instance of custom resource
$app_root = $root . '/app'; // Include all base classes explicitly, autoload the rest include $lib_root . '/application.php'; include $lib_root . '/db.php'; include $lib_root . '/db_result.php'; include $lib_root . '/input.php'; include $lib_root . '/session.php'; include $lib_root . '/validation.php'; include $lib_root . '/model.php'; include $lib_root . '/controller.php'; include $lib_root . '/view.php'; // Initialize the application Application::initialize(); Model::$root = $app_root . '/models'; Controller::$root = $app_root . '/controllers'; View::$root = $app_root . '/views'; // Database connectivity DB::$adapter = "mysql"; DB::$host = ""; DB::$user = ""; DB::$password = ""; DB::$database = ""; DB::$adapter_root = $lib_root . '/db'; // Load the database adapter, will die() if not found DB::load_adapter(); function __autoload($class) { if (!Application::load($class)) { die("Could not locate class: {$class}"); } }