westdc-zf1/application/module/Reference/Handler/RisHandler.php

91 lines
1.8 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Reference\Handler;
use \Helpers\View as view;
use \Helpers\dbh;
use \Helpers\Table;
use \Files\Files;
use \Reference\Reference;
//事件中存在的操作
class RisHandler implements \Reference\Event\RisEvent
{
private $db; //传入PDO对象误
private $config; //全局配置
public $table;
public $tbl_maillog = ""; //邮件日志表
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->table = new Table();
}
//检查ris中的文献是否已经存在
public function checkRisReference(\Zend_EventManager_Event $e)
{
$ref = $e->getParam('ref');
$wheresql = array();
if(preg_match("/\'/",$ref['title']))
{
$ref['title'] = preg_replace("/\'/","''",$ref['title']);
}
2013-11-01 09:14:13 +00:00
$wheresql[] = " lower(title)=lower('{$ref['title']}') ";
$wheresql[] = " year='{$ref['year']}' ";
2013-11-01 09:14:13 +00:00
//暂时不使用期刊限制
/*if(isset($ref['publisher']))
{
$wheresql[] = " publisher='{$ref['publisher']}' ";
2013-11-01 09:14:13 +00:00
}*/
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;
}
}
//删除作者
public function deleteAuthor(\Zend_EventManager_Event $e)
{
$id = $e->getParam('id');
$ref = new Reference();
return $ref->deleteReferenceAuthor($id);
}
public function deleteTag(\Zend_EventManager_Event $e)
{
$id = $e->getParam('id');
$ref = new Reference();
return $ref->deleteReferenceTag($id);
}
}