コード例 #1
0
ファイル: abstract.php プロジェクト: fchaose/qeephp
 /**
  * QeePHP 应用程序 MVC 模式入口
  *
  * @return mixed
  */
 function run()
 {
     // #IFDEF DEBUG
     QLog::log(__METHOD__, QLog::DEBUG);
     // #ENDIF
     // 设置默认的时区
     date_default_timezone_set($this->context->getIni('l10n_default_timezone'));
     // 设置 session 服务
     if ($this->context->getIni('runtime_session_provider')) {
         Q::loadClass($this->context->getIni('runtime_session_provider'));
     }
     // 打开 session
     if ($this->context->getIni('runtime_session_start')) {
         // #IFDEF DEBUG
         QLog::log('session_start()', QLog::DEBUG);
         // #ENDIF
         session_start();
     }
     // 设置验证失败错误处理的回调方法
     $this->context->setIni('dispatcher_on_access_denied', array($this, 'onAccessDenied'));
     // 设置处理动作方法未找到错误的回调方法
     $this->context->setIni('dispatcher_on_action_not_found', array($this, 'onActionNotFound'));
     // 从 session 中提取 flash message
     if (isset($_SESSION)) {
         $key = $this->context->getIni('app_flash_message_key');
         $arr = isset($_SESSION[$key]) ? $_SESSION[$key] : null;
         if (!is_array($arr)) {
             $arr = array(self::FLASH_MSG_INFO, $arr);
         } elseif (!isset($arr[1])) {
             $arr = array(self::FLASH_MSG_INFO, $arr[0]);
         }
         if ($arr[0] != self::FLASH_MSG_ERROR && $arr[0] != self::FLASH_MSG_INFO && $arr[0] != self::FLASH_MSG_WARNING) {
             $arr[0] = self::FLASH_MSG_INFO;
         }
         $this->_flash_message_type = $arr[0];
         $this->_flash_message = $arr[1];
         unset($_SESSION[$key]);
     }
     // 初始化访问控制对象
     $this->acl = Q::getSingleton('QACL');
     // 执行动作
     $context = QContext::instance($this->context->module_name, $this->_appid);
     return $this->_executeAction($context);
 }