/** * 自动运行 */ public function init() { restore_error_handler(); // 文件锁 $this->_lockFile = APPLICATION_PATH . '/Data/Logs/install.lock'; $this->_isLocked = file_exists($this->_lockFile); // 使用视图 QP_Layout::name('Setup.html'); }
/** * 框架只会自动调用该方法,用户自己的代码可加在里面. * */ public function init() { // 使用 session @session_start(); // 使用 Layout QP_Layout::start(); // 引用公共函数库(Application/Library已经在搜索路径中了) require 'Function.inc.php'; // 得到当前语言 $lang = getLang(); // 读出JS语言包设置到视图中 $jsLang = json_encode(include APPLICATION_PATH . '/Lang/' . $lang . '/Javascript.php'); QP_Layout::set('jsLang', $jsLang); // 用户访问权限判断 $this->_checkpriv(); }
/** * 异步得到输入编辑器HTML * */ public function htmlAction() { // 不使用视图 QP_Layout::stop(); $id = $this->request->getGet('id', 0); if ($id > 0) { // 得到要编辑的BUG模板内容 $info = $this->model->bugtplInfo($id); $tplname = $info['tplname']; $defaultTpl = $info['tplhtml']; } else { // 默认的模板内容 $tplname = ''; $defaultTpl = getDefaultBugTpl(); } $this->view->tplname = $tplname; $this->view->tplhtml = $defaultTpl; }
/** * 关于系统 */ public function aboutAction() { // 不使用视图 QP_Layout::stop(); }
/** * 运行调度器 * */ public function run() { // APP运行的开始时间 $this->_setDebugInfo('beginTime', microtime(true)); // 运行应用的 Bootstrap require APPLICATION_PATH . '/Bootstrap.php'; $bootStrap = new Bootstrap(); $bootStrap->init(); // 解析当前的URI(包括解析路由) $this->_parseUri(); // 得到控制器 $controller = $this->_getController(); $action = $this->_action . 'Action'; // 判断动作是否存在 if (!method_exists($controller, $action)) { throw new QP_Exception('控制器:' . get_class($controller) . ' 中未定义动作:' . $action, QP_Exception::EXCEPTION_NO_ACTION); } // 选择的动作 $this->_setDebugInfo('action', $action); // 把执行的输出先保存起来放到 Layout 中显示 ob_start(); // 执行 init 方法 $controller->init(); // 执行动作 $controller->{$action}(); // 得到所有输出内容 $viewContent = ob_get_clean(); // 是否自动输出视图 if ($controller->viewIsAutoRender()) { $controller->view->setPath($this->_controllerPath); $viewContent .= $controller->view->render($this->_action . '.html'); // 使用的视图 $this->_setDebugInfo('view', $this->_action . '.html'); } // 是否启用了 Layout if (QP_Layout::isEnabled()) { // 将 Layout 当作当前视图的一部分 $view = QP_View::getInstance(); $view->setPath(APPLICATION_PATH . '/Views/Layouts', true); // 将布局的变量与重新赋值给视图 $view->assign(QP_Layout::get()); // 'LayoutContent' 为框架的布局内容引用 $view->LayoutContent = $viewContent; $layoutName = QP_Layout::name(); $viewContent = $view->render($layoutName); // 使用的 Layout $this->_setDebugInfo('layout', $layoutName); } // 如果是 SAPI 运行模式就要设置字符集,防止乱码 if (PHP_SAPI != 'cli') { header("Content-Type:text/html; charset=" . $this->_appConfig['charset']); } // 有视图内容则输出 if ($viewContent != '') { echo $viewContent; } // APP运行的结束时间 $this->_setDebugInfo('endTime', microtime(true)); // 如果显示调试信息 并且 当前不是 AJAX 的请求 并且框架不是以 CLI方式运行 if ($this->_appConfig['debug'] && !$this->_request->isAjax() && PHP_SAPI != 'cli') { $debugInfo = $this->_debugInfo; include QUICKPHP_PATH . '/Debug/Debuginfo.php'; } }
/** * 得到当前布局名 * * @param $name 如果设置值则 Layout 登录这个值,否则返回当前的 Layout 名称 * @return string */ public static function name($name = '') { if ($name) { self::$_name = $name; } return self::$_name; }
/** * 打印BUG */ public function printAction() { // 不使用Layout QP_Layout::stop(); // 不自动解析视图 $this->setViewAutoRender(false); // BUG信息 $bugid = $this->request->getGet('bugid'); echo $this->bugHtml($bugid); }
/** * 显示选择用户框 */ public function selectUserAction() { // 不使用视图 QP_Layout::stop(); // 用户组 $pcUid = $this->getPCUid(); $this->view->groupList = $this->model->userGroupList(array('userid' => $pcUid)); }