253 lines
11 KiB
PHP
253 lines
11 KiB
PHP
<?php
|
|
namespace app\api\controller;
|
|
|
|
use think\Controller;
|
|
use think\Db;
|
|
|
|
class Base extends Controller
|
|
{
|
|
|
|
protected $user_obj = '';
|
|
protected $captcha_obj = '';
|
|
protected $article_obj = '';
|
|
protected $user_act_obj = '';
|
|
protected $admin_obj = '';
|
|
protected $user_reviewer_obj = '';
|
|
protected $journal_obj = '';
|
|
protected $reviewer_major_obj = '';
|
|
protected $reviewer_to_journal_obj = '';
|
|
protected $user_reviewer_info_obj = '';
|
|
protected $user_msg_obj = '';
|
|
protected $chief_to_journal_obj = '';
|
|
protected $board_to_journal_obj = '';
|
|
protected $reviewer_from_author_obj = '';
|
|
protected $article_author_obj = '';
|
|
protected $user_black_obj = '';
|
|
protected $user_to_special_obj = '';
|
|
protected $user_register_check_obj = '';
|
|
protected $user_cert_obj = '';
|
|
protected $apply_board_obj = '';
|
|
protected $apply_yboard_obj = '';
|
|
protected $user_score_log_obj = '';
|
|
protected $user_index_log_obj = '';
|
|
protected $article_reviewer_obj = '';
|
|
protected $user_ash_obj = '';
|
|
protected $major_obj = '';
|
|
protected $user_to_yboard_obj = '';
|
|
protected $user_author_obj = '';
|
|
protected $country_obj = '';
|
|
protected $user_log_obj = '';
|
|
protected $article_reviewer_question_obj = '';
|
|
protected $article_msg_obj = '';
|
|
protected $article_file_obj = '';
|
|
protected $article_transfer_obj = '';
|
|
protected $login_auto_obj = '';
|
|
protected $major_to_journal_obj = '';
|
|
protected $article_dialog_obj = '';
|
|
protected $article_proposal_obj = '';
|
|
protected $article_response_to_reviewer_obj = '';
|
|
protected $user_reviewer_recommend_obj = '';
|
|
protected $email_log_obj = '';
|
|
protected $email_template_obj = '';
|
|
protected $production_article_obj = '';
|
|
protected $company_top_obj = '';
|
|
protected $user_cv_obj = '';
|
|
protected $ts_obj = '';
|
|
protected $ts_refer_obj = '';
|
|
protected $ts_frag_obj = '';
|
|
protected $online_obj = '';
|
|
protected $article_reviewer_file_obj = '';
|
|
protected $production_article_author_obj = '';
|
|
protected $production_article_organ_obj = '';
|
|
protected $production_article_refer_obj = '';
|
|
protected $production_article_author_to_organ_obj = '';
|
|
protected $production_article_frag_obj = '';
|
|
|
|
public function __construct(\think\Request $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
$this->user_obj = Db::name('user');
|
|
$this->captcha_obj = Db::name('captcha');
|
|
$this->article_obj = Db::name('article');
|
|
$this->user_act_obj = Db::name('user_act');
|
|
$this->admin_obj = Db::name('admin');
|
|
$this->user_reviewer_obj = Db::name('user_reviewer_apply');
|
|
$this->journal_obj = Db::name('journal');
|
|
$this->reviewer_major_obj = Db::name('reviewer_major');
|
|
$this->reviewer_to_journal_obj = Db::name('reviewer_to_journal');
|
|
$this->user_reviewer_info_obj = Db::name('user_reviewer_info');
|
|
$this->user_msg_obj = Db::name('user_msg');
|
|
$this->chief_to_journal_obj = Db::name('chief_to_journal');
|
|
$this->board_to_journal_obj = Db::name('board_to_journal');
|
|
$this->reviewer_from_author_obj = Db::name('reviewer_from_author');
|
|
$this->article_author_obj = Db::name('article_author');
|
|
$this->user_black_obj = Db::name('user_black');
|
|
$this->user_to_special_obj = Db::name('user_to_special');
|
|
$this->user_register_check_obj = Db::name('user_register_check');
|
|
$this->user_cert_obj = Db::name('user_cert');
|
|
$this->apply_board_obj = Db::name('apply_board');
|
|
$this->apply_yboard_obj = Db::name('apply_yboard');
|
|
$this->user_score_log_obj = Db::name('user_score_log');
|
|
$this->user_index_log_obj = Db::name('user_index_log');
|
|
$this->article_reviewer_obj = Db::name('article_reviewer');
|
|
$this->user_ash_obj = Db::name('user_ash');
|
|
$this->major_obj = Db::name('major');
|
|
$this->user_to_yboard_obj = Db::name('user_to_yboard');
|
|
$this->country_obj = Db::name('country');
|
|
$this->user_log_obj = Db::name('user_log');
|
|
$this->article_reviewer_question_obj = Db::name('article_reviewer_question');
|
|
$this->article_msg_obj = Db::name('article_msg');
|
|
$this->article_file_obj = Db::name('article_file');
|
|
$this->article_transfer_obj = Db::name('article_transfer');
|
|
$this->login_auto_obj = Db::name('login_auto');
|
|
$this->major_to_journal_obj = Db::name('major_to_journal');
|
|
$this->article_dialog_obj = Db::name('article_dialog');
|
|
$this->article_proposal_obj = Db::name('article_proposal');
|
|
$this->article_response_to_reviewer_obj = Db::name('article_response_to_reviewer');
|
|
$this->user_reviewer_recommend_obj = Db::name('user_reviewer_recommend');
|
|
$this->email_log_obj = Db::name('email_log');
|
|
$this->email_template_obj = Db::name('email_template');
|
|
$this->production_article_obj = Db::name('production_article');
|
|
$this->company_top_obj = Db::name('company_top');
|
|
$this->user_cv_obj = Db::name('user_cv');
|
|
$this->ts_obj = Db::name('ts');
|
|
$this->ts_refer_obj = Db::name('ts_refer');
|
|
$this->ts_frag_obj = Db::name('ts_frag');
|
|
$this->online_obj = Db::name('online');
|
|
$this->article_reviewer_file_obj = Db::name('article_reviewer_file');
|
|
$this->production_article_obj = Db::name('production_article');
|
|
$this->production_article_author_obj = Db::name('production_article_author');
|
|
$this->production_article_organ_obj = Db::name('production_article_organ');
|
|
$this->production_article_refer_obj = Db::name('production_article_refer');
|
|
$this->production_article_author_to_organ_obj = Db::name('production_article_author_to_organ');
|
|
$this->production_article_frag_obj = Db::name('production_article_frag');
|
|
}
|
|
|
|
|
|
|
|
public function pdfAddProof($article_id)
|
|
{
|
|
$p_info = $this->production_article_obj->where('article_id', $article_id)->where('state', 0)->find();
|
|
vendor('fpdf.fpdf');
|
|
vendor('fpdi/fpdi');
|
|
$pdf = new \FPDI();
|
|
$pageCount = $pdf->setSourceFile(ROOT_PATH . 'public' . DS . $p_info['file_pdf']);
|
|
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
|
|
$templateId = $pdf->importPage($pageNo);
|
|
$size = $pdf->getTemplateSize($templateId);
|
|
if ($size['w'] > $size['h']) $pdf->AddPage('L', array($size['w'], $size['h']));
|
|
else $pdf->AddPage('P', array($size['w'], $size['h']));
|
|
$pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80);
|
|
$pdf->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80);
|
|
$pdf->useTemplate($templateId);
|
|
}
|
|
$pdf->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . '.pdf');
|
|
if ($p_info['file_sub'] != '' && substr($p_info['file_sub'], strripos($p_info['file_sub'], '.') + 1) == 'pdf') {
|
|
$pdf1 = new \FPDI();
|
|
$pageCount1 = $pdf1->setSourceFile(ROOT_PATH . 'public' . DS . "articleSUB" . DS . $p_info['file_sub']);
|
|
for ($pageNo = 1; $pageNo <= $pageCount1; $pageNo++) {
|
|
$templateId1 = $pdf1->importPage($pageNo);
|
|
$size = $pdf1->getTemplateSize($templateId1);
|
|
if ($size['w'] > $size['h']) $pdf1->AddPage('L', array($size['w'], $size['h']));
|
|
else $pdf1->AddPage('P', array($size['w'], $size['h']));
|
|
$pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 25, 80);
|
|
$pdf1->image(ROOT_PATH . 'public' . DS . 'pdf' . DS . 'bg2.png', 55, 155, 80);
|
|
$pdf1->useTemplate($templateId1);
|
|
}
|
|
$pdf1->Output(ROOT_PATH . 'public' . DS . 'proofPDF' . DS . $article_id . 'SUB.pdf');
|
|
}
|
|
}
|
|
|
|
public function createYboardCert($user_info,$journal_info,$start_time,$year){
|
|
if(!is_dir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'])){
|
|
mkdir(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id']);
|
|
}
|
|
$sj_num = rand(1000,9999);
|
|
$template = ROOT_PATH . 'public' . DS . 'cert' . DS . 'yboard_template.png';
|
|
$ziti = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'siyuan.ttf';
|
|
$ziti1 = ROOT_PATH . 'public' . DS . 'zhengshu' . DS . 'Georgia0.ttf';
|
|
$image = \think\Image::open($template);
|
|
$ys = date("F Y",$start_time)." to ".date("F Y",strtotime("+ ".$year." year",$start_time));
|
|
$image->text($user_info['realname'], $ziti, 45, '#000000', [1060, 750])
|
|
->text($ys, $ziti1, 32, '#C49A6C', [1370, 1015])
|
|
->text(date("Y.m.d",$start_time), $ziti, 25, '#000000', [500, 1280])
|
|
->text($journal_info['title'], $ziti1, 36, '#C49A6C', [860, 930])
|
|
->save(ROOT_PATH . 'public' . DS . 'cert' . DS .$journal_info['journal_id'].DS. $user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png');
|
|
return $journal_info['journal_id'].DS.$user_info['user_id'].'_yboard_'.date('Y',$start_time).$sj_num . '.png';
|
|
}
|
|
|
|
public function majorids($major_id){
|
|
$frag[]=$major_id;
|
|
$list = $this->major_obj->where('pid',$major_id)->select();
|
|
foreach($list as $v){
|
|
$cache = self::majorids($v['major_id']);
|
|
$frag = array_merge($frag,$cache);
|
|
}
|
|
return $frag;
|
|
}
|
|
|
|
|
|
public function getMajorShu($major){
|
|
if($major==0){
|
|
return '';
|
|
}
|
|
$res = $this->major_obj->where('major_id',$major)->find();
|
|
if($res['pid']==1){
|
|
return $res['major_id'];
|
|
}
|
|
|
|
$p = self::getMajorShu($res['pid']);
|
|
return $p.','.$res['major_id'];
|
|
}
|
|
|
|
public function getMajorStr($major_id)
|
|
{
|
|
$frag = '';
|
|
$major_info = $this->major_obj->where('major_id', $major_id)->find();
|
|
if ($major_info == null) {
|
|
return '';
|
|
}
|
|
if ($major_info['major_level'] == 1) {
|
|
return 'Medicine';
|
|
} else {
|
|
$frag = $this->getMajorStr($major_info['pid']) . ' > ' . $major_info['major_title'];
|
|
}
|
|
return $frag;
|
|
}
|
|
|
|
|
|
public function save_article_file($article_id, $user_id, $username, $url, $type_name)
|
|
{
|
|
//首先确定数据库里面是否存在此数据
|
|
$res = $this->article_file_obj->where(['file_url' => $url])->find();
|
|
if ($res) { //编辑的时候不能重复存储
|
|
return true;
|
|
} else if ($type_name == 'picturesAndTables' && trim($url) == '') {
|
|
return true;
|
|
} else if ($type_name == 'coverLetter' && trim($url) == '') {
|
|
return true;
|
|
} else if ($type_name == 'totalpage' && trim($url) == '') {
|
|
return true;
|
|
}
|
|
$insert_data['article_id'] = $article_id;
|
|
$insert_data['user_id'] = $user_id;
|
|
$insert_data['username'] = $username;
|
|
$insert_data['file_url'] = $url;
|
|
$insert_data['type_name'] = $type_name;
|
|
$insert_data['ctime'] = time();
|
|
return $this->article_file_obj->insertGetId($insert_data);
|
|
}
|
|
|
|
|
|
public function getArticleAuthors($article_id)
|
|
{
|
|
$res = $this->article_author_obj->where('article_id', $article_id)->where('state', 0)->select();
|
|
$frag = '';
|
|
foreach ($res as $v) {
|
|
$frag .= $v['firstname'] . $v['lastname'] . ',';
|
|
}
|
|
return substr($frag, 0, -1);
|
|
}
|
|
|
|
}
|
|
?>
|