/** * Whatever Data is returned by Hanlder, should be an array will be rendered as array on response * * @param AbstractUser $user * @param array $controllerInfo * @param String $handlerName */ function rx_interceptor_json($user, $controllerInfo, $handlerName) { $user->validate(); include_once RUDRA . "/core/handler/AbstractHandler.php"; $handlerInfo = ClassUtil::getHandler($handlerName); if ($handlerInfo != NULL) { global $temp; include_once $handlerInfo["filePath"]; $className = $handlerInfo["className"]; $tempClass = new ReflectionClass($className); if ($tempClass->isInstantiable()) { $temp = $tempClass->newInstance(); } if ($temp != NULL) { try { if ($tempClass->hasMethod("invokeHandler")) { $resp = call_method_by_class($tempClass, $temp, 'invokeHandler', array('user' => $user, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]); if (isset($resp)) { echo json_encode($resp); } } } catch (Exception $e) { echo json_encode(array("error" => $e)); } } } }
function rx_interceptor_page($user, $info, $handlerName) { $user->validate(); include_once RUDRA . "/core/handler/AbstractHandler.php"; $handlerInfo = ClassUtil::getHandler($handlerName); if ($handlerInfo != NULL) { global $temp; include_once $handlerInfo["filePath"]; $className = $handlerInfo["className"]; $tempClass = new ReflectionClass($className); if ($tempClass->isInstantiable()) { $temp = $tempClass->newInstance(); } if ($temp != NULL) { if ($tempClass->hasMethod("invokeHandler")) { $tpl = new Smarty(); call_user_func(rx_function("rx_set_smarty_paths"), $tpl); $tpl->debugging = RX_SMARTY_DEBUG; $header = new Header($tpl); $page = new Page(); $view = call_method_by_class($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'header' => $header, 'page' => $page, 'dataModel' => $page->data, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]); if (!isset($view)) { $view = $handlerName; } $tpl->assign('user', $user); $tpl->assign('page', $page); $tpl->assign('header', $header); $tpl->assign('CONTEXT_PATH', CONTEXT_PATH); $tpl->assign('RESOURCE_PATH', RESOURCE_PATH); $tpl->assign('METAS', $header->metas); $tpl->assign('TITLE', $header->title); $view_path = $view . TEMP_EXT; if (!file_exists($view_path)) { $tpl->setTemplateDir(RUDRA . "/core/view"); //$view_path = get_include_path () . RUDRA . "/core/view/".$view.TEMP_EXT; //$view_path = get_include_path () . RUDRA . "../view/".$view.TEMP_EXT; } $tpl->assign('BODY_FILES', $view_path); $tpl->assign('page_json', json_encode($page->data->data)); $tpl->display(RUDRA . "/core/view/full.tpl"); Browser::log("header", $header->css, $header->scripts); Browser::printlogs(); } } } }
function rx_interceptor_template($user, $info, $handlerName) { $user->validate(); include_once RUDRA . "/core/handler/AbstractHandler.php"; $handlerInfo = ClassUtil::getHandler($handlerName); if ($handlerInfo != NULL) { global $temp; include_once $handlerInfo["filePath"]; $className = $handlerInfo["className"]; $tempClass = new ReflectionClass($className); if ($tempClass->isInstantiable()) { $temp = $tempClass->newInstance(); } if ($temp != NULL) { if ($tempClass->hasMethod("invokeHandler")) { $tpl = new Smarty(); call_user_func(rx_function("rx_set_smarty_paths"), $tpl); $tpl->debugging = RX_SMARTY_DEBUG; $page = new Page(); $view = call_method_by_class($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'page' => $page, 'dataModel' => $page->data, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]); if (!isset($view)) { $view = $handlerName; } $tpl->assign('user', $user); $tpl->assign('CONTEXT_PATH', CONTEXT_PATH); $tpl->assign('RESOURCE_PATH', RESOURCE_PATH); if (isset($tpl->repeatData)) { foreach ($tpl->repeatData as $key => $value) { $tpl->assign($value['key'], $value['value']); $tpl->display($this->getViewPath() . $view . Config::get('TEMP_EXT')); } } else { $tpl->display($this->getViewPath() . $view . Config::get('TEMP_EXT')); } echo TEMP_DELIMITER; Browser::printlogs(); echo TEMP_DELIMITER . json_encode($page->data->data); Browser::printlogs(); } } } }