From 8a3358b0548f1961e48957da645a56574ef14d3d Mon Sep 17 00:00:00 2001 From: wlx Date: Tue, 14 May 2013 05:49:18 +0000 Subject: [PATCH] #452, add ris output support for doi published data --- .../default/controllers/ServiceController.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index 5abb15ae..0a93ec39 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1376,4 +1376,62 @@ class ServiceController extends Zend_Controller_Action ->setBody($footer); } + + //RIS format convert + function risAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $uuid=$this->_request->getParam('uuid'); + $lang=$this->_request->getParam('lang'); + $ris=''; + if ($lang=='cn' && !empty($uuid)) + { + $sql="select d.*,m.description from datadoi d left join metadata m on d.uuid=m.uuid where d.uuid='$uuid' and d.ts_published is not null"; + $row=$this->db->fetchRow($sql); + $authors=explode(',',str_replace('"','',substr($row['authors'],1,-1))); + $orgs=explode(',',str_replace('"','',substr($row['organization'],1,-1))); + $ris.='TY - JOUR'."\r\n"; + $ris.='T1 - '.$row['title']."\r\n"; + foreach($authors as $a) + { + $ris.='A1 - '.$a."\r\n"; + } + $ris.='Y1 - '.date('Y/m/d',strtotime($row['ts_published']))."\r\n"; + $ris.='JF - '.$row['publisher']."\r\n"; + $ris.='JA - '.$row['publisher']."\r\n"; + $ris.='UR - http://dx.doi.org/'.$row['doi']."\r\n"; + $ris.='PB - '.$row['publisher']."\r\n"; + $ris.='M3 - doi:'.$row['doi']."\r\n"; + $ris.='DO - doi:'.$row['doi']."\r\n"; + $ris.='ER -'."\r\n"; + } + else if ($lang=='en' && !empty($uuid)) + { + $sql="select d.*,m.description from datadoi d left join metadata m on d.uuid=m.uuid where d.uuid='$uuid' and d.ts_published is not null"; + $row=$this->db->fetchRow($sql); + $authors=explode(',',str_replace('"','',substr($row['author_en'],1,-1))); + $orgs=explode(',',str_replace('"','',substr($row['organization'],1,-1))); + $ris.='TY - JOUR'."\r\n"; + $ris.='T1 - '.$row['title_en']."\r\n"; + foreach($authors as $a) + { + $ris.='A1 - '.$a."\r\n"; + } + $ris.='Y1 - '.date('Y/m/d',strtotime($row['ts_published']))."\r\n"; + $ris.='JF - '.$row['publisher_en']."\r\n"; + $ris.='JA - '.$row['publisher_en']."\r\n"; + $ris.='UR - http://dx.doi.org/'.$row['doi']."\r\n"; + $ris.='PB - '.$row['publisher_en']."\r\n"; + $ris.='M3 - doi:'.$row['doi']."\r\n"; + $ris.='DO - doi:'.$row['doi']."\r\n"; + $ris.='ER -'."\r\n"; + } + if (!empty($ris)) + { + $this->getResponse()->setHeader('Content-Type', 'application/x-Research-Info-Systems')->setHeader('Content-Disposition','attachment; filename="'.$uuid.'.ris"') + //->setHeader('Content-Type','application/force-download') + ->setBody($ris); + } + } }