#453, add bibtex citation support

This commit is contained in:
wlx 2013-05-14 10:03:27 +00:00
parent 6bf1971309
commit 753963a839
1 changed files with 46 additions and 0 deletions

View File

@ -1434,4 +1434,50 @@ class ServiceController extends Zend_Controller_Action
->setBody($ris);
}
}
//Bibtex format convert
function bibtexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid=$this->_request->getParam('uuid');
$lang=$this->_request->getParam('lang');
$bib='';
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);
$bib.='@article{'.$row['doi'].",\r\n";
$bib.=' author = '.str_replace('"','',$row['authors']).",\r\n";
$bib.=' journal = {'.$row['publisher']."},\r\n";
$bib.=' publisher = {'.$row['publisher']."},\r\n";
$bib.=' title = {'.$row['title']."},\r\n";
$bib.=' year = {'.date('Y',strtotime($row['ts_published']))."},\r\n";
$bib.=' month = {'.date('m',strtotime($row['ts_published']))."},\r\n";
$bib.=' url = {http://dx.doi.org/'.$row['doi']."},\r\n";
$bib.=' doi = {'.$row['doi']."}\r\n";
$bib.="}\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);
$bib.='@article{'.$row['doi'].",\r\n";
$bib.=' author = '.str_replace('"','',$row['author_en']).",\r\n";
$bib.=' journal = {'.$row['publisher_en']."},\r\n";
$bib.=' publisher = {'.$row['publisher_en']."},\r\n";
$bib.=' title = {'.$row['title']."},\r\n";
$bib.=' year = {'.date('Y',strtotime($row['ts_published']))."},\r\n";
$bib.=' month = {'.date('m',strtotime($row['ts_published']))."},\r\n";
$bib.=' url = {http://dx.doi.org/'.$row['doi']."},\r\n";
$bib.=' doi = {'.$row['doi']."}\r\n";
$bib.="}\r\n";
}
if (!empty($bib))
{
$this->getResponse()->setHeader('Content-Type', 'application/x-Bibtex')->setHeader('Content-Disposition','attachment; filename="'.$uuid.'.bib"')
//->setHeader('Content-Type','application/force-download')
->setBody($bib);
}
}
}