Init ci
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class Controller {
|
||||
|
||||
public function loadPage() {
|
||||
$app = Config::get('app:App:default_app');
|
||||
|
||||
require_once 'app/'. $app .'/controllers/Index.class.php';
|
||||
$c = new IndexController();
|
||||
$data = $c->_index();
|
||||
|
||||
$v = new View();
|
||||
$v->setTemplate('app/'. $app .'/templates/main.php');
|
||||
$v->setView('app/'. $app .'/views/Index_index.php');
|
||||
$v->setData($data);
|
||||
|
||||
$html = $v->render();
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class Model {
|
||||
|
||||
protected $db;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = Db::getInstance();
|
||||
}
|
||||
|
||||
public static function factory($package, $model) {
|
||||
require_once ROOT_DIR .'/app/'. $package .'/models/'. $model .'.class.php';
|
||||
$class_name = ucfirst($package) .'_'. $model .'Model';
|
||||
return new $class_name();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class View {
|
||||
|
||||
private $_template;
|
||||
private $_view;
|
||||
private $_data;
|
||||
|
||||
private $_block;
|
||||
|
||||
public function setTemplate($path) {
|
||||
$this->_template = $path;
|
||||
}
|
||||
|
||||
public function setView($path) {
|
||||
$this->_view = $path;
|
||||
}
|
||||
|
||||
public function setData($data) {
|
||||
$this->_data = $data;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$this->_block = $this->_sandbox($this->_view);
|
||||
return $this->_sandbox($this->_template);
|
||||
}
|
||||
|
||||
private function _sandbox($path) {
|
||||
ob_clean();
|
||||
include $path;
|
||||
$html = ob_get_contents();
|
||||
ob_clean();
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user