/** * 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)); } } } }
public static function handler($handle_name) { $CloudinaryClassInfo = \ClassUtil::getHandler($handle_name); if ($CloudinaryClassInfo != NULL) { include_once $CloudinaryClassInfo["filePath"]; $CloudinaryClassInstance = new $CloudinaryClassInfo["className"](); $CloudinaryClassInstance->populateParams(); return $CloudinaryClassInstance; } return null; }
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(); } } } }
function rx_scan_dir($annotations, $dir) { $allController = ClassUtil::getControllerArray(); $dir_iterator = new RecursiveDirectoryIterator($dir); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); // could use CHILD_FIRST if you so wish foreach ($iterator as $filename => $file) { if ($file->isFile()) { if (fnmatch("*/handler/*.php", $file->getPathname()) || fnmatch("*\\\\handler\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $result = $annotations->getClassAnnotations($className); if (isset($result["Handler"]) && isset($result["Handler"][0]) && !empty($result["Handler"][0])) { ClassUtil::setHandler($result["Handler"][0], array("className" => $className, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "requestParams" => isset($result["RequestParams"]))); Browser::warn("HandleScanned::", ClassUtil::getHandler($result["Handler"][0])); ClassUtil::setMTime($className, $file->getMTime()); } } } else { if (fnmatch("*/controller/*.php", $file->getPathname()) || fnmatch("*\\\\controller\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $methods = get_class_methods($className); foreach ($methods as $method) { $result = $annotations->getMethodAnnotations($className, $method); Browser::error("ControllerScanned::", $result); if (isset($result["RequestMapping"]) && isset($result["RequestMapping"][0]) && isset($result["RequestMapping"][0]["url"])) { $allController[] = array("className" => $className, "method" => $method, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "mappingUrl" => $result["RequestMapping"][0]["url"], "requestParams" => isset($result["RequestParams"]), "cache" => isset($result["RequestMapping"][0]["cache"]) ? $result["RequestMapping"][0]["cache"] : FALSE, "type" => isset($result["RequestMapping"][0]["type"]) ? $result["RequestMapping"][0]["type"] : NULL, "requestMethod" => isset($result["RequestMapping"][0]["method"]) ? strtoupper($result["RequestMapping"][0]["method"]) : NULL); } } Browser::warn("ControllerScanned::", $allController[$result["RequestMapping"][0]["url"]]); ClassUtil::setMTime($className, $file->getMTime()); } } else { if (fnmatch("*/model/*.php", $file->getPathname()) || fnmatch("*\\\\model\\\\*.php", $file->getPathname())) { require_once $file->getPathname(); $className = str_replace(".php", "", $file->getFilename()); $scan = true; if (ClassUtil::getMTime($className) >= $file->getMTime()) { $scan = false; } if ($scan && class_exists($className)) { $result = $annotations->getClassAnnotations($className); if (isset($result["Model"]) && isset($result["Model"][0]) && !empty($result["Model"][0])) { ClassUtil::setModel($result["Model"][0], array("className" => $className, "filePath" => $file->getPathname(), "mtime" => $file->getMTime(), "type" => $result["Model"][0])); Browser::warn("ModelScanned::", ClassUtil::getModel($result["Model"][0])); ClassUtil::setMTime($className, $file->getMTime()); } } } } } } } ClassUtil::setControllerArray($allController); }