This commit is contained in:
wangjinlei
2024-08-26 10:05:24 +08:00
parent 1f53c0419b
commit fb68d793d7
3 changed files with 160 additions and 1 deletions

View File

@@ -369,7 +369,7 @@ class Main extends Controller {
->select();
$list = array_merge($tmr_list,$bmec_list,$mdm_list);
$re['list'] = $list;
$re['list'] = strongArticleList($list);
return jsonSuccess($re);
}

View File

@@ -263,6 +263,12 @@ function strongArticleList($list){
$list[$k]['authortitle'] = getAuthor($v);
$list[$k]["mains"] = null;
$list[$k]['has_html'] = hasHtml($v['article_id']);
$list[$k]['stage_year'] = $stage_info['stage_year'];
$list[$k]['journal_short'] = $journal_info["jabbr"];
$list[$k]['journal_title'] = $journal_info['title'];
$list[$k]['stage_vol'] = $stage_info['stage_vol'];
$list[$k]['stage_no'] = $stage_info['stage_no'];
$list[$k]['usx'] = $journal_info['usx'];
}
//标题斜体

View File

@@ -33,6 +33,9 @@ class Datebase extends Controller
protected $db_obj = '';
protected $db_data_obj = '';
protected $article_author_to_organ_obj = "";
protected $article_organ_obj = '';
protected $ts_base_url = "http://ts.tmrjournals.cn/";
public function __construct(\think\Request $request = null)
@@ -54,6 +57,8 @@ class Datebase extends Controller
$this->journal_paper_art_obj = Db::name('journal_paper_art');
$this->db_obj = Db::name('db');
$this->db_data_obj = Db::name('db_data');
$this->article_author_to_organ_obj = Db::name('article_author_to_organ');
$this->article_organ_obj = Db::name("article_organ");
}
/**
@@ -229,6 +234,154 @@ class Datebase extends Controller
return jsonSuccess($re);
}
public function xmlCreateForArticle(){
$article_id = 3034;
$article_info = $this->article_obj->where("article_id",$article_id)->find();
$journal_info = $this->journal_obj->where("journal_id",$article_info['journal_id'])->find();
$xml = new \SimpleXMLElement('<article/>');
// 设置命名空间
$xml->addAttribute('xmlns:mml', 'http://www.w3.org/1998/Math/MathML');
$xml->addAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$xml->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->addAttribute('article-type', $article_info['type']);
// 创建 <front> 元素
$front = $xml->addChild('front');
// 创建 <journal-meta> 元素并添加子元素
$journalMeta = $front->addChild('journal-meta');
$journalMeta->addChild('journal-id', $journal_info['usx']);
$journalTitleGroup = $journalMeta->addChild('journal-title-group');
$journalTitleGroup->addChild('journal-title', $journal_info['title'])->addAttribute('xml:lang', 'en');
// $journalTitleGroup->addChild('journal-title', '刊名')->addAttribute('xml:lang', 'zh-Hans');
$journalTitleGroup->addChild('abbrev-journal-title', $journal_info['jabbr']);
$journalMeta->addChild('issn', $journal_info['issn'])->addAttribute('pub-type', 'ppub');
// $journalMeta->addChild('issn', 'CN')->addAttribute('pub-type', 'cn');
$publisher = $journalMeta->addChild('publisher');
$publisher->addChild('publisher-name', 'TMR publisher group');
$publisher->addChild('publisher-name', 'TMR')->addAttribute('specific-use', 'short-name');
// 创建 <article-meta> 元素并添加子元素
$articleMeta = $front->addChild('article-meta');
$articleMeta->addChild('article-id', $article_info['article_id']);
$articleMeta->addChild('article-id', $article_info['doi'])->addAttribute('pub-id-type', 'doi');
$articleCategories = $articleMeta->addChild('article-categories');
$subjGroup = $articleCategories->addChild('subj-group');
// $subjGroup->addChild('subject', '学科栏目信息')->addAttribute('xml:lang', 'zh-Hans');
$subjGroup->addChild('subject', 'subject')->addAttribute('xml:lang', 'en');
$articleTypeGroup = $articleCategories->addChild('subj-group');
$articleTypeGroup->addAttribute('id', 'article-type');
// $articleTypeGroup->addChild('subject', '文章类型')->addAttribute('xml:lang', 'zh-Hans');
$articleTypeGroup->addChild('subject', $article_info['type'])->addAttribute('xml:lang', 'en');
// 添加 <title-group> 元素
$titleGroup = $articleMeta->addChild('title-group');
$titleGroup->addChild('article-title', $article_info['title'])->addAttribute('xml:lang', 'en');
$transTitleGroup = $titleGroup->addChild('trans-title-group');
$transTitleGroup->addAttribute('xml:lang', 'en');
$transTitleGroup->addChild('trans-title', $article_info['title'])->addAttribute('xml:lang', 'en');
// 添加 <contrib-group> 和相关的 <contrib> 元素
$contribGroup = $articleMeta->addChild('contrib-group');
$authors = $this->article_author_obj->where("article_id",$article_id)->where("state",0)->select();
$organs = $this->article_organ_obj->where("article_id",$article_id)->select();
$os = [];
foreach ($organs as $k=>$v){
$os[$v['article_organ_id']] = $k+1;
}
foreach ($authors as $v){
$contrib_cache = $contribGroup->addChild('contrib');
$contrib_cache->addAttribute('contrib-type', 'author');
$nameAlternatives_cache = $contrib_cache->addChild('name-alternatives');
$name_cache = $nameAlternatives_cache->addChild("name");
$name_cache->addAttribute("name-style","western");
$name_cache->addAttribute("specific-use","en");
$name_cache->addAttribute("xml:lang","en");
$name_cache->addChild("surname",$v['first_name']);
$name_cache->addChild("given-names",$v['last_name']);
$l_c = $this->article_author_to_organ_obj->where("article_id",$article_id)->where("article_author_id",$v['article_author_id'])->where("state",0)->select();
foreach ($l_c as $val){
$xref_cache = $contrib_cache->addChild("xref");
$xref_cache->addAttribute("rid","aff".$os[$val['article_organ_id']]);
$xref_cache->addAttribute("xml:base","aff");
$xref_cache->addAttribute("xml:lang","en");
$xref_cache->addChild("sup",$os[$val['article_organ_id']]);
}
}
foreach ($organs as $v){
$affAl_cache = $contribGroup->addChild("aff-alternatives");
$affAl_cache->addAttribute("id","aff".$os[$v['article_organ_id']]);
$aff_cache = $affAl_cache->addChild("aff");
$aff_cache->addAttribute("xml:lang","en");
$aff_cache->addChild("label",$os[$v['article_organ_id']]." ".$v['organ_name']);
$ins_cache = $aff_cache->addChild("institution ",$v['organ_name']);
$ins_cache->addAttribute("content-type",'orgname');
}
//pub-date
$stage_info = $this->journal_stage_obj->where("journal_stage_id",$article_info['journal_stage_id'])->find();
$pubDate = $articleMeta->addChild("pub_date");
$pub_date_list = explode(" ",$article_info['pub_date']);
$pubDate->addChild("year",$pub_date_list[2]);
$pubDate->addChild("month",$pub_date_list[1]);
$vol = $articleMeta->addChild("volume",$stage_info['stage_vol']);
$vol->addAttribute("content-type","Vol.");
$issue = $articleMeta->addChild("issue",$article_info['npp']);
$issue->addAttribute("content-type","No.");
//abstract
// $abstract = $articleMeta->addChild("abstract ");
// $abstract->addAttribute("xml:lang","en");
// $abs_p = $abstract->addChild("p",$article_info['abstract']);
// $abs_p->addAttribute("indent","0mm");
//keywords
$kwd = $articleMeta->addChild("kwd-group");
$kwd->addAttribute("kwd-group-type","inspec");
$kwd->addAttribute("xml:lang","en");
$keywords_list = explode(";",$article_info['keywords']);
foreach ($keywords_list as $v){
if($v==""){
continue;
}
$kwd->addChild("kwd",trim($v));
}
//notes
$notes = $front->addChild("notes");
$notes_p = $notes->addChild("p");
$notes_p->addAttribute("ontent-type","qrcode");
$notes_p->addAttribute("xml:specific-use","website");
$url = "https://www.tmrjournals.com/article.html?J_num=".$journal_info['journal_id']."&a_id=".$article_info['article_id'];
$notes_p_uri = $notes_p->addChild("uri",htmlspecialchars($url));
$notes_p_uri->addAttribute("xlink:href",htmlspecialchars($url));
$notes_p1 = $notes->addChild("p");
$notes_p1->addAttribute("xml:specific-use","crossmark");
$notes_p1_uri = $notes_p1->addChild("uri");
$notes_p1_uri->addAttribute("xlink:href","http://crossmark.crossref.org/dialog/?doi=".$article_info['doi']);
// $name = $contrib->addChild('name');
// $name->addAttribute('name-style', 'eastern');
// $name->addAttribute('specific-use', 'zh-Hans');
// $name->addAttribute('xml:lang', 'zh-Hans');
// $name->addChild('surname', '姓');
// $name->addChild('given-names', '名');
// 示例只展示部分内容,完整生成对应的 XML 需要按文件结构依次添加其他元素
// 将生成的 XML 输出或保存
// echo $xml->asXML(); // 或者保存到文件,例如 $xml->asXML('output.xml');
$xml->asXML('d:/output.xml');
}
private function push_sftp($stage)
{
$stage_info = $this->journal_stage_obj->where('journal_stage_id',$stage)->find();