#452, add ris output support for doi published data

This commit is contained in:
wlx 2013-05-14 05:49:18 +00:00
parent f0eafe0bc3
commit 8a3358b054
1 changed files with 58 additions and 0 deletions

View File

@ -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);
}
}
}