/**
  * 新增补丁
  * @author 奕潇 <*****@*****.**>
  */
 public function addpack($title_old = '', $title = '', $sql = '', $des = '', $author = '')
 {
     if (IS_POST) {
         $aId = I('post.id', 0, 'intval');
         if ($aId != 0) {
             //编辑逻辑,取到原有数据
             $info = $this->getJsonFile($aId);
         }
         //dump($this->mPackPath . '/' . $aId . '.json');exit;
         $aTitle = I('post.title');
         $aDes = I('post.des');
         $aAuthor = I('post.author');
         $aSql = I('post.sql');
         if ($aSql == '') {
             $this->error('必须填写Sql语句。');
         }
         $info['title'] = $aTitle;
         $info['des'] = $aDes;
         $info['author'] = $aAuthor;
         if ($aId == 0) {
             //新增逻辑
             $time = time();
             if ($title == '') {
                 $title = $time;
             }
             $info['title'] = $title;
             $fh = $this->writeSql($sql, $time);
             $info['ctime'] = time();
             $info['mtime'] = '0';
             $fh = $this->writeJsonFile($time, $info);
             $this->success("新增补丁成功。");
         } else {
             $info['mtime'] = time();
             //打开文件
             $this->writeJsonFile($aId, $info);
             fclose($fh);
             $this->writeSql($aSql, $aId);
             $this->success("编辑补丁成功。");
             exit;
         }
     } else {
         $aId = I('get.id', 0, 'intval');
         if ($aId != 0) {
             $info = $this->getJsonFile($aId);
             $info['sql'] = $this->read_file($this->pack_sql_dir . '/' . $aId . '.sql');
         }
         $formBuilder = new AdminConfigBuilder();
         $formBuilder->title('新增补丁')->keyText('title', '补丁名称')->keyTextArea('des', '用途介绍')->keyTextArea('sql', 'sql语句')->keyText('author', '作者')->buttonSubmit();
         if ($aId != 0) {
             $info['id'] = $aId;
             $formBuilder->keyHidden('id');
         }
         $formBuilder->data($info);
         $formBuilder->display();
     }
 }
 /**
  * 新增补丁
  * @author 奕潇 <*****@*****.**>
  */
 public function addpack($title_old = '', $title = '', $sql = '', $des = '', $author = '')
 {
     if (IS_POST) {
         $aId = I('post.id', 0, 'intval');
         if ($aId != 0) {
             //编辑逻辑,取到原有数据
             $info = $this->getJsonFile($aId);
         }
         //dump($this->mPackPath . '/' . $aId . '.json');exit;
         $aTitle = I('post.title');
         $aDes = I('post.des');
         $aAuthor = I('post.author');
         $aSql = I('post.sql');
         if ($aSql == '') {
             $this->error(L('_SQL_STATEMENTS_MUST_BE_FILLED_OUT_'));
         }
         $info['title'] = $aTitle;
         $info['des'] = $aDes;
         $info['author'] = $aAuthor;
         if ($aId == 0) {
             //新增逻辑
             $time = time();
             if ($title == '') {
                 $title = $time;
             }
             $info['title'] = $title;
             $fh = $this->writeSql($sql, $time);
             $info['ctime'] = time();
             $info['mtime'] = '0';
             $fh = $this->writeJsonFile($time, $info);
             $this->success(L('_NEW_PATCH_SUCCESS_'));
         } else {
             $info['mtime'] = time();
             //打开文件
             $this->writeJsonFile($aId, $info);
             fclose($fh);
             $this->writeSql($aSql, $aId);
             $this->success(L('_EDIT_PATCH_SUCCESS_'));
             exit;
         }
     } else {
         $aId = I('get.id', 0, 'intval');
         if ($aId != 0) {
             $info = $this->getJsonFile($aId);
             $info['sql'] = $this->read_file($this->pack_sql_dir . '/' . $aId . '.sql');
         }
         $formBuilder = new AdminConfigBuilder();
         $formBuilder->title(L('_NEW_PATCH_'))->keyText('title', L('_PATCH_NAME_'))->keyTextArea('des', L('_INTRODUCTION_'))->keyTextArea('sql', L('_SQL_STATEMENT_'))->keyText('author', L('_AUTHOR_'))->buttonSubmit();
         if ($aId != 0) {
             $info['id'] = $aId;
             $formBuilder->keyHidden('id');
         }
         $formBuilder->data($info);
         $formBuilder->display();
     }
 }