From c82157635356f5b9059178921a1c3fcdaabf560b Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 18 Jun 2013 00:31:08 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0pdf=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=B8=AD=E5=AF=B9=E5=BC=95=E7=94=A8=E6=96=B9=E5=BC=8F=E3=80=81?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/ServiceController.php | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index 09bee2dc..6128fa6b 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -374,10 +374,12 @@ class ServiceController extends Zend_Controller_Action if (!empty($uuid)) { $sql="select g.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.south,m.east,m.west,m.north,date(m.timebegin) as timebegin,date(m.timeend) as timeend,m.title_en,m.uuid,m.description,g.id,m.projection,t.filetype - from metadata m left join xml x on m.id=x.id left join thumbnail t on x.id=t.id + ,m.ts_published,d.doi as datadoi,d.authors,d.author_en,d.publisher,d.publisher_en, date_part('year',d.ts_published) as publish_year + from metadata m left join thumbnail t on m.id=t.id + left join datadoi d on d.uuid=m.uuid left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid); $row=$this->db->fetchRow($sql); - $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?"; + $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.reftype=0 and m.uuid=? order by m.place"; $sql=$this->db->quoteInto($sql,$uuid); $ref=$this->db->fetchAll($sql); $reference=""; @@ -386,6 +388,28 @@ class ServiceController extends Zend_Controller_Action $reference.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$refer['reference'])."\r\n"; } $row['reference']=$reference; + //判断是否使用多篇文献引用 + $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.reftype=3 and m.uuid=? order by m.place"; + $sql=$this->db->quoteInto($sql,$uuid); + $ref=$this->db->fetchAll($sql); + $reference=""; + foreach($ref as $k=>$refer) + { + $reference.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$refer['reference'])."\r\n"; + } + $row['mcitation']=$reference; + + //支持项目判断 + $sql="select f.* from fund f left join mdfund m on m.fid=f.id where m.uuid=? order by m.place"; + $sql=$this->db->quoteInto($sql,$uuid); + $ref=$this->db->fetchAll($sql); + $fund=""; + foreach($ref as $k=>$refer) + { + $fund.=($k+1).'. '.$refer['fund_type'].':'.str_replace(array("\r\n", "\n", "\r"),'',$refer['title']).'(编号:'.$refer['fund_id'].")\r\n"; + } + if (!empty($fund)) $row['suppinfo']=$fund; + $sql="select cc.name as category, cc.name_zh from metadata m left join category c on m.id=c.id left join categorycode cc on c.code=cc.code where m.uuid=".$this->db->quote($uuid); $cat=$this->db->fetchAll($sql); $row['category_zh']=''; @@ -426,10 +450,28 @@ class ServiceController extends Zend_Controller_Action $rs=$this->db->fetchRow($sql,array($row['projection'])); if ($rs) $projection=$rs['proj4text']; } - if (!empty($projection)) $row['projection']=$projection; - } else - $projection=''; - + if (!empty($projection)) $row['projection']=$projection; + $cit=''; + if ($row['mcitation']) + { + $cit=$row['mcitation']; + } else if ($row['citation']) + { + if (empty($row['datadoi'])) + { + $cit=$row['citation']; + } + elseif (!strpos($row['citation'],$row['datadoi'])) + { + $cit='文章引用:'.$row['citation']; + $cit.="\r\n数据的引用:"; + $cit.=substr($row['authors'],1,-1).'. '.$row['title'].'. '.$row['publisher'].', '.(empty($row['ts_published'])?$row['publish_year']:date('Y',strtotime($row['ts_published']))).'. doi:'.$row['datadoi']; + $cit.=' ['.str_replace('"','',substr($row['author_en'],1,-1)).'. '.$row['title_en'].'. '.$row['publisher_en'].', '.(empty($row['ts_published'])?$row['publish_year']:date('Y',strtotime($row['ts_published']))).'. doi:'.$row['datadoi'].']'; + } + } + $row['citation']=$cit; + } + $dom = new DOMDocument(); $dom->loadXML($row['data']); $xpath = new DOMXpath($dom);