/**
     * 错误列表显示
     *
     * @param string $message
     * @param code   $code
     */
    public function __construct($message = 0, $code = null)
    {
        if (_CLI_) {
            $file = $this->getFile();
            $line = $this->getLine();
            $now = date('Y-m-d H:i:s');
            $out = <<<EOF
==================================================================================
--                         Uncaught exception!
--时间:{$now}
--信息:{$message}
--代码:{$code}
--文件:{$file}
--行数:{$line}
==================================================================================

EOF;
            echo $out;
        } elseif (_DEV_) {
            $this->_viewer = Leb_View::getInstance();
            $this->_viewer->setLayoutPath('_template/layout/');
            $this->_viewer->setLayout('exception');
            $this->_viewer->setTemplate($this->_exceptionFile);
            $this->_viewer->title = '出错了!';
            $time = date('Y-m-d H:i:s', time());
            $this->_viewer->time = $time;
            $this->_viewer->message = $message;
            $this->_viewer->code = $code;
            $this->_viewer->file = $this->getFile();
            $this->_viewer->line = $this->getLine();
            $this->_viewer->run();
            Leb_Debuger::showVar();
        } elseif (defined('_ER_PAGE_')) {
            $this->_viewer = Leb_View::getInstance();
            $this->_viewer->setLayoutPath('_template/layout/');
            $this->_viewer->setLayout('exception');
            $this->_viewer->setTemplate(_ER_PAGE_);
            $this->_viewer->title = '出错了!';
            $time = date('Y-m-d H:i:s', time());
            $this->_viewer->time = $time;
            $this->_viewer->message = $message;
            $this->_viewer->code = $code;
            $this->_viewer->file = $this->getFile();
            $this->_viewer->line = $this->getLine();
            $this->_viewer->run();
            Leb_Debuger::showVar();
        }
        if (_RUNTIME_) {
            $now = time();
            $file = _RUNTIME_ . date('-Y-m-d', $now);
            $line = date('H:i:s') . "\t" . getClientIp() . "\r\n";
        }
    }
    /**
     * 重定向
     * @param string $msg 显示消息
     * @param string $url to Go
     * @param int $time 页面停留时间单位秒,0:页面不跳转
     *
     */
    public static function redirect($msg, $url, $time, $type = 'success')
    {
        $viewer = Leb_View::getInstance();
        $viewer->setTemplate('msg');
        $stay_time = $time * 1000;
        if (0 == $stay_time) {
            $viewer->direct_js = '';
        } else {
            if ('' == $url) {
                $viewer->direct_js = "setTimeout(\"history.go(-1);\",{$stay_time})";
            } else {
                $viewer->direct_js = "setTimeout(\"window.location.href ='{$url}';\",{$stay_time})";
            }
        }
        $url = empty($url) ? 'Javascript:window.history.back();' : $url;
        $class = $html = '';
        switch ($type) {
            case 'success':
                $class = 'fl zqicon';
                break;
            case 'error':
                $class = 'fl tsicon';
                break;
        }
        if ($class) {
            $html = <<<EOF
<div class="{$class}"></div>
<div class="fl ml10">
    <p class="f14 col_5">{$msg}</p>
    <p class="f14 col_1 fb mt5"><a href="{$url}">[马上跳转]</a></p>
</div>
EOF;
        }
        $viewer->needLayout(false);
        $viewer->title = '信息提示页';
        $viewer->message = $html;
        $viewer->run();
        die;
    }
Beispiel #3
0
 /**
  * 更改资源网址
  *
  * @param string $url
  */
 public static function asset($url)
 {
     $realPath = Leb_View::getEnvVar('resourceBase');
     if ($realPath == '/') {
         $realPath = '';
     }
     return $realPath . '/' . $url;
 }
Beispiel #4
0
 /**
  * 获得渲染器
  *
  */
 public function getViewer()
 {
     if (is_null($this->_viewer)) {
         $this->_viewer = Leb_View::getInstance();
         $this->setDefaultTemplate();
         $this->setDefaultLayoutBase();
     }
     return $this->_viewer;
 }
Beispiel #5
0
 /**
  * 设置页面 <title></title>
  *
  * @param string $title
  * @return void
  */
 public function addMoreString($str)
 {
     self::$_engine->assign('moreString', $str);
 }