Example #1
0
 public static function output(Exception $error)
 {
     if (APP_DEBUG) {
         if (IS_AJAX) {
             Response::json($error->getMessage());
             exit;
         }
         include Config::get('TMPL_EXCEPTION_FILE');
         exit;
     } else {
         echo '程序异常,给您带来麻烦,非常抱歉!';
     }
     exit;
 }
Example #2
0
 /**
  * 将$this->vars解析成json输出,并结束程序
  *
  * @stability: 3
  * @param string|array|null $name
  * @param mixed|null $value
  * @return void
  */
 protected function json($name = null, $value = null)
 {
     if (!is_null($name)) {
         $this->assign($name, $value);
     }
     Response::json($this->vars);
 }
Example #3
0
 /**
  * Upload cover image and update 'coverpath'
  * 封面上传并写入主模型
  *
  * @return void
  */
 public function cover()
 {
     // 上传图片
     $info = Upload::image($_FILES['uploadify_file'], $this->cover_thumb_name);
     // 建立数据表
     $this->model->where(array('id' => $_POST['id']))->save(array('coverpath' => $info['name']));
     // 输出JSON
     Response::json($info);
 }