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();