예제 #1
0
 public function writeLog()
 {
     $logs = LogCache::getCache();
     $html = array();
     $html[] = '<table width="100%" border="1" cellpadding="0" cellspacing="0">';
     $html[] = '<tr><th colspan="2"><h2>debuger</h2></th></tr>';
     foreach ($logs as $key => $list) {
         $html[] = '<tr>';
         $html[] = '<th align="left">' . (empty($key) ? 'default' : $key) . '</th>';
         $html[] = '<td>';
         foreach ($list as $i => $msg) {
             $html[] = '<p>' . $msg . '</p>';
         }
         $html[] = '</td>';
         $html[] = '</tr>';
     }
     $html[] = '</table>';
     echo implode('', $html);
 }
예제 #2
0
 private function delegate($urlParse)
 {
     $controller = $urlParse->getController();
     $action = $urlParse->getAction();
     if (empty($controller)) {
         $controller = $this->defaultController;
     }
     try {
         $controllerObject = $this->loadController($controller);
         if ($controllerObject instanceof Controller) {
             LogCache::log('controller name', $controller);
             if (empty($action)) {
                 $action = $controllerObject->__getDefaultActionName();
                 if (!$action) {
                     $action = $this->defaultAction;
                 }
             }
             $params = $urlParse->getParam();
             $controllerObject->__setApp($this);
             $controllerObject->trigger($action, $controller, $params);
         } else {
             throw new FwException("not extend controller `{$controller}`!", 2);
         }
     } catch (FwException $e) {
     }
 }
예제 #3
0
 public function countQuery($query)
 {
     $this->open();
     $resource = mysql_query($query, $this->link);
     if (is_bool($resource)) {
         if (!$resource) {
             $error = mysql_error();
             if ($error) {
                 throw new FwException($error . '<br /><br />SQL : ' . $query, 3388);
             }
         }
         LogCache::log('SQL', $query);
         return 1;
     } else {
         LogCache::log('SQL', $query);
     }
     if ($resource) {
         return mysql_num_rows($resource);
     }
     return 0;
 }
예제 #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);
     }
 }