1
This commit is contained in:
@@ -46,6 +46,8 @@ class Publish extends Base
|
||||
"doi" => "require",
|
||||
"journal_name" => "require",
|
||||
"article_name" => "require",
|
||||
"author"=>"require",
|
||||
"vol"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
@@ -57,6 +59,8 @@ class Publish extends Base
|
||||
$pra['doi'] = $data['doi'];
|
||||
$pra['journal_name'] = $data['journal_name'];
|
||||
$pra['article_name'] = $data['article_name'];
|
||||
$pra['author'] = $data['author'];
|
||||
$pra['vol'] = $data['vol'];
|
||||
$pra['factor'] = isset($data['factor'])?$data['factor']:0;
|
||||
$pra['is_china'] = isset($data['is_china'])?$data['is_china']:0;
|
||||
$pra['is_wos'] = isset($data['is_wos'])?$data['is_wos']:0;
|
||||
@@ -78,12 +82,73 @@ class Publish extends Base
|
||||
}
|
||||
$url = 'http://journalapi.tmrjournals.com/public/index.php/master/Article/editArticleCite';
|
||||
$pra = [];
|
||||
$pra['article_id'] = $data['article_id'];
|
||||
$pra['article_cite_id'] = $data['article_cite_id'];
|
||||
$pra['factor'] = isset($data['factor'])?$data['factor']:0;
|
||||
$pra['is_china'] = isset($data['is_china'])?$data['is_china']:0;
|
||||
$pra['is_wos'] = isset($data['is_wos'])?$data['is_wos']:0;
|
||||
object_to_array(json_decode(myPost($url, $pra)));
|
||||
return jsonSuccess([]);
|
||||
$res = object_to_array(json_decode(myPost($url, $pra)));
|
||||
return jsonSuccess($res);
|
||||
}
|
||||
|
||||
|
||||
public function getArticleCites(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id" => "require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Article/getArticleCitesForSubmit";
|
||||
$pra = [];
|
||||
$pra['article_id'] = $data['article_id'];
|
||||
$res = object_to_array(json_decode(myPost($url, $pra)));
|
||||
$re['list'] = $res['data']["list"];
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
public function raboDataByDoi(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"doi"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$url = "https://doi.crossref.org/openurl/";
|
||||
$pra['pid'] = "books@tmrjournals.com";
|
||||
$pra['id'] = trim($data['doi']);
|
||||
$pra['noredirect'] = true;
|
||||
$r = xml_to_array(myGetParam($url,$pra));
|
||||
|
||||
|
||||
if(isset($r["crossref_result"]["query_result"]["body"]['query']["article_title"])){
|
||||
$flag = $r["crossref_result"]["query_result"]["body"]['query'];
|
||||
$flag['author'] = formateAuthor(isset($r["crossref_result"]["query_result"]["body"]['query']['contributors']['contributor'])?$r["crossref_result"]["query_result"]["body"]['query']['contributors']['contributor']:null);
|
||||
$flag['vol'] = formateVol($r["crossref_result"]["query_result"]["body"]['query']);
|
||||
return jsonSuccess($flag);
|
||||
}else{
|
||||
return jsonError("not find");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delArticleCite(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_cite_id" => "require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
|
||||
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Article/delArticleCiteForSubmission";
|
||||
$pra['article_cite_id'] = $data['article_cite_id'];
|
||||
$re = object_to_array(json_decode(myPost($url, $pra)));
|
||||
|
||||
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +211,7 @@ class Publish extends Base
|
||||
$pra = [];
|
||||
$pra['article_id'] = $data['article_id'];
|
||||
$res = object_to_array(json_decode(myPost($url, $pra)));
|
||||
return jsonSuccess([]);
|
||||
return jsonSuccess($res);
|
||||
}
|
||||
|
||||
public function getArticleMains(){
|
||||
|
||||
@@ -491,6 +491,94 @@ function myGet($url)
|
||||
}
|
||||
}
|
||||
|
||||
function formateVol($v){
|
||||
$flag = "";
|
||||
if(isset($v['year'])) {
|
||||
$flag .= $v['year']." ";
|
||||
}
|
||||
if(isset($v['volume'])) {
|
||||
$flag .= $v['volume']." ";
|
||||
}
|
||||
if(isset($v['first_page'])) {
|
||||
$flag .= $v['first_page']." ";
|
||||
}
|
||||
if(isset($v['item_number'])&&!isset($v['first_page'])) {
|
||||
$flag .= $v['item_number']." ";
|
||||
}
|
||||
if(isset($v['issue'])) {
|
||||
$flag .= $v['issue']." ";
|
||||
}
|
||||
return trim($flag);
|
||||
}
|
||||
|
||||
function formateAuthor($list){
|
||||
$flag = '';
|
||||
if (count($list)<=3){
|
||||
foreach ($list as $v){
|
||||
$flag .= $v['given_name']." ".$v['surname'].", ";
|
||||
}
|
||||
$flag = trim(trim($flag),",");
|
||||
}else{
|
||||
for ($i=0;$i<3;$i++){
|
||||
$flag .= $list[$i]['given_name']." ".$list[$i]['surname'].", ";
|
||||
}
|
||||
$flag .= "et al";
|
||||
}
|
||||
|
||||
return $flag;
|
||||
}
|
||||
|
||||
|
||||
function xml_to_array($xml)
|
||||
{
|
||||
$reg = "/<(\\w+)[^>]*?>([\\x00-\\xFF]*?)<\\/\\1>/";
|
||||
if(preg_match_all($reg, $xml, $matches))
|
||||
{
|
||||
$count = count($matches[0]);
|
||||
$arr = array();
|
||||
for($i = 0; $i < $count; $i++)
|
||||
{
|
||||
$key = $matches[1][$i];
|
||||
$val = xml_to_array( $matches[2][$i] ); // 递归
|
||||
if(array_key_exists($key, $arr))
|
||||
{
|
||||
if(is_array($arr[$key]))
|
||||
{
|
||||
if(!array_key_exists(0,$arr[$key]))
|
||||
{
|
||||
$arr[$key] = array($arr[$key]);
|
||||
}
|
||||
}else{
|
||||
$arr[$key] = array($arr[$key]);
|
||||
}
|
||||
$arr[$key][] = $val;
|
||||
}else{
|
||||
$arr[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}else{
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function myGetParam($url,$params)
|
||||
{
|
||||
$query_string = http_build_query($params);
|
||||
$full_url = $url . '?' . $query_string;
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $full_url); // 设置请求URL
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 设置返回数据而不是直接输出
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 禁用SSL验证
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
echo 'Error:' . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
function my_doiToFrag($data)
|
||||
{
|
||||
$ts_refer_obj = Db::name('ts_refer');
|
||||
|
||||
Reference in New Issue
Block a user