2013-09-26 08:26:29 +00:00
|
|
|
<?php
|
|
|
|
namespace Reference\Handler;
|
|
|
|
|
2013-09-29 10:06:49 +00:00
|
|
|
use \Helpers\View as view;
|
|
|
|
use \Helpers\dbh;
|
|
|
|
use \Helpers\Table;
|
|
|
|
use \Files\Files;
|
|
|
|
use \Reference\Reference;
|
2013-09-26 08:26:29 +00:00
|
|
|
|
|
|
|
//事件中存在的操作
|
|
|
|
class ReferenceHandler implements \Reference\Event\ReferenceEvent
|
|
|
|
{
|
|
|
|
private $db; //传入PDO对象误
|
|
|
|
private $config; //全局配置
|
|
|
|
|
2013-09-29 10:06:49 +00:00
|
|
|
public $table;
|
2013-09-26 08:26:29 +00:00
|
|
|
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');
|
2013-09-29 10:06:49 +00:00
|
|
|
$this->table = new Table();
|
2013-09-26 08:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function checkReferenceParam(\Zend_EventManager_Event $e)
|
|
|
|
{
|
|
|
|
$data = $e->getParam('data');
|
|
|
|
|
|
|
|
if(!is_array($data))
|
|
|
|
{
|
|
|
|
return "参数错误";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($data["title"]))
|
|
|
|
{
|
|
|
|
return "请输入标题";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($data['reference']))
|
|
|
|
{
|
|
|
|
return "请输入前台引用方式,并且唯一";
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processReferenceData(\Zend_EventManager_Event $e)
|
|
|
|
{
|
|
|
|
$data = $e->getParam('data');
|
|
|
|
|
|
|
|
if(empty($data['attid']))
|
|
|
|
{
|
|
|
|
$data['attid'] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2013-09-29 10:06:49 +00:00
|
|
|
public function insertToReferenceTable(\Zend_EventManager_Event $e)
|
|
|
|
{
|
|
|
|
$att = $e->getParam('file_data');
|
|
|
|
|
|
|
|
$reference = new Reference();
|
|
|
|
$title = $reference->getReferenceTitleFromFilenName($att['realname']);
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'title'=>$title,
|
|
|
|
'attid'=>$att['id'],
|
|
|
|
'reference'=>$title.'---'.date("Y-m-d H:i:s").".".microtime().rand()
|
|
|
|
);
|
|
|
|
|
|
|
|
$dbh = new dbh();
|
|
|
|
|
|
|
|
$cache_data = array();
|
|
|
|
|
|
|
|
$cache_data['ref_id'] = $dbh->insert($this->table->reference,$data,true);
|
|
|
|
$cache_data['ref_title'] = $title;
|
|
|
|
|
|
|
|
return $cache_data;
|
|
|
|
}
|
|
|
|
|
2013-10-09 10:02:11 +00:00
|
|
|
public function checkMdrefParam(\Zend_EventManager_Event $e)
|
|
|
|
{
|
|
|
|
$data = $e->getParam('data');
|
|
|
|
|
|
|
|
if(!is_array($data))
|
|
|
|
{
|
|
|
|
return "参数错误";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($data["refid"]))
|
|
|
|
{
|
|
|
|
return "请填写文献ID";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($data['uuid']))
|
|
|
|
{
|
|
|
|
return "请填写UUID";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!view::isUuid($data['uuid']))
|
|
|
|
{
|
|
|
|
return "UUID格式不正确";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(empty($data['reftype']))
|
|
|
|
{
|
|
|
|
return "请选择文献类型";
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processMdrefData(\Zend_EventManager_Event $e)
|
|
|
|
{
|
|
|
|
$data = $e->getParam('data');
|
|
|
|
|
|
|
|
if(empty($data['place']))
|
|
|
|
{
|
|
|
|
$data['place'] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!is_numeric($data['place']))
|
|
|
|
{
|
|
|
|
$data['place'] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2013-09-26 08:26:29 +00:00
|
|
|
}
|