本文整理汇总了PHP中Home::index方法的典型用法代码示例。如果您正苦于以下问题:PHP Home::index方法的具体用法?PHP Home::index怎么用?PHP Home::index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Home
的用法示例。
在下文中一共展示了Home::index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* "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');
}
}
示例2: __construct
/**
* "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();
}
}
示例3: __construct
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();
}
}
示例4: __construct
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');
}
}
示例5: __construct
/**
* "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();
}
}
示例6: __construct
/**
* "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();
}
}
示例7: isset
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();
}
}
示例8: isset
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();
}
}
}
示例9: __construct
/**
* "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();
}
}
示例10: __construct
/**
* "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();
}
}
示例11: __construct
/**
* "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');
}
}
示例12: map
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]);
}
}
示例13: isset
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();
}
}
}
示例14: __construct
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');
}
}
示例15: __construct
/**
* "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();
}
}