static function render() { $args = func_get_args(); $action = $args[0]; $controller = isset($args[1]) ? $args[1] : self::controller_name(); $controllerClass = $controller . 'Controller'; $ContrArgs = isset($args[2]) ? $args[2] : ''; if (!is_callable(array($controllerClass, $action))) { if (is_file('controllers/' . $controller . '_controller.php')) { include 'controllers/' . $controller . '_controller.php'; } Registry::set('controller', $controller, true); //loading model if (is_file('models/' . $controller . '.php')) { include 'models/' . $controller . '.php'; } else { Registry::addDebug('<div class="notice">Notice: No model For: <i>"' . $controller . '"</i> controller</div>'); } $controllerClass::$action($ContrArgs); ob_start(); include 'views/' . $controller . '/' . $action . '.html.php'; Registry::set('content', ob_get_contents()); ob_end_clean(); } }
static function render($file) { if (is_file('views/' . Registry::get('controller') . '/_' . $file . '.html.php')) { include 'views/' . Registry::get('controller') . '/_' . $file . '.html.php'; } else { $fileEx = explode('/', $file); $fileExLast = array_pop($fileEx); if (is_file('views/' . implode('/', $fileEx) . '/_' . $fileExLast . '.html.php')) { include 'views/' . implode('/', $fileEx) . '/_' . $fileExLast . '.html.php'; } elseif (is_file('views/' . implode('/', $fileEx) . '/' . $fileExLast . '.php')) { include 'views/' . implode('/', $fileEx) . '/' . $fileExLast . '.php'; } else { Registry::addDebug('<div class="error">Error: No file (' . $file . ') loading by View::render </div>'); } } }
static function delegate($debug = false) { //REST система <!-- BEGIN --> /*global $_PUT; global $_DELETE;*/ global $_POST; $_PUT = array(); $_DELETE = array(); if (isset($_POST['_method']) || isset($_POST[0])) { //Реристрация Запроса (REQUEST) if (isset($_POST['_method'])) { Registry::set('method', strtolower($_POST['_method'])); //$_SERVER['REQUEST_METHOD']=strtoupper($_POST['_method']); unset($_POST['_method']); Registry::set('request', $_POST); $_POST = array(); /*$temp= "_".$_SERVER["REQUEST_METHOD"]; $$temp=$_POST;*/ } else { Registry::set('method', 'post'); $_SERVER['REQUEST_METHOD'] = 'POST'; Registry::set('request', $_POST); } //REST action decloration $action = constant(Registry::get('method')); } //REST система <!-- END --> //if($RESTaction){$controller=$RESTaction;echo "KUKARACHJA";} // Анализируем путь self::getController($file, $controller, $action, $args); $controllerClass = $controller . 'Controller'; // Файл доступен? if (!is_readable($file)) { die('404 Not Found Error:unreadable'); } include $file; //проверка на наличия правельного контролера if (!is_callable(array($controllerClass, $action))) { array_unshift($args, $action); $action = 'index'; if (!is_callable(array($controllerClass, $action))) { die('404 Not Found Error: uncallable 2'); } } Registry::set('controller', $controller, true); //добавлаем в журнал текушей контролер //вывод стандартной абортки... если неиспользуетса контролер if ($controllerClass == 'applicationController') { //Registry::set('controller', 'application',true); //добавлаем в журнал текушей контролер applicationController::index($args); } //вывод каковата модалимя и стандартной абортки... // Выполняем действие application if (!is_callable(array('applicationController', 'index'))) { //Registry::set('controller', 'application',true); //добавлаем в журнал текушей контролер include 'controllers/application_controller.php'; applicationController::index($args); } // Выполняем действие контродира если не application if ($controllerClass != 'applicationController') { //loading model if (is_file('models/' . $controller . '.php')) { include 'models/' . $controller . '.php'; } else { Registry::addDebug('<div class="notice">Notice: No model For: <i>"' . $controller . '"</i> controller</div>'); } $controllerClass::$action($args); //loading VIEW if (is_file('views/' . $controller . '/' . $action . '.html.php')) { ob_start(); include 'views/' . $controller . '/' . $action . '.html.php'; $output = ob_get_contents(); Registry::append('content', ob_get_contents()); ob_end_clean(); } else { Registry::addDebug('<div class="notice">Notice: No VIEW For: <i>"' . $controller . '/' . $action . '"</i> controller</div>'); } } }