public function invokeHandler(Smarty $viewModel, $header, $f, $page, User $user) { $header->meta(array('keywords' => 'Home Meta Keywords', 'description' => 'Home Meta Description')); $header->title('RUDRAX'); $header->import('bootstrap', 'utils', 'product_login', 'utils_tunnel'); $cahce = new RxCache(); $page->data->assign('myDataKey', $cahce->get('mykey')); $cahce->set('mykey', $cahce->get('mykey') + 1); if (isset($_REQUEST['uname'])) { $username = $_POST['uname']; $password = $_POST['pass']; $user->auth($username, $password); } //Console::log($this->user->getToken(),$username,$password); if ($user->isValid()) { $viewModel->assign('token', $user->getToken()); $viewModel->assign('profile', $user->getProfile()); $viewModel->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true); $viewModel->assign("FirstName", array("John", "Mary", "James", "Henry")); $viewModel->assign("LastName", array("Doe", "Smith", "Johnson", "Case")); $viewModel->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), array("M", "N", "O", "P"))); $viewModel->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); $viewModel->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX")); $viewModel->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas")); $viewModel->assign("option_selected", "NE"); return "home/home"; } else { return "sample/login"; } }
public function invoke(User $user, $handlerName) { $user->validate(); include_once RUDRA . "/core/handler/AbstractHandler.php"; $handleCache = new RxCache("handlers", true); global $temp; $className; if ($handleCache->hasKey($handlerName)) { $classObj = $handleCache->get($handlerName); include_once $classObj["filePath"]; $className = $classObj["className"]; } else { $className = ucfirst($handlerName); include_once HANDLER_PATH . "/" . $this->getHandlerPath() . $className . ".php"; } $tempClass = new ReflectionClass($className); if ($tempClass->isInstantiable()) { $temp = $tempClass->newInstance(); } if ($temp != NULL) { if ($tempClass->hasMethod("invokeHandler")) { $tpl = new Smarty(); // $tpl->prepare(); self::setSmartyPaths($tpl); // $tpl->testInstall(); exit; $tpl->debugging = Config::get('SMARTY_DEBUG'); $page = new Page(); $view = RudraX::invokeMethodByReflectionClass($tempClass, $temp, 'invokeHandler', array('tpl' => $tpl, 'viewModel' => $tpl, 'user' => $user, 'page' => $page, 'dataModel' => $page->data)); //$view = $temp->invokeHandler($tpl ); if (!isset($view)) { $view = $handlerName; } $tpl->assign('user', $user); $tpl->assign('CONTEXT_PATH', CONTEXT_PATH); $tpl->assign('RESOURCE_PATH', Config::get('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; if (BROWSER_LOGS) { Browser::printlogs(); } echo TEMP_DELIMITER . json_encode($page->data->data); } else { if ($tempClass->hasMethod("invoke")) { $view = $temp->invoke(); if (!isset($view)) { $view = $handlerName; } include $this->getViewPath() . $view . '.php'; } } } }