public function __construct() { $this->splitUrl(); if (!$this->url_controller) { require APP . 'controller/DefaultController.php'; $page = new DefaultController(); $page->index(); } elseif (file_exists(APP . 'controller/' . ucfirst($this->url_controller) . 'Controller.php')) { $this->url_controller = ucfirst($this->url_controller) . 'Controller'; require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { $this->url_controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
<?php class DefaultController extends adapterUi { function index() { $tplDir = $this->cmsdata['head']['tplDir']; header("Content-type:text/html;charset=UTF-8"); if (!empty($this->cmsdata['head']['forceCompile'])) { $smarty->force_compile = true; } $this->smarty->display($tplDir); } } $controller = new DefaultController(); $controller->index(); /*$sysData['templateRoot'] = $smarty->getTemplateDir(0)."/"; if(isset($_GET['debug'])){ if($_GET['debug'] == 'on'){ $smarty->debugging = true; } }*/ /*if( !empty( $rootData['head']['forceCompile'] ) ){ $smarty->force_compile = true; } $smarty->assign('root',$rootData); $smarty->assign('sysInfo',$sysData); $smarty->display($tplDir);*/
<?php function check_logged_in() { BaseController::check_logged_in(); } function check_if_admin() { BaseController::check_if_admin(); } $routes->get('/', function () { DefaultController::index(); }); $routes->get('/info', function () { DefaultController::info(); }); $routes->post('/ostoskori/:id/lisaa', function ($id) { CartController::add($id); }); $routes->post('/ostoskori/:id/poista', function ($id) { CartController::delete($id); }); $routes->post('/ostoskori/tyhjenna', function () { CartController::deleteAll(); }); $routes->get('/kassa', function () { OrdersController::add_form(); }); $routes->post('/kassa', function () { OrdersController::add(); });