/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this 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) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if ($this->url_controller) { $controller = ucfirst(strtolower($this->url_controller)); $pathController = APP . "controllers/{$controller}.controller.php"; if (file_exists($pathController)) { // llamamos al archivo controlador require $pathController; $action = strtolower($this->url_action) . 'Action'; if (!empty($this->url_params)) { $this->url_controller = new $controller($this->url_params); } else { $this->url_controller = new $controller(); } // comprobamos si la accion existe if (method_exists($this->url_controller, $action)) { $this->url_controller->{$action}($this->url_params); } else { $params = array_merge(array($this->url_action), $this->url_params); $this->url_controller->index($params); } } else { header('location: ' . URL . 'error'); } } elseif (!$this->url_controller) { require APP . 'controllers/Home.controller.php'; $page = new Home(); $page->index(); } }
public function __construct() { $this->getUrlWithoutModRewrite(); if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { require APP . 'controllers/' . $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)) { // Llama el metodo y le pasa los argumentos call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { //Si no hay parametros llama a el metodo sin argumentos. $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // Si no se define alguna accion defino por defecto la index $this->url_controller->index(); } else { //Si la accion no existe lanzo el error require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('location: ' . URL . '/not_found'); } } } else { header('location: ' . URL . '/not_found'); } }
public function __construct() { $this->splitUrl(); if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { require APP . 'controllers/' . $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'); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->getUrlWithoutModRewrite(); $GLOBALS["beans"] = new stdClass(); $this->openDatabaseConnection(); $this->loadModels(); $this->loadHelpers(); date_default_timezone_set('UTC'); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // If user is not logged in, restrict to the login page only $this->checkLoggedIn(); // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controllers/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { // defined action not existent: show the error page require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->getUrlWithoutModRewrite(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controllers/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controllers/' . $this->url_controller . '.php'; /** * Bad workaround due to list being a reserved keyword. Should probably rename to something other than list in production. **/ if ($this->url_controller == 'list') { $this->url_controller = new days(); } else { $this->url_controller = new $this->url_controller(); } // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { // defined action not existent: show the error page require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } } } else { require APP . 'controllers/error.php'; $page = new Error(); $page->index(); } }
function __construct() { //get url $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if (empty($url[0])) { require 'controllers/home.php'; $controller = new Home(); $controller->index(); return false; } //load controler with file $file = 'controllers/' . $url[0] . '.php'; //check if file exists if (file_exists($file)) { require $file; } else { require 'controllers/error.php'; $controller = new Error(); throw new Exception("The file: {$file} Does not exist!"); return false; } //initialize controler and load model $controller = new $url[0](); $controller->LoadModel($url[0]); //if function was set load function, else load index if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { echo "Napaka: funkcija {$url['1']} ne obstaja."; } return false; } elseif (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { echo "Napaka: funkcija {$url['1']} ne obstaja."; } return false; } else { $controller->index(); } }
function __construct() { $url = isset($_GET["url"]) ? $_GET["url"] : null; $url = rtrim($url, '/'); $url = explode('/', $url); if (empty($url[0])) { // If Empty array then invoke Defualt Home page require 'Controller/Home.php'; $controller = new Home(); echo "I am here"; $controller->loadModel("home"); $controller->index(); return false; } $file = 'Controller/' . $url[0] . '.php'; //Check File Is exist in the Controller if (file_exists($file)) { require $file; } else { $this->error(); } $controller = new $url[0](); // Home Controller $controller->loadModel($url[0]); if (isset($url[2])) { //Check Function parameter is set in the URL $_method_name = 'execute' . $url[1]; if (method_exists($controller, $_method_name)) { $controller->{'execute' . $url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { $_method_name = 'execute' . $url[1]; if (method_exists($controller, $_method_name)) { $controller->{'execute' . $url[1]}(); } else { $this->error(); } } else { $controller->index(); } } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: does such a controller exist ? if (file_exists('./application/controller/' . $this->url_controller . '.php')) { // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require './application/controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { // call the method and pass the arguments to it if (isset($this->url_parameter_3)) { // will translate to something like $this->home->method($param_1, $param_2, $param_3); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3); } elseif (isset($this->url_parameter_2)) { // will translate to something like $this->home->method($param_1, $param_2); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2); } elseif (isset($this->url_parameter_1)) { // will translate to something like $this->home->method($param_1); $this->url_controller->{$this->url_action}($this->url_parameter_1); } else { // if no parameters given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { // default/fallback: call the index() method of a selected controller if (method_exists($this->url_controller, 'index')) { $this->url_controller->index(); } else { // invalid URL, so simply show home/index require './application/controller/home.php'; $home = new Home(); $home->index(); } } } else { // invalid URL, so simply show home/index require './application/controller/home.php'; $home = new Home(); $home->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('HTTP/1.0 404 Not Found'); require APP . 'controller/error.php'; $cont_error = new Error("Esa acción no existe"); $cont_error->index(); } } } else { header('HTTP/1.0 404 Not Found'); require APP . 'controller/error.php'; $cont_error = new Error("Ese controlador no existe"); $cont_error->index(); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/Home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (is_numeric($this->url_action)) { // no action defined: call the default index() method of a selected controller $this->url_controller->index($this->url_action); } elseif (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { new Alert('warning', "exclamation-triangle", "Ce lien n'existe pas..."); header('location: ' . URL . 'erreur'); } } } else { new Alert('warning', "exclamation-triangle", "Ce lien n'existe pas..."); header('location: ' . URL . 'erreur'); } }
public function map() { if ($this->routes[0] === "" && empty($this->routes[1])) { $home = new Home(); return $home->index(); } elseif ("" !== $this->routes[0] && !isset($this->routes[1])) { $className = ucfirst($this->routes[0]); $c = new $className($this->db); return $c->index(); } elseif ("" !== $this->routes[0] && $this->routes[1] !== "" && !isset($this->routes[2])) { $className = ucfirst($this->routes[0]); $method = strtolower($this->routes[1]); $c = new $className($this->db); return $c->{$method}($con = null); } elseif ("" !== $this->routes[0] && $this->routes[1] !== "" && $this->routes[2] !== "") { $className = ucfirst($this->routes[0]); $method = strtolower($this->routes[1]); $c = new $className(); return $c->{$method}($this->routes[2]); } }
function __construct() { $url = isset($_GET['url']) ? $_GET['url'] : null; $url = rtrim($url, '/'); $url = explode('/', $url); //print_r($url); if (empty($url[0])) { require 'controllers/home.php'; $controller = new Home(); $controller->index(); return false; } $file = 'controllers/' . $url[0] . '.php'; if (file_exists($file)) { require $file; } else { $this->error(); exit; } $controller = new $url[0](); $controller->loadModel($url[0]); // calling methods if (isset($url[2])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}($url[2]); } else { $this->error(); } } else { if (isset($url[1])) { if (method_exists($controller, $url[1])) { $controller->{$url[1]}(); } else { $this->error(); } } else { $controller->index(); } } }
public function __construct() { $this->parseUrl(); //return; // check for controller: no controller given ? then load start-page if (!$this->controller) { require APP_DIR . 'controllers/home.php'; $page = new Home(); $page->index(); } elseif (file_exists(APP_DIR . 'controllers/' . $this->controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP_DIR . 'controllers/' . $this->controller . '.php'; $this->controller = new $this->controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->controller, $this->action)) { if (!empty($this->params)) { // Call the method and pass arguments to it call_user_func_array(array($this->controller, $this->action), $this->params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->controller->{$this->action}(); } } else { if (strlen($this->action) == 0) { // no action defined: call the default index() method of a selected controller $this->controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { Home::index(); } elseif (file_exists(APP_PATH . 'controllers/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { // defined action not existent: show the error page $page = new ErrorController(); $page->index(); } } } else { $page = new ErrorController(); $page->index(); } }
<?php define('ROOT', $_SERVER['DOCUMENT_ROOT']); define('HOST', $_SERVER['HTTP_HOST']); define('APP', ROOT . '/application'); require APP . '/config/settings.php'; // ======================================== // Router // ======================================== require APP . '/controller/controller.php'; switch (split_url()) { case '': require APP . '/controller/home.php'; $page = new Home(); $page->index(); break; case 'about': require APP . '/controller/about.php'; $page = new About(); $page->index(); break; case '404': default: require APP . '/controller/error.php'; $page = new Error(); $page->index(); break; }
private function _DisplayHome() { require APP . 'controller/home.php'; $page = new Home(); $page->index(); }
$this->projectrepository = new projectrepository(); $this->adminrepository = new AdminRepository(); } public function index() { $totalUsers = $this->userrepository->count(); $totalFundraisers = $this->fundrepository->count(); $totalFunds = $this->payrepository->total(); $totalProjects = $this->projectrepository->count(); $allFund = $this->fundrepository->get_all(); $allFund = array_reverse($allFund); $allUsers = $this->userrepository->get_all(); $view_page = "home/index"; include_once ROOT_PATH . "admin/views/admin/container.php"; } } //OBJECT OF adminusercontroller $home = new Home(); //IF m IS SET, SET IT TO $method, ELSE DEFAULT IT TO index if (isset($_GET['m'])) { $method = $_GET['m']; } else { $method = "index"; } switch ($method) { case "index": $home->index(); break; default: $home->index(); }
use Klein\Klein as Route; $bag = new Pimple\Container(); // container $route = new Route(); $home = new Home($bag); //controller $dashboard = new Dashboard($bag); // controller $user = new User(); $role = new Role(); $leave = new LeaveController($bag); // $route->respond( function () use($home){ // return 'Middleware should be first palce'; // }); $route->respond('GET', '/', function () use($home) { return $home->index(); }); $route->respond('GET', '/test', function () use($user, $role) { $users = $user->all(); foreach ($users as $user) { var_dump($user->role->permission); } }); $route->respond('GET', '/show/[i:id]', function ($request) use($home) { return $home->show($request); }); $route->respond('GET', '/create', function () use($home) { return $home->create(); }); $route->respond('POST', '/store', function ($request, $response) use($home) { return $home->store($request, $response);
/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); //if not installed and the url is not of install goto install if ($this->getSystemSetting(self::INSTALLATION_STATUS) != 'installed' && strtolower($this->url_controller) != 'install') { self::redirectToAction('index', 'install', 'admin'); } //var_dump(self::getCurrentModule()); die(); //$cntr_file = './app/code/'.self::$module->path.'/'.self::$module->name.'/'.$this->url_controller.'.php'; $cntr_file = './app/code/' . $this->url_controllerFilePath; //die($cntr_file); if (file_exists($cntr_file)) { // if so, then load this file and create this controller // example: if controller would be "sms", then this line would translate into: $this->sms = new sms(); require_once $cntr_file; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { // call the method and pass the arguments to it if (isset($this->url_parameter_3)) { // will translate to something like $this->home->method($param_1, $param_2, $param_3); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3); exit; } elseif (isset($this->url_parameter_2)) { // will translate to something like $this->home->method($param_1, $param_2); $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2); exit; } elseif (isset($this->url_parameter_1)) { // will translate to something like $this->home->method($param_1); $this->url_controller->{$this->url_action}($this->url_parameter_1); exit; } else { // if no parameters given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); exit; } } elseif (method_exists($this->url_controller, 'index')) { // default/fallback: call the index() method of a selected controller //header('Location: '.URL.$this->url_controller.'?notification=Page not found&error_code=1'); //exit(); $this->url_controller->index(); exit; } } // invalid URL, so simply show home/index if (!empty($this->url_controller)) { self::pageNotFound($this->url); } require './app/code/main/home/home.php'; $home = new Home(self::$module->name); $home->index(); exit; }