예제 #1
0
 public function getDbSession()
 {
     if ($this->dbsession) {
         return $this->dbsession;
     }
     $config = Config::get("database.mysql") or array();
     return $this->dbsession = new DBMysql($config);
 }
예제 #2
0
 public function __construct($config)
 {
     $this->setOption($config);
     $this->config = $config;
     Config::setConfig($this->config);
     $umconfig = Config::get(static::CFGKEY_MAPPING) or array();
     $this->urlMapping = new UrlMapping($umconfig);
     $this->checkOptions();
 }
예제 #3
0
 private function init()
 {
     if ($this->state === static::STATE_INIT) {
         return;
     }
     $session_name = Config::get('session_name', '__life__');
     session_name($session_name);
     session_start();
     $this->state = static::STATE_INIT;
 }
예제 #4
0
 public function trigger($action, $controller, $params)
 {
     $this->request = new Request();
     $this->response = new Response();
     $this->session = new Session();
     $paths = $params['paths'];
     $isSimpleMode = $this->__isSimpleMode();
     if ($isSimpleMode) {
         $method = $this->__handleRequestName();
         $paths = array_splice($paths, 1);
         LogCache::log('simple mode', 'true');
     } else {
         $method = $action . self::SUFFIX;
         $paths = array_splice($paths, 2);
         LogCache::log('simple mode', 'false');
     }
     if (method_exists($this, $method)) {
         $this->view = $this->__getView($this->app->getViewPath(), $this->app->getLayoutPath());
         if ($this->__before($controller, $action)) {
             return;
         }
         LogCache::log('action name', $method);
         $pageinfo = call_user_func_array(array($this, $method), $paths);
         $this->__afterCall($controller, $action);
         if (!empty($pageinfo)) {
             if (is_bool($pageinfo)) {
                 $pageinfo = null;
             }
             $viewName = null;
             $layout = null;
             if (is_array($pageinfo)) {
                 if (isset($pageinfo['layout']) and $pageinfo['layout']) {
                     $layout = $pageinfo['layout'];
                 }
                 if (isset($pageinfo['view']) and $pageinfo['view']) {
                     $viewName = $pageinfo['view'];
                 }
             } else {
                 $viewName = $pageinfo;
             }
             if (empty($viewName)) {
                 //在simple模式,直接使用controller名作为view名
                 if ($isSimpleMode) {
                     $viewName = $controller . '.php';
                 } else {
                     $viewName = $controller . '/' . $action . '.php';
                 }
             }
             if (empty($layout)) {
                 $layout = $this->__getLayoutName();
                 if (empty($layout)) {
                     $layout = Config::get('layout');
                 }
             }
             $this->view->write($viewName, $layout);
         }
         $this->__after($controller, $action);
     } else {
         throw new FwException("not defined method `{$method}`!", 3);
     }
 }