添加了多个上传自动提取文件名作为文献名称的功能,添加了文献删除的功能,优化页面跳转
This commit is contained in:
parent
579a204c0f
commit
8ab7186eab
|
@ -1167,10 +1167,11 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
if(!empty($id))
|
||||
{
|
||||
$msg = "文献修改成功!";
|
||||
view::Post($this,$msg,-2);
|
||||
}else{
|
||||
$msg = "文献添加成功!";
|
||||
view::Post($this,$msg,"/admin/data/ref/ac/add");
|
||||
}
|
||||
view::Post($this,$msg,"/admin/data/ref/ac/add");
|
||||
}
|
||||
}else{
|
||||
$this->view->data = array();
|
||||
|
@ -1196,7 +1197,12 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
$statu = $reference->uploadReferencePdf($_FILES['Filedata']);
|
||||
$autoread = false;
|
||||
if($this->_getParam('multi'))
|
||||
{
|
||||
$autoread = true;
|
||||
}
|
||||
$statu = $reference->uploadReferencePdf($_FILES['Filedata'],$autoread);
|
||||
$this->jsonexit($statu);
|
||||
return true;
|
||||
}
|
||||
|
@ -1226,6 +1232,19 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
return true;
|
||||
}
|
||||
|
||||
//删除文献
|
||||
if($ac == "deleteref")
|
||||
{
|
||||
$refid = $this->_getParam('id');
|
||||
if($reference->deleteReference($refid))
|
||||
{
|
||||
view::Post($this,"删除成功!",-1);
|
||||
}else{
|
||||
view::Post($this,"删除失败!",-1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}//文献管理 refAction()
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ var _this = {
|
|||
var uploader;
|
||||
var param;
|
||||
param = {
|
||||
"PHPSESSID" : _this.SessionID,
|
||||
"PHPSESSID" : _this.SessionID,
|
||||
"multi" : 'yes'
|
||||
};
|
||||
$(function() {
|
||||
$('#file_upload').uploadify({
|
||||
|
@ -80,7 +81,7 @@ var upload = {
|
|||
},
|
||||
makeFileHtml : function(data){
|
||||
return '<div class="alert alert-success">'
|
||||
+'<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
|
||||
//+'<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
|
||||
+ data.realname
|
||||
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
|
||||
+'</div>';
|
||||
|
|
|
@ -48,15 +48,29 @@ table thead tr th {background:#EBF2F6;}
|
|||
<?php $autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<tr id="DataLine_<?= $item['id']?>">
|
||||
<tr id="DataLine_<?= $item['id']?>">
|
||||
<?php if(!empty($item['title']) || !empty($item['year'])) { ?>
|
||||
|
||||
<td><?= $item['title'] ?></td>
|
||||
<td><?= $item['year'] ?></td>
|
||||
<td>
|
||||
<td rowspan="2">
|
||||
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
|
||||
<a href="javascript:void(0);" onclick="onedel(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
|
||||
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="2"><?= $item['reference'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if(empty($item['title']) && empty($item['year'])) { ?>
|
||||
<td colspan="2"><?= $item['reference'] ?></td>
|
||||
<td>
|
||||
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
|
||||
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
@ -67,96 +81,4 @@ table thead tr th {background:#EBF2F6;}
|
|||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
var info = {
|
||||
btn_prefix : "delbtn_",
|
||||
item_prefix : "DataLine_",
|
||||
url : "/admin/data/doi/ac/del"
|
||||
}
|
||||
$(document).ready(function(e) {
|
||||
$('.verified_btn').click(function(e) {
|
||||
$(this).ajaxmsg({
|
||||
callback:function(){window.location.reload();}
|
||||
});
|
||||
});
|
||||
});
|
||||
(function( $ ){
|
||||
|
||||
$.fn.ajaxmsg = function( options ) {
|
||||
|
||||
var settings = $.extend( {
|
||||
url:'',
|
||||
callback : '',
|
||||
}, options);
|
||||
|
||||
var methods = {
|
||||
msg : function(id)
|
||||
{
|
||||
methods.submited();
|
||||
},
|
||||
creatWindow : function(content){
|
||||
$.colorbox({
|
||||
initialHeight: '0',
|
||||
initialWidth: '0',
|
||||
html: methods.dialog(content),
|
||||
opacity: '0.3',
|
||||
onComplete: function(){
|
||||
$('.confirm_yes').click(function(e){
|
||||
e.preventDefault();
|
||||
if(typeof(settings.callback)=='function')
|
||||
{
|
||||
settings.callback();
|
||||
}
|
||||
$.colorbox.close();
|
||||
});
|
||||
$('.confirm_no').click(function(e){
|
||||
e.preventDefault();
|
||||
$.colorbox.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
submited : function(){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':settings.url,
|
||||
'data':'',
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{alert(data.error);}
|
||||
if(typeof(data.success)!='undefined')
|
||||
{
|
||||
methods.creatWindow(data.success);
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert('出现错误,请稍候再试');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
alert('出现错误,请刷新后重试');
|
||||
}
|
||||
});
|
||||
},
|
||||
dialog : function(content){
|
||||
HTML = '<div class=""><div class="modal-header"><h3>提示信息</h3></div>'
|
||||
+ '<div class="modal-body"><div class=" span5">'+content+'</div></div>'
|
||||
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">确定</a></div></div>';
|
||||
return HTML;
|
||||
}
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
settings.url = $(this).attr('rel');
|
||||
if(settings.url == '')
|
||||
{
|
||||
alert('参数错误');
|
||||
}
|
||||
methods.msg();
|
||||
});
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
</script>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
namespace Reference\Handler;
|
||||
|
||||
use Helpers\View as view;
|
||||
use Helpers\dbh;
|
||||
use \Helpers\View as view;
|
||||
use \Helpers\dbh;
|
||||
use \Helpers\Table;
|
||||
use \Files\Files;
|
||||
use \Reference\Reference;
|
||||
|
||||
//事件中存在的操作
|
||||
class ReferenceHandler implements \Reference\Event\ReferenceEvent
|
||||
|
@ -10,6 +13,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
|
|||
private $db; //传入PDO对象误
|
||||
private $config; //全局配置
|
||||
|
||||
public $table;
|
||||
public $tbl_maillog = ""; //邮件日志表
|
||||
|
||||
function __construct($db = NULL)
|
||||
|
@ -22,6 +26,7 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
|
|||
}
|
||||
|
||||
$this->config = \Zend_Registry::get('config');
|
||||
$this->table = new Table();
|
||||
}
|
||||
|
||||
public function checkReferenceParam(\Zend_EventManager_Event $e)
|
||||
|
@ -58,4 +63,27 @@ class ReferenceHandler implements \Reference\Event\ReferenceEvent
|
|||
return $data;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,7 @@ class ReferenceListener implements \Zend_EventManager_ListenerAggregate
|
|||
$Handler = new ReferenceHandler();
|
||||
$events->attach('submit.checkParam', array($Handler, 'checkReferenceParam'), 100);
|
||||
$events->attach('submit.processData', array($Handler, 'processReferenceData'), 100);
|
||||
$events->attach('upload.insertToReferenceTable', array($Handler, 'insertToReferenceTable'), 100);
|
||||
}
|
||||
|
||||
public function detach(\Zend_EventManager_EventCollection $events)
|
||||
|
|
|
@ -5,6 +5,7 @@ use \Helpers\View as view;
|
|||
use \Helpers\dbh;
|
||||
use \Reference\Listener\ReferenceListener;
|
||||
use \Files\Files;
|
||||
use \Search\Search;
|
||||
|
||||
class Reference
|
||||
{
|
||||
|
@ -13,6 +14,7 @@ class Reference
|
|||
|
||||
protected $events = NULL;
|
||||
public $table;
|
||||
public $keyword;
|
||||
|
||||
function __construct($db = NULL,$mail = NULL)
|
||||
{
|
||||
|
@ -84,19 +86,19 @@ class Reference
|
|||
{
|
||||
$request = new \Zend_Controller_Request_Http();
|
||||
$data = array(
|
||||
'reference'=>$request->getParam('reference'),
|
||||
'link'=>$request->getParam('link'),
|
||||
'publisher'=>$request->getParam('publisher'),
|
||||
'year' => $request->getParam('year'),
|
||||
'title' => $request->getParam('title'),
|
||||
'bibtex' => $request->getParam('bibtex'),
|
||||
'attid' => $request->getParam('attid')
|
||||
'reference' => trim($request->getParam('reference')),
|
||||
'link' => trim($request->getParam('link')),
|
||||
'publisher' => trim($request->getParam('publisher')),
|
||||
'year' => (int)$request->getParam('year'),
|
||||
'title' => trim($request->getParam('title')),
|
||||
'ris' => trim($request->getParam('ris')),
|
||||
'attid' => (int)$request->getParam('attid')
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
//上传文献PDF
|
||||
public function uploadReferencePdf($file)
|
||||
public function uploadReferencePdf($file,$autoread = false)
|
||||
{
|
||||
$files = new Files();
|
||||
$file_info = $files->upload($file,'literature/',true);
|
||||
|
@ -118,12 +120,27 @@ class Reference
|
|||
$dbh = new dbh();
|
||||
|
||||
$file_id = $dbh->insert($this->table->attachments,$file_data,true);
|
||||
|
||||
$file_data['id'] = $file_id;
|
||||
|
||||
if($autoread)
|
||||
{
|
||||
$params = compact('file_data');
|
||||
$results = $this->events()->trigger('upload.insertToReferenceTable', $this, $params);
|
||||
$cache_data = $results->bottom();
|
||||
$file_data = array_merge($file_data,$cache_data);
|
||||
}
|
||||
|
||||
return $file_data;
|
||||
}
|
||||
|
||||
//通过文件名自动提取文章标题
|
||||
public function getReferenceTitleFromFilenName($filename)
|
||||
{
|
||||
$file = new Files();
|
||||
$title = str_replace( ".".$file->getFileTextExt($filename),"",$filename);
|
||||
return $title;
|
||||
}
|
||||
|
||||
//删除文献文件
|
||||
public function deleteReferenceAttchment($attid)
|
||||
{
|
||||
|
@ -146,6 +163,11 @@ class Reference
|
|||
//所有文献
|
||||
public function fetchReferences()
|
||||
{
|
||||
if(!empty($this->keyword))
|
||||
{
|
||||
$search = new Search();
|
||||
$keyword = $search->splitKeyword($this->keyword);
|
||||
}
|
||||
$sql = "SELECT * FROM {$this->table->reference} ORDER BY id DESC";
|
||||
$rs = $this->db->query($sql);
|
||||
return $rs->fetchAll();
|
||||
|
@ -154,8 +176,8 @@ class Reference
|
|||
//获取专题数据的文献
|
||||
public function fetchThemeReferences($code)
|
||||
{
|
||||
$sql="select distinct ref.* from mdref r left join reference ref on r.refid=ref.id
|
||||
left join datasource ds on r.uuid=ds.uuid left join source s on s.id=ds.sourceid
|
||||
$sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
|
||||
left join datasource ds on r.uuid=ds.uuid left join {$this->table->source} s on s.id=ds.sourceid
|
||||
where s.code='$code'
|
||||
order by ref.year,ref.title";
|
||||
$rs=$this->db->query($sql);
|
||||
|
@ -193,5 +215,22 @@ class Reference
|
|||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//删除文献
|
||||
public function deleteReference($id,$delete_att = false)
|
||||
{
|
||||
if(empty($id) || !is_numeric($id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if($delete_att == false)
|
||||
{
|
||||
$sql = "DELETE FROM {$this->table->reference} WHERE id=$id";
|
||||
return $this->db->exec($sql);
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue