Location: PHPKode > projects > simpleMVC > myGifts/index.php
<?php

if (DEBUG)
	ob_start();

require("includes/includes.inc.php");

$user = User::getCurrentUser();

$handler = Tools::getHttpParam("handler");
$method = Tools::getHttpParam("method");
$nextAction = Tools::getHttpParam("nextAction");
$error = "";
$errorCritical = false;

$logger->logMessage($logger->LOG_INFO, "appel $handler/$method");

if (empty($handler)) {
	$logger->logMessage($logger->LOG_INFO, "default action : ".MVC_DEFAULT_HANDLER." !");
	$handler = MVC_DEFAULT_HANDLER;
	$method = "display";
}
if (empty($method)) {
	$logger->logMessage($logger->LOG_INFO, "default method : display");
	$method = "display";
}

if (Controler::needsLogin($handler) > 0) {
	if (!is_object($user) || empty($user->name)) {
		$logger->logMessage($logger->LOG_INFO, "$handler needs Login !");
		$nextAction = $handler;
		$handler = "login";
		$method = "display";
	} elseif (Controler::needsLogin($handler) > $user->accessLevel) {
		$logger->logMessage($logger->LOG_INFO, "$handler needs Login !");
		$error = "ERROR_ACCESSDENIED";
		$errorCritical = true;
	}
}

$object = Controler::getObject($handler);

if ($method != "display") {
	$error = Controler::callAction($object, $handler);

	$logger->logMessage($logger->LOG_INFO, "nextAction avant = $nextAction/".empty($nextAction));
	if (empty($nextAction))
		$nextAction = Controler::nextAction($handler);
	$logger->logMessage($logger->LOG_INFO, "nextAction final = $nextAction");
	if (!empty($nextAction) && empty($error)) {
		Controler::goto($nextAction);
	} else
		Controler::gotoPrevious($error);
}

if (!empty($error) && $errorCritical) {
	Controler::displayError($error);
} elseif ($method != "action") {
	$params = Controler::getParamsAction($object, $handler);

	Controler::displayTemplate($handler, $user, $object, $nextAction);
}

if (DEBUG)
	ob_end_flush();
?>
Return current item: simpleMVC