From d16e677a2d39f9452bdf4e18b0ab1c21138ceda7 Mon Sep 17 00:00:00 2001 From: wlx Date: Sun, 1 Feb 2015 13:05:35 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=9D=E6=AD=A5=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=AE=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/ServiceController.php | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index e85882c8..b6510eda 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -755,6 +755,74 @@ class ServiceController extends Zend_Controller_Action $odf->exportAsAttachedFile($row['title'].'.odt'); } + + //用于制备三江源数据目录简要文件 + public function odtmdAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $uuid=$this->_request->getParam('uuid'); + $ac=$this->_request->getParam('ac'); + //error_reporting(1); + if (!empty($uuid)) + { + $sql="select g.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.ts_created,m.datatype, + 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,m.ts_published,d.doi as datadoi, + d.authors,d.publisher, 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 k.keyword, k.keytype from keyword k left join metadata m on k.id=m.id where m.uuid=? order by k.keytype"; + $sql=$this->db->quoteInto($sql,$uuid); + $keys=$this->db->fetchAll($sql); + $keyword=array(); + foreach($keys as $key) + { + @$keyword[$key['keytype']].=$key['keyword'].','; + } + $row['keyword']=$keyword; + } + require_once('odtphp/library/odf.php'); + $config["PATH_TO_TMP"]="/tmp/zip"; + $config["ZIP_PROXY"]="ZipArchive"; + $odf=new Odf("../data/metadata-template-simplemd.odt",$config); + $odf->setVars('title',$row['title'],true,'utf-8'); + @$odf->setVars('uuid',$row['uuid'],true,'utf-8'); + $odf->setVars('datetime',date('Y-m-d',strtotime($row['ts_created']))); + $odf->setVars('abstract',$row['description'],true,'utf-8'); + @$odf->setVars('theme_keyword',$row['keyword']['theme'],true,'utf-8'); + @$odf->setVars('place_keyword',$row['keyword']['place'],true,'utf-8'); + @$odf->setVars('temporal_keyword',empty($row['keyword']['temporal'])?'':$row['keyword']['temporal'],true,'utf-8'); + @$odf->setVars('discipline_keyword',$row['keyword']['discipline'],true,'utf-8'); + @$odf->setVars('filesize',$row['filesize'],true,'utf-8'); + @$odf->setVars('fileformat',$row['fileformat'],true,'utf-8'); + @$odf->setVars('timebegin',$row['timebegin'],true,'utf-8'); + @$odf->setVars('timeend',$row['timeend'],true,'utf-8'); + $cit=''; + if ($row['datadoi']) + { + $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']; + } else + { + $cit=$row['citation']; + } + @$odf->setVars('citation',$cit,true,'utf-8'); + //@$odf->setVars('reference',$row['reference'],true,'utf-8'); + //@$odf->setVars('doi',$row['doi'],true,'utf-8'); + @$odf->setVars('north',$row['north'],true,'utf-8'); + @$odf->setVars('south',$row['south'],true,'utf-8'); + @$odf->setVars('west',$row['west'],true,'utf-8'); + @$odf->setVars('east',$row['east'],true,'utf-8'); + @$odf->setVars('service',$row['datatype']?'在线下载':'离线申请',true,'utf-8'); + //@$odf->setImage('bigthumb', 'http://'.$_SERVER['SERVER_NAME'].'/service/bigthumb/uuid/'.$row['uuid']); + @$odf->setImage('thumb', 'http://'.$_SERVER['SERVER_NAME'].'/service/thumb/uuid/'.$row['uuid']); + @$odf->setImage('qrcode', 'http://'.$_SERVER['SERVER_NAME'].'/service/qrcode/uuid/'.$row['uuid']); + + $odf->exportAsAttachedFile($row['title'].'.odt'); + } function uploadAction(){ $this->_helper->layout()->disableLayout();