diff --git a/application/api/controller/Article.php b/application/api/controller/Article.php index 0f9de52..2a5e95d 100644 --- a/application/api/controller/Article.php +++ b/application/api/controller/Article.php @@ -1907,10 +1907,74 @@ class Article extends Base } - /**分解文章的图片和表格 - * @return void - */ - public function markArticleImgTab(){ + + +// public function markArticleTable(){ +// $data = $this->request->post(); +// $rule = new Validate([ +// "article_id"=>"require" +// ]); +// if(!$rule->check($data)){ +// return jsonError($rule->getError()); +// } +// $article_info = $this->article_obj->where("article_id",$data['article_id'])->find(); +// //处理word的图片内容 +// $files = $this->article_file_obj->where("article_id",$data['article_id'])->where("type_name","manuscirpt")->where("state",0)->order("ctime desc")->limit(1)->select(); +// $file = ''; +// if(isset($files[0])){ +// $file = $files[0]['file_url']; +// } +// $dir = ROOT_PATH."public/articleTable/".$article_info['accept_sn']; +// if (!is_dir($dir)) { +// mkdir($dir, 0777, true); +// } +// $article_info = $this->article_obj->where("article_id",$data['article_id'])->find(); +// $url = $this->ts_base_url."api/typeset/markTables"; +// $program['file'] = $file; +// $program['sn'] = $article_info['accept_sn']; +// $res = object_to_array(json_decode(myPost($url, $program))); +// if(!isset($res['data']['list'])){ +// return ; +// } +// $file_runs = $res['data']['list']; +// foreach ($file_runs as $v){ +// $insert['article_id'] = $data['article_id']; +// $insert['image'] = $article_info['accept_sn']."/".$v; +// $insert['ctime'] = time(); +// $this->article_image_obj->insert($insert); +// } +// +// } + + + + public function addArticleTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require", + "list"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + foreach ($data['list'] as $v){ + $insert['article_id'] = $data['article_id']; + if($v['type']==0){ + $insert['table'] = $data['table']; + $insert['html_data'] = $data['html_data']; + $insert['type'] = 0; + }else{ + $insert['type'] = 1; + $insert['url'] = $data['url']; + } + $insert['ctime'] = time(); + $this->article_table_obj->insert($insert); + } + return jsonSuccess([]); + } + + + public function reloadArticleTable(){ $data = $this->request->post(); $rule = new Validate([ "article_id"=>"require" @@ -1918,25 +1982,233 @@ class Article extends Base if(!$rule->check($data)){ return jsonError($rule->getError()); } - $article_info = $this->article_obj->where("article_id",$data['article_id'])->find(); - $files = $this->article_file_obj->where("article_id",$data['article_id'])->where("type_name","manuscirpt")->where("state",0)->order("ctme desc")->limit(1)->select(); + $this->article_table_obj->where("article_id",$data['article_id'])->update(['state'=>1]); + return jsonSuccess([]); + + } + + public function getArticleTable(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $tables = $this->article_table_obj->where("article_id",$data['article_id'])->where("state",0)->select(); + $re['list'] = $tables; + + return jsonSuccess($re); + } + + + + /**分解文章的图片和表格 + * @return void + */ + private function markArticleImage($article_id){ + $article_info = $this->article_obj->where("article_id",$article_id)->find(); + //处理word的图片内容 + $files = $this->article_file_obj->where("article_id",$article_id)->where("type_name","manuscirpt")->where("state",0)->order("ctime desc")->limit(1)->select(); + $file = ''; if(isset($files[0])){ $file = $files[0]['file_url']; } - $dir = ROOT_PATH."public/articleImage/".$article_info['accept_sn']; + $dir = ROOT_PATH."public/articleImage/".$article_id; if (!is_dir($dir)) { mkdir($dir, 0777, true); } - $url = $this->ts_base_url."api/typeset/markImages"; - $program['url'] = "https://submission.tmrjournals.com/public/".$files; - $program['sn'] = $article_info['accept_sn']; - $res = object_to_array(json_decode(myPost($url, $program))); - $file_runs = $res['list']; - return jsonSuccess($file_runs); + $this->markWord("https://submission.tmrjournals.com/public/".$file,$article_id); + //处理压缩包等等的内容 + $pics = $this->article_file_obj->where("article_id",$article_id)->where("type_name","picturesAndTables")->where("state",0)->select(); + foreach ($pics as $v){ + $extension = pathinfo($v['file_url'], PATHINFO_EXTENSION); + if($extension=="zip"){ + $this->markZip(ROOT_PATH."public/".$v['file_url'],$article_id); + } + } + return jsonSuccess([]); } + private function markZip($file,$article_id){ + $article_info = $this->article_obj->where("article_id",$article_id)->find(); + $zip = new \ZipArchive(); + // 打开 ZIP 文件 + if ($zip->open($file) === true) { + $fileCount = $zip->numFiles; + $num_rand = rand(1000,9999); + for ($i = 0; $i < $fileCount; $i++) { + $stat = $zip->statIndex($i); + $fileName = $stat['name']; + $fileContent = $zip->getFromIndex($i); + $base_url = ROOT_PATH."public/articleImage/".$article_id."/"; + $extension = pathinfo($fileName, PATHINFO_EXTENSION); + if($extension=="jpg"||$extension=="JPG"||$extension=="jpeg"){ + file_put_contents($base_url."zipimg".$num_rand.$i.".jpg", $fileContent); + $insert['article_id'] = $article_id; + $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".jpg"; + $insert['ctime'] = time(); + $this->article_image_obj->insert($insert); + }elseif ($extension=="png"){ + file_put_contents($base_url."zipimg".$num_rand.$i.".png", $fileContent); + $insert['article_id'] = $article_id; + $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".png"; + $insert['ctime'] = time(); + $this->article_image_obj->insert($insert); + }elseif ($extension=="tiff"){ + file_put_contents($base_url."zipimg".$num_rand.$i.".tiff", $fileContent); + $insert['article_id'] = $article_id; + $insert['image'] = $article_id."/"."zipimg".$num_rand.$i.".tiff"; + $insert['ctime'] = time(); + $this->article_image_obj->insert($insert); + }elseif ($extension=="docx"){ + $word_dir = ROOT_PATH."public/articleCache/".$article_id; + if (!is_dir($word_dir)) { + mkdir($word_dir, 0777, true); + } + $word_file = rand(1000,9999).$fileName; + file_put_contents($word_dir."/".$word_file, $fileContent); + $this->markWord("https://submission.tmrjournals.com/public/articleCache/".$article_id."/".$word_file,$article_id); + } + + } + + // 关闭 ZIP 文件 + $zip->close(); + + } else { + return json(['error' => 'Unable to open ZIP file.']); + } + } + + private function markWord($file,$article_id){ + $url = $this->ts_base_url."api/typeset/markImages"; + $program['file'] = $file; + $program['article_id'] = $article_id; + + $res = object_to_array(json_decode(myPost($url, $program))); + if(!isset($res['data']['list'])){ + return ; + } + $file_runs = $res['data']['list']; + foreach ($file_runs as $v){ + $insert['article_id'] = $article_id; + $insert['image'] = $article_id."/".$v; + $insert['ctime'] = time(); + $this->article_image_obj->insert($insert); + } + } + + + + public function getArticleImages(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $check = $this->article_image_obj->where("article_id",$data['article_id'])->where("state",0)->find(); + if(!$check){ + $this->markArticleImage($data['article_id']); + } + $list = $this->article_image_obj->where("article_id",$data['article_id'])->where("state",0)->select(); + $re['list'] = $list; + + return jsonSuccess($re); + } + + + public function reloadArticleImages(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $dir = ROOT_PATH."public".DS."articleImage".DS.$data['article_id']; + if (is_dir($dir)) { + $files = scandir($dir); + foreach ($files as $file) { + // 忽略"."和".."(代表当前目录和父级目录) + if ($file != '.' && $file != '..') { + $filePath = $dir . DS . $file; + // 如果是文件,则删除 + if (is_file($filePath)) { + unlink($filePath); + } + } + } + } + //清除数据库数据 + $this->article_image_obj->where("article_id",$data['article_id'])->update(['state'=>1]); + //重新获取 + $this->markArticleImage($data['article_id']); + return jsonSuccess([]); + } + + public function getArticleTables(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + $list = $this->article_table_obj->where("article_id",$data['article_id'])->where("state",0)->select(); + $re['list'] = $list; + + return jsonSuccess($re); + } + + + public function addArticleTable1(){ + $data = $this->request->post(); + $rule = new Validate([ + "article_id"=>"require", + "list"=>"require" + ]); + if(!$rule->check($data)){ + return jsonError($rule->getError()); + } + foreach ($data['list'] as $v){ + $insert['article_id'] = $data['article_id']; + $insert['table'] = $v['table']; + $insert['type'] = 0; + $insert['ctime'] = time(); + $this->article_table_obj->insert($insert); + } + return jsonSuccess([]); + } + +// public function reloadArticleTable(){ +// $data = $this->request->post(); +// $rule = new Validate([ +// "article_id"=>"require", +// "list"=>"require" +// ]); +// if(!$rule->check($data)){ +// return jsonError($rule->getError()); +// } +// //清除原数据 +// $this->article_table_obj->where("article_id",$data['article_id'])->update(['state'=>1]); +// //添加新数据 +// foreach ($data['list'] as $v){ +// $insert['article_id'] = $data['article_id']; +// $insert['table'] = $v['table']; +// $insert['type'] = 0; +// $insert['ctime'] = time(); +// $this->article_table_obj->insert($insert); +// } +// return jsonSuccess([]); +// } + + + /** * 编辑添加审稿实例(临时开启,为了补充审稿实例不够) @@ -3169,6 +3441,9 @@ class Article extends Base } } + + + /** * 添加推荐审稿人 */ diff --git a/application/api/controller/Base.php b/application/api/controller/Base.php index 11f1490..f314edc 100644 --- a/application/api/controller/Base.php +++ b/application/api/controller/Base.php @@ -75,7 +75,9 @@ class Base extends Controller protected $board_group_obj = ""; protected $committee_to_journal_obj = ''; protected $editor_to_journal_obj = ''; - protected $email_account_obj; + protected $email_account_obj=""; + protected $article_image_obj=""; + protected $article_table_obj=""; public function __construct(\think\Request $request = null) @@ -147,6 +149,8 @@ class Base extends Controller $this->committee_to_journal_obj = Db::name("committee_to_journal"); $this->editor_to_journal_obj = Db::name("editor_to_journal"); $this->email_account_obj = Db::name("email_account"); + $this->article_image_obj = Db::name("article_image"); + $this->article_table_obj = Db::name("article_table"); } diff --git a/application/api/controller/Reviewer.php b/application/api/controller/Reviewer.php index f15fe4a..30263b6 100644 --- a/application/api/controller/Reviewer.php +++ b/application/api/controller/Reviewer.php @@ -847,15 +847,17 @@ class Reviewer extends Base //验证字数 $content = $data['qu9contents']." ".$data['qu10contents']." ".$data['qu11contents']." ".$data['qu12contents']." ".$data['qu13contents']." ".$data['qu14contents']." ".$data['qu15contents']." ".$data['comment']; if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $content)>0){//含有中文 - if($journal_info['journal_id']==1){ - if(mb_strlen($content, 'UTF8')<150){ - return jsonError("We encourage you to enrich your comment further to help improve the peer paper (at least 150 words)."); - } - }else{ - if(mb_strlen($content, 'UTF8')<100){ - return jsonError("We encourage you to enrich your comment further to help improve the peer paper (at least 70 words)."); - } - } + + return jsonError("Cannot contain Chinese"); +// if($journal_info['journal_id']==1){ +// if(mb_strlen($content, 'UTF8')<150){ +// return jsonError("We encourage you to enrich your comment further to help improve the peer paper (at least 150 words)."); +// } +// }else{ +// if(mb_strlen($content, 'UTF8')<100){ +// return jsonError("We encourage you to enrich your comment further to help improve the peer paper (at least 70 words)."); +// } +// } }else{//不含中文 if($journal_info['journal_id']==1){ $carray = explode(" ", $content);