$_class"; // class not available
return false;
}
// initialize Processing
$object = new $_class ($_postVars, $_getVars);
$methods = get_class_methods($object);
// method in object available and public?
if (!in_array($_event, $methods)) {
// function not available or not public
$_SESSION['messages'][] = "unknown event: " . $_event . " in class " . $_class . "";
return false;
}
if (call_user_func(array (
$object,
'isValid'
))) { // security checks successful
// call the function
call_user_func(array (
$object,
$_event
));
} else {
call_user_func(array (
$object,
'showInvalid'
));
}
self :: $processingInstance = $object;
return true;
}
/***************************************************************
* calls processEvent and shows errorMessage if occures
****************************************************************/
public static function process($_postVars, $_getVars) {
$nav = $_getVars["nav"];
$action = null;
// iterate POST for button-action
foreach ($_postVars as $key => $value) {
if (strstr($key, "btn")) {
$action = str_replace("_y", "", str_replace("_x", "", $key . "_onClick"));
break;
}
}
// if there is no action defined by POST, use action from GET
if (!strlen($action)) {
$action = (!isset($_getVars["action"]) ? (!isset($_getVars['showPrintable']) ? "show" : "showPrintable") : $_getVars["action"] . "_onClick");
}
try {
if (!self :: processEvent($nav . "Controller", $action, $_postVars, $_getVars)) {
if (ConfigLoader :: getInstance()->getPHPSettings('debugMode') == 'on') {
MessageLoader :: showMessages();
} else {
ErrorLogLoader :: getInstance()->logError($_SESSION['messages'], $nav . "Controller");
unset ($_SESSION['messages']);
$location = ConfigLoader :: getInstance()->getConfigPath('headerLocation');
header('Location: /'.$location);
}
}
} catch (Exception $ex) {
if (ConfigLoader :: getInstance()->getPHPSettings('debugMode') == 'on') {
echo "Fatal error occured: " . $ex->getMessage() . "
" . nl2br($ex->getTraceAsString());
echo '
in ' . $ex->getFile() . ', line: ' . $ex->getLine() . '.';
} else {
$error = "Fatal error occured: " . $ex->getMessage() . nl2br($ex->getTraceAsString()) . " in " . $ex->getFile() . ", line: " . $ex->getLine();
ErrorLogLoader :: getInstance()->logError($error, $nav . "Controller");
$location = ConfigLoader :: getInstance()->getConfigPath('headerLocation');
header('Location: /'.$location);
}
}
}
}
?>