diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index dc2c3a05..77723fda 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1387,7 +1387,7 @@ class ServiceController extends Zend_Controller_Action $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"; + $sql="select d.*,m.description,m.ts_published as publish_year 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))); $ris.='TY - JOUR'."\r\n"; @@ -1396,7 +1396,7 @@ class ServiceController extends Zend_Controller_Action { $ris.='A1 - '.$a."\r\n"; } - $ris.='Y1 - '.date('Y/m/d',strtotime($row['ts_published']))."\r\n"; + $ris.='Y1 - '.(empty($row['publish_year'])?date('Y/m/d',strtotime($row['ts_published'])):date('Y/m/d',strtotime($row['publish_year'])))."\r\n"; $ris.='JF - '.$row['publisher']."\r\n"; $ris.='JA - '.$row['publisher']."\r\n"; $ris.='UR - http://dx.doi.org/'.$row['doi']."\r\n"; @@ -1407,7 +1407,7 @@ class ServiceController extends Zend_Controller_Action } 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"; + $sql="select d.*,m.description,m.ts_published as publish_year 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))); $ris.='TY - JOUR'."\r\n"; @@ -1416,7 +1416,7 @@ class ServiceController extends Zend_Controller_Action { $ris.='A1 - '.$a."\r\n"; } - $ris.='Y1 - '.date('Y/m/d',strtotime($row['ts_published']))."\r\n"; + $ris.='Y1 - '.(empty($row['publish_year'])?date('Y/m/d',strtotime($row['ts_published'])):date('Y/m/d',strtotime($row['publish_year'])))."\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"; @@ -1443,30 +1443,30 @@ class ServiceController extends Zend_Controller_Action $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"; + $sql="select d.*,m.description,m.ts_published as publish_year 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('"','',str_replace(',',' and ',$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.=' year = {'.(empty($row['publish_year'])?date('Y',strtotime($row['ts_published'])):date('Y',strtotime($row['publish_year'])))."},\r\n"; + $bib.=' month = {'.(empty($row['publish_year'])?date('m',strtotime($row['ts_published'])):date('m',strtotime($row['publish_year'])))."},\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"; + $sql="select d.*,m.description,m.ts_published as publish_year 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('"','',str_replace(',',' and ',$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.=' year = {'.(empty($row['publish_year'])?date('Y',strtotime($row['ts_published'])):date('Y',strtotime($row['publish_year'])))."},\r\n"; + $bib.=' month = {'.(empty($row['publish_year'])?date('m',strtotime($row['ts_published'])):date('m',strtotime($row['publish_year'])))."},\r\n"; $bib.=' url = {http://dx.doi.org/'.$row['doi']."},\r\n"; $bib.=' doi = {'.$row['doi']."}\r\n"; $bib.="}\r\n";