实现pdf格式中对引用方式、支持项目的更新

This commit is contained in:
wlx 2013-06-18 00:31:08 +00:00
parent b626bfc7b8
commit c821576353
1 changed files with 48 additions and 6 deletions

View File

@ -374,10 +374,12 @@ class ServiceController extends Zend_Controller_Action
if (!empty($uuid)) 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 $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); left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid);
$row=$this->db->fetchRow($sql); $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); $sql=$this->db->quoteInto($sql,$uuid);
$ref=$this->db->fetchAll($sql); $ref=$this->db->fetchAll($sql);
$reference=""; $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"; $reference.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$refer['reference'])."\r\n";
} }
$row['reference']=$reference; $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); $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); $cat=$this->db->fetchAll($sql);
$row['category_zh']=''; $row['category_zh']='';
@ -426,10 +450,28 @@ class ServiceController extends Zend_Controller_Action
$rs=$this->db->fetchRow($sql,array($row['projection'])); $rs=$this->db->fetchRow($sql,array($row['projection']));
if ($rs) $projection=$rs['proj4text']; if ($rs) $projection=$rs['proj4text'];
} }
if (!empty($projection)) $row['projection']=$projection; if (!empty($projection)) $row['projection']=$projection;
} else $cit='';
$projection=''; 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 = new DOMDocument();
$dom->loadXML($row['data']); $dom->loadXML($row['data']);
$xpath = new DOMXpath($dom); $xpath = new DOMXpath($dom);