Exemplo n.º 1
0
 /**
  * 初始化
  * @param $type
  */
 public static function init($type)
 {
     if (is_object(self::$view)) {
         return self::$view;
     }
     if (!empty($type)) {
         $types = "\\System\\Library\\View\\" . ucfirst($type) . "\\" . ucfirst($type);
         self::$view = new $types();
         self::$config = \Application::$appConfig['view'][$type];
         $ro = \Application::$appLib['route'];
         self::$routeUrl = $ro::$routeUrl;
         //如果是管理员 找system 否则找对应设置的模板文件夹
         if (self::$routeUrl['module'] == "admin") {
             self::$config['template_dir'] = APP_TEMP_PATH . "/system";
             self::$isManagement = TRUE;
         } else {
             $tpl = getTplName();
             self::$config['template_dir'] = APP_TEMP_PATH . "/" . $tpl;
         }
         self::$view->init(self::$config);
     } else {
         return exception("模版解析模式不能为空!");
     }
 }
Exemplo n.º 2
0
 public static function halt($error)
 {
     $e = array();
     if (APP_DEBUG || IS_CGI) {
         //调试模式下输出错误信息
         if (!is_array($error)) {
             $trace = debug_backtrace();
             $e['message'] = $error;
             $e['file'] = $trace[0]['file'];
             $e['line'] = $trace[0]['line'];
             ob_start();
             debug_print_backtrace();
             $e['trace'] = ob_get_clean();
         } else {
             $e = $error;
         }
         if (IS_CGI) {
             exit($e['message'] . PHP_EOL . 'FILE: ' . $e['file'] . '(' . $e['line'] . ')' . PHP_EOL . $e['trace']);
         }
     } else {
         //否则定向到错误页面
         $error_page = C('error:error_page');
         if (!empty($error_page)) {
             if (true === isManagement()) {
                 redirect(ADMIM_TPLS_PATH . "/" . $error_page);
             } else {
                 $tpl = getTplName();
                 redirect(APP_TEMP_PATH . "/" . $tpl . "/" . $error_page);
             }
         } else {
             if (C('error:show_error_msg')) {
                 $e['message'] = is_array($error) ? $error['message'] : $error;
             } else {
                 $e['message'] = C('error:error_message');
             }
         }
     }
     // 包含异常页面模板
     $TMPL_EXCEPTION_FILE = C('debug:tmpl_exception_file');
     if (!$TMPL_EXCEPTION_FILE) {
         //显示在加载配置文件之前的程序错误
         exit('<b>Error:</b>' . $e['message'] . ' in <b> ' . $e['file'] . ' </b> on line <b>' . $e['line'] . '</b>');
     }
     include ADMIM_TPLS_PATH . "/" . $TMPL_EXCEPTION_FILE;
     exit;
 }
Exemplo n.º 3
0
 public function parseTemplate($template = '')
 {
     $tpl = getTplName();
     $tplFile = $tpl?$this->config['template_dir']."/".$tpl:$this->config['template_dir']."/".'default';
     return $this->template_dir."/".$tplFile."/".$template;
 }