后台实现数据的DOI注册功能
This commit is contained in:
parent
fa515cbbdc
commit
f5d19529d3
|
@ -4189,28 +4189,14 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$this->view->uuid = $uuid;
|
||||
$this->view->data = $doi->view($uuid);
|
||||
include('data/Metadata.php');
|
||||
$md = new Metadata($this->db);
|
||||
$metadata = $md->view($uuid);
|
||||
if(empty($this->view->data))
|
||||
{
|
||||
$this->view->data = array(
|
||||
'uuid'=>$uuid,
|
||||
'title'=>$metadata['title'],
|
||||
'doi'=>$metadata['doi'],
|
||||
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
|
||||
'publisher'=>'三江源生态监测综合服务平台',
|
||||
'title_en'=>$metadata['title_en'],
|
||||
'publisher_en'=>'Ecological data platform for Sanjiangyuan National Nature Reserve',
|
||||
);
|
||||
$this->view->data=$doi->prepare($uuid);
|
||||
}else{
|
||||
$this->view->data['doi'] = $metadata['doi'];
|
||||
$md=$doi->prepare($uuid);
|
||||
$this->view->data['info'] = $doi->data_process_out($this->view->data);
|
||||
if(empty($this->view->data['ts_published']))
|
||||
{
|
||||
$this->view->data['title'] = $metadata['title'];
|
||||
$this->view->data['title_en'] = $metadata['title_en'];
|
||||
}
|
||||
$this->view->data['title'] = $md['title'];
|
||||
$this->view->data['title_en'] = $md['title_en'];
|
||||
}
|
||||
}else{
|
||||
$this->view->data = $doi->view($uuid);
|
||||
|
|
|
@ -35,39 +35,21 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<?php if ($this->mcitation) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>本数据要求的多篇文献引用</h4>
|
||||
<ol>
|
||||
<?php foreach($this->mcitation as $ref) :
|
||||
echo '<li>'.$ref->reference;
|
||||
echo '<a href="/knowledge/paper/id/'.$ref->id.'"><i class="icon-info-sign text-success"></i>查看</a>';
|
||||
if (empty($ref->link))
|
||||
{
|
||||
if(!empty($ref->attid))
|
||||
echo '<a href="/service/attach/id/'.$ref->attid.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}else{
|
||||
echo '<a href="'.$ref->link.'"><i class="icon-download text-success"></i>下载</a>';
|
||||
}
|
||||
echo "</li>";
|
||||
endforeach;
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php if ($md->citation) : ?>
|
||||
<?php if ($md->citation || $md->datadoi) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-quote-left muted"></i>本数据引用方式</h4>
|
||||
<p><?php if (empty($md->datadoi) || !strpos($md->citation,$md->datadoi)) : ?><span class="label label-info">文章的引用</span>
|
||||
<?php endif; echo $this->escape($md->citation);if (strpos($md->citation,$md->datadoi)) : ?>
|
||||
(下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)
|
||||
<?php endif; ?>
|
||||
<p><span class="label label-info">数据的引用</span>
|
||||
<?php
|
||||
if (!empty($md->datadoi)) :
|
||||
echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->datadoi;
|
||||
//echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']';
|
||||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> )
|
||||
<?php
|
||||
else :
|
||||
echo $md->citation;
|
||||
endif; ?>
|
||||
</p>
|
||||
<?php if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?>
|
||||
<p><span class="label label-info">数据的引用</span><?php
|
||||
echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi;
|
||||
echo ' ['.str_replace('"','',substr($md->author_en,1,-1)).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']';
|
||||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; if ($this->ref) : ?>
|
||||
<?php endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>相关文献(作者推荐)</h4>
|
||||
<ol>
|
||||
|
@ -312,8 +294,8 @@ foreach($this->keys as $cg) :
|
|||
echo '<li><a href="/data/tag/key/'.urlencode($cg['keyword']).'"><i class="icon-tag"></i>'.$cg['keyword'].'</a></li>';
|
||||
endforeach;
|
||||
?></ul>
|
||||
<?php if ($md->doi) : ?>
|
||||
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI:</span><?php echo $md->doi; ?></li></ul>
|
||||
<?php if ($md->datadoi) : ?>
|
||||
<ul class="well well-small inline unstyled"><li><span class="label label-success">数据DOI:</span><a href="http://dx.doi.org/<?php echo $md->datadoi; ?>"><?php echo $md->datadoi; ?></a></li></ul>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<hr />
|
||||
|
|
|
@ -25,9 +25,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
if(empty($uid))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." d where ".$wheresql."ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC";
|
||||
$sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." d where ".$wheresql."ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC";
|
||||
}else{
|
||||
$sql = "SELECT d.* FROM ".$this->tbl_doi." d
|
||||
$sql = "SELECT d.*,array_to_json(d.organization) as org_json,array_to_json(d.organization_en) as orgen_json FROM ".$this->tbl_doi." d
|
||||
LEFT JOIN mdauthor a ON d.uuid=a.uuid
|
||||
WHERE a.userid=".$uid." AND a.status>0 and ".$wheresql."
|
||||
ORDER BY d.ts_published desc,d.ts_submitted desc,d.ts_created DESC
|
||||
|
@ -39,12 +39,12 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
|
||||
function add($data){
|
||||
include_once("helper/dbh.php");
|
||||
$dbh = new dbh($this->db);
|
||||
$this->data_process_in($data);
|
||||
//include_once("helper/view.php");
|
||||
//view::Dump($data);
|
||||
return $dbh->insert($this->tbl_doi,$data);
|
||||
$sql="insert into ".$this->tbl_doi." (doi,authors,organization,publisher,uuid,url,title,title_en,publisher_en,author_en,organization_en) values('".
|
||||
$data['doi']."','".$data['authors']."',array[".$data['organization']."],'".$data['publisher']."','".$data['uuid'].
|
||||
"','".$data['url']."','".$data['title']."','".$data['title_en']."','".$data['publisher_en']."','".$data['author_en'].
|
||||
"',array[".$data['organization_en']."])";
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
function update($data,$uuid,$uid=0){
|
||||
|
@ -73,7 +73,11 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
}else{
|
||||
$condition = " uuid='$uuid' ";
|
||||
}
|
||||
$state = $dbh->update($this->tbl_doi,$data,$condition,true);
|
||||
$sql="update $this->tbl_doi set doi='".$data['doi']."',uuid='".$data['uuid']."',publisher='".$data['publisher']."',
|
||||
url='".$data['url']."',title='".$data['title']."',title_en='".$data['title_en']."',publisher_en='".$data['publisher_en']."',
|
||||
authors='".$data['authors']."',author_en='".$data['author_en']."',organization=array[".$data['organization']."],
|
||||
organization_en=array[".$data['organization_en']."] where ".$condition;
|
||||
$state=$this->db->exec($sql);
|
||||
|
||||
if( $state == true)
|
||||
{
|
||||
|
@ -91,15 +95,19 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
$orgs_en = array();
|
||||
foreach($data['info'] as $k=>$v)
|
||||
{
|
||||
$authors[$v['order']] = str_replace(",",",",$v['author']);
|
||||
$orgs[$v['order']] = str_replace(",",",",$v['organization']);
|
||||
$authors_en[$v['order']] = str_replace(",",",",$v['author_en']);
|
||||
$orgs_en[$v['order']] = str_replace(",",",",$v['organization_en']);
|
||||
$authors[(int)$v['order']] = $v['author'];
|
||||
$orgs[(int)$v['order']] = $v['organization'];
|
||||
$authors_en[(int)$v['order']] = $v['author_en'];
|
||||
$orgs_en[(int)$v['order']] = $v['organization_en'];
|
||||
}
|
||||
ksort($authors);
|
||||
ksort($orgs);
|
||||
ksort($authors_en);
|
||||
ksort($orgs_en);
|
||||
$authors = "{".join(",",$authors)."}";
|
||||
$orgs = "{".join(",",$orgs)."}";
|
||||
$orgs = "'".join("','",$orgs)."'";
|
||||
$authors_en = "{".join(",",$authors_en)."}";
|
||||
$orgs_en = "{".join(",",$orgs_en)."}";
|
||||
$orgs_en = "'".join("','",$orgs_en)."'";
|
||||
$data['authors'] = $authors;
|
||||
$data['organization'] = $orgs;
|
||||
$data['author_en'] = $authors_en;
|
||||
|
@ -109,9 +117,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
|
||||
function data_process_out(&$data){
|
||||
$authors = $this->array_split($data['authors']);
|
||||
$orgs = $this->array_split($data['organization']);
|
||||
$orgs = json_decode($data['org_json']);
|
||||
$authors_en = $this->array_split($data['author_en']);
|
||||
$orgs_en = $this->array_split($data['organization_en']);
|
||||
$orgs_en = json_decode($data['orgen_json']);
|
||||
$info = array();
|
||||
foreach($authors as $k=>$v)
|
||||
{
|
||||
|
@ -120,18 +128,13 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
'organization'=>str_replace("\"","",$orgs[$k]),
|
||||
'author_en'=>str_replace("\"","",$authors_en[$k]),
|
||||
'organization_en'=>str_replace("\"","",$orgs_en[$k]),
|
||||
'order'=> count($authors)+($k-1)
|
||||
'order'=> count($authors)+$k
|
||||
);
|
||||
}
|
||||
//include_once("helper/view.php");
|
||||
//view::Dump($info);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function array_split($a){
|
||||
/*$a = str_replace("{",'',$a);
|
||||
$a = str_replace("}",'',$a);
|
||||
$a = explode(",",$a); */
|
||||
return explode(',',substr($a,1,-1));
|
||||
}
|
||||
|
||||
|
@ -139,9 +142,9 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
{
|
||||
if(is_numeric($id))
|
||||
{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE id=$id";
|
||||
$sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." WHERE id=$id";
|
||||
}else{
|
||||
$sql = "SELECT * FROM ".$this->tbl_doi." WHERE uuid='$id'";
|
||||
$sql = "SELECT *,array_to_json(organization) as org_json,array_to_json(organization_en) as orgen_json FROM ".$this->tbl_doi." WHERE uuid='$id'";
|
||||
}
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
|
@ -247,4 +250,49 @@ class Doi extends Zend_Controller_Plugin_Abstract
|
|||
}
|
||||
}
|
||||
|
||||
//为未注册DOI的数据准备初始信息
|
||||
function prepare($uuid)
|
||||
{
|
||||
$sql="select substring(doi from 'sjy.(.*).db') as max from datadoi where doi like '10.3972/sjy.%.db' order by doi desc limit 1";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if ($row)
|
||||
{
|
||||
$i=(int)$row['max'];
|
||||
$i++;
|
||||
$doi='10.3972/sjy.'.sprintf("%'.03d",$i).'.db';
|
||||
} else
|
||||
$doi='10.3972/sjy.001.db';
|
||||
|
||||
$sql="select m.uuid,m.title,m.title_en,m.ts_published,res.organisation from metadata m left join role r on m.uuid=r.uuid left join responsible res on r.resid=res.id where r.role='resourceProvider' and m.uuid='$uuid'";
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
if (!$row) return false;
|
||||
$org_english=array('青海省生态环境遥感监测中心'=>'Qinghai Remote Sensing Environmental Monitoring Center',
|
||||
'青海省环境监测中心站'=>'Qinghai Environmental Monitoring Center',
|
||||
'青海省气象科学研究所'=>'Qinghai Institute of Meteorological Science',
|
||||
'青海省草原总站'=>'',
|
||||
'青海省水土保持局'=>'',
|
||||
'青海省林业调查规划院'=>'',
|
||||
'青海省水文水资源勘测局'=>'');
|
||||
|
||||
$info = array(
|
||||
'author'=>str_replace("\"","",$row['organisation']),
|
||||
'organization'=>str_replace("\"","",$row['organisation']),
|
||||
'author_en'=>str_replace("\"","",$org_english[$row['organisation']]),
|
||||
'organization_en'=>str_replace("\"","",$org_english[$row['organisation']]),
|
||||
'order'=> 1
|
||||
);
|
||||
|
||||
$result = array('uuid'=>$uuid,
|
||||
'title'=>$row['title'],
|
||||
'doi'=>$doi,
|
||||
'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid,
|
||||
'publisher'=>'三江源生态监测综合服务平台',
|
||||
'title_en'=>$row['title_en'],
|
||||
'publisher_en'=>'Ecological data platform for Sanjiangyuan National Nature Reserve',
|
||||
'info'=>array($info),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue