示例#1
0
文件: Front.php 项目: hongbo819/LJL
 public static function run()
 {
     LJL_Registry::set('request', new LJL_Request());
     $request = LJL_Registry::get('request');
     LJL_Registry::set('response', new LJL_Response());
     $response = LJL_Registry::get('response');
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $controller = LJL_String::toValidVariableName($controller);
     $action = LJL_String::toValidVariableName($action);
     if (empty($controller)) {
         throw new LJL_Exception("The controller of '{$controller}' is empty in request!");
     }
     if (empty($action)) {
         throw new LJL_Exception("The action of '{$action}' is empty in request!");
     }
     $controller = APP_NAME . '_Page_' . ucfirst($controller);
     //var_dump($controller);
     $page = new $controller($request, $response);
     self::$_page = $page;
     self::$_url = empty($_SERVER['SCRIPT_URL']) ? '' : $_SERVER['SCRIPT_URL'];
     self::$_cacheKey = self::getCacheKey();
     //var_dump($page);
     if ($page->isCache() && ($html = self::getCache())) {
         die($html);
     }
     if ($page->validate($request, $response)) {
         $actionMap = $page->getActionMapping();
         if (empty($actionMap)) {
             $action = 'do' . ucfirst($action);
             if (method_exists($page, $action)) {
                 $page->{$action}($request, $response);
             } else {
                 throw new LJL_Exception("The function of '{$action}' does not exist in class '{$controller}'!");
             }
         } else {
             foreach ($actionMap[$action] as $methodName) {
                 $methodName = 'do' . ucfirst($methodName);
                 if (method_exists($page, $methodName)) {
                     $page->{$methodName}($request, $response);
                 } else {
                     throw new LJL_Exception(' the function dose not exist:' . $methodName);
                 }
             }
         }
     }
     self::$_html = $response->display();
     $page->isCache() && self::setCache();
 }
示例#2
0
 public static function reset()
 {
     self::$_aProps = null;
 }