2014-12-23 14:32:23 +00:00
|
|
|
<?php
|
2014-12-30 06:44:39 +00:00
|
|
|
namespace Westdc\Reference\Handler;
|
2014-12-23 14:32:23 +00:00
|
|
|
|
2014-12-30 06:44:39 +00:00
|
|
|
use Zend\EventManager\EventInterface;
|
|
|
|
use Westdc\Service\AbstractServiceManager;
|
2014-12-23 14:32:23 +00:00
|
|
|
|
|
|
|
//事件中存在的操作
|
2014-12-30 06:44:39 +00:00
|
|
|
class RisHandler extends AbstractServiceManager
|
2014-12-23 14:32:23 +00:00
|
|
|
{
|
|
|
|
private $db; //传入PDO对象误
|
|
|
|
private $config; //全局配置
|
|
|
|
|
2014-12-30 06:44:39 +00:00
|
|
|
private $table;
|
2014-12-23 14:32:23 +00:00
|
|
|
public $tbl_maillog = ""; //邮件日志表
|
|
|
|
|
|
|
|
function __construct($db = NULL)
|
|
|
|
{
|
2014-12-30 06:44:39 +00:00
|
|
|
$this->dbService = $this->getServiceManager()->get('Db');
|
|
|
|
$this->db = $this->dbService->getPdo();
|
2014-12-23 14:32:23 +00:00
|
|
|
|
2014-12-30 06:44:39 +00:00
|
|
|
$this->table = new \stdClass;
|
|
|
|
$this->table->reference = "reference";
|
|
|
|
$this->table->reference_author = "ref_author";
|
|
|
|
$this->table->reference_tag = "ref_tag";
|
2014-12-23 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//检查ris中的文献是否已经存在
|
2014-12-30 06:44:39 +00:00
|
|
|
public function checkRisReference(EventInterface $e)
|
2014-12-23 14:32:23 +00:00
|
|
|
{
|
|
|
|
$ref = $e->getParam('ref');
|
|
|
|
|
|
|
|
$wheresql = array();
|
|
|
|
|
|
|
|
if(preg_match("/\'/",$ref['title']))
|
|
|
|
{
|
|
|
|
$ref['title'] = preg_replace("/\'/","''",$ref['title']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$wheresql[] = " lower(title)=lower('{$ref['title']}') ";
|
|
|
|
$wheresql[] = " year='{$ref['year']}' ";
|
|
|
|
|
|
|
|
//暂时不使用期刊限制
|
|
|
|
/*if(isset($ref['publisher']))
|
|
|
|
{
|
|
|
|
$wheresql[] = " publisher='{$ref['publisher']}' ";
|
|
|
|
}*/
|
|
|
|
|
|
|
|
if(count($wheresql) > 0)
|
|
|
|
{
|
|
|
|
$wheresql = " WHERE ".join(" and ",$wheresql);
|
|
|
|
}else{
|
|
|
|
$wheresql = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql="select * from {$this->table->reference} $wheresql";
|
|
|
|
$sth=$this->db->query($sql);
|
|
|
|
$row=$sth->fetch();
|
|
|
|
$id=$row['id'];
|
|
|
|
|
|
|
|
if(!empty($row['id']))
|
|
|
|
{
|
|
|
|
return $id;
|
|
|
|
}else{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除作者
|
2014-12-30 06:44:39 +00:00
|
|
|
public function deleteAuthor(EventInterface $e)
|
2014-12-23 14:32:23 +00:00
|
|
|
{
|
|
|
|
$id = $e->getParam('id');
|
2014-12-30 06:44:39 +00:00
|
|
|
|
|
|
|
$sql = "DELETE FROM {$this->table->reference_author} WHERE id=$id ";
|
|
|
|
return $this->db->exec($sql);
|
2014-12-23 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
2014-12-30 06:44:39 +00:00
|
|
|
public function deleteTag(EventInterface $e)
|
2014-12-23 14:32:23 +00:00
|
|
|
{
|
|
|
|
$id = $e->getParam('id');
|
2014-12-30 06:44:39 +00:00
|
|
|
|
|
|
|
$sql = "DELETE FROM {$this->table->reference_tag} WHERE id=$id ";
|
|
|
|
return $this->db->exec($sql);
|
2014-12-23 14:32:23 +00:00
|
|
|
}
|
|
|
|
}
|