function request($class, $proc, $param = array(), $lRet = false) { $globals = $GLOBALS['globals']; $objData = Controller::Call($class, $proc, $globals, $param); if (isset($objData->view_file)) { $file = $objData->view_file . '.tpl'; } else { $file = $class . '/' . $proc . '.tpl'; } if (is_string($objData)) { if ($lRet) { return $objData; } echo $objData; } else { //if( file_exists( $globals->environment->dir_view . $file ) ){ $smarty = new Smarty(); $smarty->setTemplateDir($globals->environment->dir_view); $smarty->assign('class', $class); $smarty->assign('proc', $proc); $smarty->assign('param', $param); $smarty->assign('objData', $objData); $smarty->assign('tools', $globals->tools); $smarty->assign('environment', $globals->environment); if ($lRet) { return $smarty->fetch($file); } $smarty->display($file); } }
public static function Route($requestUrl) { $requestUrl = self::removePath($requestUrl); $controllerAction = self::parseUrl($requestUrl); if (count($controllerAction) > 0 && strlen($controllerAction[0]) > 1) { $controller = $controllerAction[0]; $action = count($controllerAction) > 1 && strlen($controllerAction[1]) > 1 ? $controllerAction[1] : "index"; if (!Controller::Call($controller, $action)) { self::UnknownResource(); } } else { //self::unknownResource(); self::Route("/user/login"); } }
<?php //TODO - Criar metodo de acesso por controller/view require_once 'configs.php'; try { //Esses valores devem vir do [systemPath]/init.php $objData = Controller::Call($class, $proc, $globals, $param); //Retorna o view $template_ext = $globals->cfg->getConfig(PROJECT_ID . '_ENGINE', 'TEMPLATE_EXTENSION', '.html'); if (isset($objData->view_file)) { $file = $objData->view_file . $template_ext; } else { $file = $class . '/' . $proc . $template_ext; } //Passa as variaveis para o template $globals->smarty->assign('class', $class); $globals->smarty->assign('proc', $proc); $globals->smarty->assign('param', $param); $globals->smarty->assign('objData', $objData); $globals->smarty->assign('tools', $globals->tools); $globals->smarty->assign('cfg', $globals->cfg); $globals->smarty->assign('login', $globals->login); $globals->smarty->assign('environment', $globals->environment); $globals->smarty->assign('user', $globals->user); $globals->smarty->assign('globals', $globals); //Renderiza o view if (file_exists($globals->environment->viewPath . $file)) { echo $globals->smarty->fetch($file); } elseif (!is_object($objData)) { echo $objData; }