static function run() { $code = 1; $msg = ''; $data = null; App::init(); try { $data = self::execute(); } catch (AppBreakException $e) { return; } catch (Exception $e) { if (App::$controller && App::$controller->is_ajax) { $code = $e->getCode(); $msg = $e->getMessage(); if (!strlen($msg)) { $msg = 'error'; } } else { return self::error_handle($e); } } if (App::$controller && App::$controller->is_ajax) { $resp = array('code' => $code, 'message' => $msg, 'data' => $data); if (defined('JSON_UNESCAPED_UNICODE')) { $json = json_encode($resp, JSON_UNESCAPED_UNICODE); } else { $json = json_encode($resp); } $jp = App::$controller->jp; if (!preg_match('/^[a-z0-9_]+$/i', $jp)) { $jp = false; } if ($jp) { echo "{$jp}({$json});"; } else { echo $json; } } else { $layout = find_layout_file(); if ($layout) { $params = App::$context->as_array(); extract($params); include $layout; } else { _view(); } } }
function find_view_and_layout() { $view = find_view(); $view_file = false; $layout_file = false; if ($view) { $view_file = $view[1]; $layout_file = find_layout_file($view[0]); if ($layout_file) { array_unshift(App::$controller->view_path, $view[0]); } } if (!$layout_file) { foreach (App::$controller->view_path as $view_path) { $layout_file = find_layout_file($view_path); if ($layout_file) { break; } } } return array($view_file, $layout_file); }