测试问题修改
This commit is contained in:
@@ -91,11 +91,11 @@ class Contribute extends Base
|
|||||||
return json_encode(['status' => 6,'msg' => 'The article title is empty']);
|
return json_encode(['status' => 6,'msg' => 'The article title is empty']);
|
||||||
}
|
}
|
||||||
//查询标题是否存在
|
//查询标题是否存在
|
||||||
$aWhere += ['title' => trim($aData['title']),'state' => ['<>',3]];
|
// $aWhere += ['title' => trim($aData['title']),'state' => ['<>',3]];
|
||||||
$aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
// $aArticle = Db::name('article')->field('article_id')->where($aWhere)->find();
|
||||||
if(!empty($aArticle)){
|
// if(!empty($aArticle)){
|
||||||
return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
|
// return json_encode(['code' => 7, 'msg' => 'Warning: you are re-submitting the article!']);
|
||||||
}
|
// }
|
||||||
//数据入库
|
//数据入库
|
||||||
$aData += $aParam;
|
$aData += $aParam;
|
||||||
$result = $this->_addData($aData);
|
$result = $this->_addData($aData);
|
||||||
@@ -132,7 +132,7 @@ class Contribute extends Base
|
|||||||
$sKeyWords = empty($aParam['keywords']) ? '' : $aParam['keywords'];
|
$sKeyWords = empty($aParam['keywords']) ? '' : $aParam['keywords'];
|
||||||
if(!empty($sKeyWords)){
|
if(!empty($sKeyWords)){
|
||||||
$aInsert['keywords'] = is_array($sKeyWords) ? implode(',', $sKeyWords) : $sKeyWords;
|
$aInsert['keywords'] = is_array($sKeyWords) ? implode(',', $sKeyWords) : $sKeyWords;
|
||||||
$aInsert['keywords'] = is_string($aInsert['keywords']) ? strip_tags($aInsert['keywords']) : '';
|
$aInsert['keywords'] = is_string($aInsert['keywords']) ? $aInsert['keywords'] : '';
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
//摘要
|
//摘要
|
||||||
@@ -205,11 +205,58 @@ class Contribute extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//作者单位
|
//处理作者
|
||||||
$iArticleId = empty($iArticleId) ? $iUpdateArticleId : $iArticleId;
|
$aCompanyId = $aAuthor = [];//作者机构ID
|
||||||
$aCompany = empty($aParam['company']) ? [] : $aParam['company'];
|
if(!empty($aParam['author'])){
|
||||||
|
$aAuthor = $aParam['author'];
|
||||||
|
foreach ($aAuthor as $key => $value) {
|
||||||
|
if(empty($iArticleId)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//处理作者名字
|
||||||
|
$aName = empty($value['name']) ? [] : explode(' ', $value['name']);
|
||||||
|
if(empty($aName)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//名字拆分
|
||||||
|
$sOldLastName = array_pop($aName);
|
||||||
|
$letters = [
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||||
|
'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||||
|
'o', 'p', 'q', 'r', 's', 't',
|
||||||
|
'u', 'v', 'w', 'x', 'y', 'z'
|
||||||
|
];
|
||||||
|
if(in_array(strtolower($sOldLastName), $letters)){
|
||||||
|
$value['company_id'] = [$sOldLastName];
|
||||||
|
$sLastName = array_pop($aName);
|
||||||
|
if(!empty($value['superscript'])){
|
||||||
|
$value['is_super'] = strpos($value['superscript'], '1') !== false ? 1 : 0;
|
||||||
|
$value['superscript'] = $sOldLastName.$value['superscript'];
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($aCompany)){
|
}else{
|
||||||
|
$sLastName = $sOldLastName;
|
||||||
|
}
|
||||||
|
$value['firstname'] = empty($aName) ? '' : trim(implode(' ', $aName));
|
||||||
|
if(empty($value['firstname'])){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(ctype_upper($value['firstname'][0]) == false){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$value['lastname'] = $sLastName;
|
||||||
|
$aAuthor[$key] = $value;
|
||||||
|
if(!empty($value['company_id'])){
|
||||||
|
$aCompanyId[] = implode(',', $value['company_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$aCompanyId = empty($aCompanyId) ? [] : array_unique(explode(',', implode(',', $aCompanyId)));
|
||||||
|
|
||||||
|
//文章机构
|
||||||
|
$iArticleId = empty($iArticleId) ? $iUpdateArticleId : $iArticleId;
|
||||||
|
if(!empty($aCompanyId)){
|
||||||
|
$aCompany = empty($aParam['company']) ? [] : $aParam['company'];
|
||||||
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
$aWhere = ['article_id' => $iArticleId,'state' => 0];
|
||||||
$aOrgan = Db::name('article_organ')->field('organ_id,organ_name,sort')->where($aWhere)->select();
|
$aOrgan = Db::name('article_organ')->field('organ_id,organ_name,sort')->where($aWhere)->select();
|
||||||
$aOrganName = empty($aOrgan) ? [] : array_column($aOrgan, 'organ_name');
|
$aOrganName = empty($aOrgan) ? [] : array_column($aOrgan, 'organ_name');
|
||||||
@@ -220,18 +267,16 @@ class Contribute extends Base
|
|||||||
if(empty($value)){
|
if(empty($value)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(!in_array($key, $aCompanyId)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$sName = trim(trim(trim($value,'*'),'#'));
|
$sName = trim(trim(trim($value,'*'),'#'));
|
||||||
if(in_array($sName, $aOrganName)){
|
if(in_array($sName, $aOrganName)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(empty($iMaxSort)){
|
|
||||||
$iSort = $key;
|
|
||||||
$aSort[$key] = $key;
|
|
||||||
}else{
|
|
||||||
$iMaxSort++;
|
$iMaxSort++;
|
||||||
$iSort = $iMaxSort;
|
$iSort = $iMaxSort;
|
||||||
$aSort[$key] = $iMaxSort;
|
$aSort[$key] = $iMaxSort;
|
||||||
}
|
|
||||||
$sName = is_string($sName) ? strip_tags($sName) : '';
|
$sName = is_string($sName) ? strip_tags($sName) : '';
|
||||||
if(empty($sName)){
|
if(empty($sName)){
|
||||||
continue;
|
continue;
|
||||||
@@ -250,8 +295,7 @@ class Contribute extends Base
|
|||||||
}
|
}
|
||||||
//处理作者
|
//处理作者
|
||||||
$aAuthorData = $aAuthorOrgn = [];
|
$aAuthorData = $aAuthorOrgn = [];
|
||||||
if(!empty($aParam['author'])){
|
if(!empty($aAuthor)){
|
||||||
$aAuthor = $aParam['author'];
|
|
||||||
//通讯作者
|
//通讯作者
|
||||||
$aCorresponding = empty($aParam['corresponding']) ? [] : array_column($aParam['corresponding'], null,'name');
|
$aCorresponding = empty($aParam['corresponding']) ? [] : array_column($aParam['corresponding'], null,'name');
|
||||||
//查询文章作者
|
//查询文章作者
|
||||||
@@ -260,19 +304,13 @@ class Contribute extends Base
|
|||||||
$aAuthorNameList = empty($aAuthorList) ? [] : array_column($aAuthorList, 'firstname');
|
$aAuthorNameList = empty($aAuthorList) ? [] : array_column($aAuthorList, 'firstname');
|
||||||
$iMaxSort = empty($aAuthorList) ? 0 : max(array_column($aAuthorList, 'sort'));
|
$iMaxSort = empty($aAuthorList) ? 0 : max(array_column($aAuthorList, 'sort'));
|
||||||
foreach ($aAuthor as $key => $value) {
|
foreach ($aAuthor as $key => $value) {
|
||||||
if(empty($iArticleId)){
|
//处理作者名
|
||||||
break;
|
if(empty($value['firstname'])){
|
||||||
}
|
continue;
|
||||||
//处理作者名字
|
}
|
||||||
$aName = empty($value['name']) ? [] : explode(' ', $value['name']);
|
if(ctype_upper($value['firstname'][0]) == false){
|
||||||
if(empty($aName)){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//名字拆分
|
|
||||||
$sLastName = array_pop($aName);
|
|
||||||
$value['firstname'] = empty($aName) ? '' : trim(implode(' ', $aName));
|
|
||||||
$value['lastname'] = $sLastName;
|
|
||||||
|
|
||||||
//处理作者机构单位关联
|
//处理作者机构单位关联
|
||||||
$aCountry = [];
|
$aCountry = [];
|
||||||
if(!empty($value['company_id'])){
|
if(!empty($value['company_id'])){
|
||||||
@@ -288,6 +326,7 @@ class Contribute extends Base
|
|||||||
if(!empty($sOrganName)){
|
if(!empty($sOrganName)){
|
||||||
$sOrganName = str_replace([', ',','], ',', $sOrganName);
|
$sOrganName = str_replace([', ',','], ',', $sOrganName);
|
||||||
$aOrganName = explode(',',$sOrganName);
|
$aOrganName = explode(',',$sOrganName);
|
||||||
|
|
||||||
$aCountry[] = empty($aOrganName) ? '' : strtolower(end($aOrganName));
|
$aCountry[] = empty($aOrganName) ? '' : strtolower(end($aOrganName));
|
||||||
}
|
}
|
||||||
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['firstname']];
|
$aAuthorOrgn[] = ['article_id' => $iArticleId,'organ_id' => $iOrgnId,'art_aut_id' => $value['firstname']];
|
||||||
@@ -320,10 +359,10 @@ class Contribute extends Base
|
|||||||
unset($value['name'],$value['company_id']);
|
unset($value['name'],$value['company_id']);
|
||||||
$iMaxSort++;
|
$iMaxSort++;
|
||||||
$value['sort'] = $iMaxSort;
|
$value['sort'] = $iMaxSort;
|
||||||
|
$value['country'] = empty($value['country']) ? '' : ucfirst(str_replace(['Pr '], '', $value['country']));
|
||||||
$aAuthorData[] = $value;
|
$aAuthorData[] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($aAuthorData)){
|
if(!empty($aAuthorData)){
|
||||||
$author_result = DB::name('article_author')->insertAll($aAuthorData);
|
$author_result = DB::name('article_author')->insertAll($aAuthorData);
|
||||||
if(empty($author_result)){
|
if(empty($author_result)){
|
||||||
|
|||||||
Reference in New Issue
Block a user