本文整理汇总了PHP中HomeController::load_view方法的典型用法代码示例。如果您正苦于以下问题:PHP HomeController::load_view方法的具体用法?PHP HomeController::load_view怎么用?PHP HomeController::load_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HomeController
的用法示例。
在下文中一共展示了HomeController::load_view方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($route)
{
if (!isset($_SESSION)) {
//buscar opciones en el PHP.INI
session_start(['use_only_cookies' => 1, 'auto_start' => 1]);
}
if (!isset($_SESSION['status'])) {
$_SESSION['status'] = false;
}
if ($_SESSION['status']) {
$this->route = !isset($_GET['r']) ? 'home' : $route;
switch ($this->route) {
case 'home':
$controller = new HomeController();
$controller->load_view('home');
break;
case 'usuarios':
$controller = new HomeController();
if (!isset($_POST['r'])) {
$controller->load_view('users');
} else {
if ($_POST['r'] == 'user-add') {
$controller->load_view('user-add');
} else {
if ($_POST['r'] == 'user-edit') {
$controller->load_view('user-edit');
} else {
if ($_POST['r'] == 'user-delete') {
$controller->load_view('user-delete');
}
}
}
}
break;
case 'generos':
$controller = new HomeController();
if (!isset($_POST['r'])) {
$controller->load_view('genres');
} else {
if ($_POST['r'] == 'genre-add') {
$controller->load_view('genre-add');
} else {
if ($_POST['r'] == 'genre-edit') {
$controller->load_view('genre-edit');
} else {
if ($_POST['r'] == 'genre-delete') {
$controller->load_view('genre-delete');
}
}
}
}
break;
case 'peliculas':
$controller = new HomeController();
$controller->load_view('movies');
break;
case 'salir':
$controller = new Session();
$controller->logout();
break;
default:
$controller = new Error404Controller();
break;
}
} else {
if (!isset($_POST['user']) && !isset($_POST['pass'])) {
$controller = new HomeController();
$controller->load_view('login');
} else {
$controller = new Session();
$session = $controller->login($_POST['user'], $_POST['pass']);
if (is_array($session)) {
$_SESSION['status'] = true;
foreach ($session as $row) {
$_SESSION['user'] = $row['user'];
$_SESSION['email'] = $row['email'];
$_SESSION['name'] = $row['name'];
$_SESSION['birthday'] = $row['birthday'];
$_SESSION['pass'] = $row['pass'];
$_SESSION['role'] = $row['role'];
}
header('Location: ./');
} else {
$controller = new HomeController();
$controller->load_view('login');
header("Location: ./?error={$session}");
}
}
}
}