文献管理中添加了批量上传功能和文件管理功能
This commit is contained in:
parent
f78bc77e7f
commit
3edc580c14
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
use Helpers\View as view;
|
||||
use Reference\Reference;
|
||||
use \Files\Files;
|
||||
|
||||
class Admin_DataController extends Zend_Controller_Action
|
||||
{
|
||||
|
@ -1137,6 +1138,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$this->_helper->viewRenderer('ref-add');
|
||||
$id = $this->_getParam('id');
|
||||
$attid = $this->_getParam('attid');
|
||||
|
||||
if(!empty($submit))
|
||||
{
|
||||
|
@ -1160,9 +1162,18 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
view::Post($this,$msg,"/admin/data/ref/ac/add");
|
||||
}
|
||||
}else{
|
||||
$this->view->data = array();
|
||||
if(!empty($id) && is_numeric($id))
|
||||
{
|
||||
$this->view->data = $reference->getOneReferenceData($id);
|
||||
}else{
|
||||
if(!empty($attid))
|
||||
{
|
||||
$files = new Files();
|
||||
$attfile = $files->getOne($attid);
|
||||
$this->view->data['attid'] = $attid;
|
||||
$this->view->data['file'] = $attfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1189,6 +1200,21 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
return true;
|
||||
}
|
||||
|
||||
//批量上传
|
||||
if($ac == "multiupload")
|
||||
{
|
||||
$this->_helper->viewRenderer('ref-multiupload');
|
||||
return true;
|
||||
}
|
||||
|
||||
//文件管理
|
||||
if($ac == "files")
|
||||
{
|
||||
$this->_helper->viewRenderer('ref-files');
|
||||
view::addPaginator($reference->getReferenceFiles(),$this,10);
|
||||
return true;
|
||||
}
|
||||
|
||||
}//文献管理 refAction()
|
||||
|
||||
/*
|
||||
|
|
|
@ -45,6 +45,12 @@ table thead tr th {background:#EBF2F6;}
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputYear">出版社/期刊</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="publisher" id="inputYear" class="input-block-level" value="<?= isset($this->data['publisher']) ? $this->data['publisher']:"" ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputReference">引用方式(前台显示)</label>
|
||||
<div class="controls">
|
||||
|
@ -58,7 +64,7 @@ table thead tr th {background:#EBF2F6;}
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputBibtex">完整引用方式</label>
|
||||
<label class="control-label" for="inputBibtex">bibtex</label>
|
||||
<div class="controls">
|
||||
<textarea name="bibtex" id="inputBibtex" class="input-block-level"><?= isset($this->data['bibtex']) ? $this->data['bibtex']:"" ?></textarea>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('后台管理');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('文献管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->theme->AppendPlus($this,'admin_plugin');
|
||||
?>
|
||||
<style>
|
||||
table thead tr th {background:#EBF2F6;}
|
||||
</style>
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div>
|
||||
<?= $this->partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?>
|
||||
</div>
|
||||
<div>
|
||||
<div class="input-append">
|
||||
<form id="datasearch" class="search_form" action="">
|
||||
<input type="text" id="keyword" name="q" value="<?php if(!empty($this->q)) echo $this->q; ?>" />
|
||||
<button type="submit" class="btn" id="search_btn">搜索</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<div id="datalist">
|
||||
<?php if (count($this->paginator)): ?>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>文件名</th>
|
||||
<th>状态</th>
|
||||
<th width="140">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<tr id="DataLine_<?= $item['id']?>">
|
||||
<td><?= $item['realname'] ?></td>
|
||||
<td><?= empty($item['attid']) ? '<font color="#CC0000">未编辑</font>':"已编辑" ?></td>
|
||||
<td>
|
||||
<a class="file-editor" href="/admin/data/ref/ac/add/<?= empty($item['attid']) ? 'attid/'.$item['id'] : 'id/'.$item['refid']?>">编辑</a>
|
||||
<a href="javascript:void(0);" onclick="file.delete(<?= $item['id']?>)" id="delbtn_<?= $item['id']?>">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
$(document).ready(function(e) {
|
||||
|
||||
});
|
||||
var file = {
|
||||
delete : function(id){
|
||||
if(confirm("是否确定删除?") == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/ref/ac/delete',
|
||||
'data':'attid=' + id,
|
||||
'success':function(data){
|
||||
if(typeof(data) == 'undefined')
|
||||
{
|
||||
alert("数据源错误,请联系管理员");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$.isEmptyObject(data.error))
|
||||
{
|
||||
alert(data.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#DataLine_'+id).fadeOut();
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
alert('附件删除出错');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('后台管理');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('文献管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->theme->AppendPlus($this,"uploadify");
|
||||
$this->theme->AppendPlus($this,'admin_plugin');
|
||||
?>
|
||||
<style>
|
||||
table thead tr th {background:#EBF2F6;}
|
||||
</style>
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div>
|
||||
<?= $this->partial('data/ref-nav.phtml',array('ac'=>$this->ac)); ?>
|
||||
</div>
|
||||
<?php if(!empty($this->error)) { ?>
|
||||
<?= $this->error ?>
|
||||
<?php } ?>
|
||||
<?php if(!empty($this->msg)) { ?>
|
||||
<?= $this->msg ?>
|
||||
<?php } else{ ?>
|
||||
<form class="form-horizontal" method="post">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputPassword">PDF</label>
|
||||
<div class="controls">
|
||||
<input type="file" name="Filedata" id="file_upload" />
|
||||
<div id="uploadedFile"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<a class="btn btn-primary" href="/admin/data/ref/ac/files">文件管理</a>
|
||||
</div>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
var _this = {
|
||||
SessionID : '<?php echo session_id(); ?>'
|
||||
};
|
||||
var uploader;
|
||||
var param;
|
||||
param = {
|
||||
"PHPSESSID" : _this.SessionID,
|
||||
};
|
||||
$(function() {
|
||||
$('#file_upload').uploadify({
|
||||
'swf' : '/js/lib/uploadify/uploadify.swf',
|
||||
'uploader' : '/admin/data/ref/ac/pdfupload',
|
||||
'multi' : true,
|
||||
'auto' : true,
|
||||
'fileTypeExts' : '*.pdf',
|
||||
'onUploadSuccess' : function(file, data, response) {
|
||||
upload.onsuccess(file, data, response);
|
||||
},
|
||||
'onUploadStart' : function(file) {
|
||||
$('#file_upload').uploadify('settings','formData',param);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var upload = {
|
||||
onsuccess : function(file, data, response){
|
||||
_data = $.parseJSON(data);
|
||||
if(!$.isEmptyObject(_data.error))
|
||||
{
|
||||
alert(_data.error);
|
||||
}else{
|
||||
$('#uploadedFile').append(upload.makeFileHtml(_data));
|
||||
}
|
||||
},
|
||||
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>'
|
||||
+ data.realname
|
||||
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
|
||||
+'</div>';
|
||||
},
|
||||
deleteFile : function(id){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/ref/ac/delete',
|
||||
'data':'attid=' + id,
|
||||
'success':function(data){
|
||||
if(typeof(data) == 'undefined')
|
||||
{
|
||||
alert("数据源错误,请联系管理员");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$.isEmptyObject(data.error))
|
||||
{
|
||||
alert(data.error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
alert('附件删除出错');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<?php if(isset($this->data['attid']) && !empty($this->data['attid'])){ ?>
|
||||
<input type="hidden" id="reference_file_content" value='<?= json_encode($this->data['file']) ?>' />
|
||||
<script>
|
||||
upload.onsuccess('',$('#reference_file_content').val(),"");
|
||||
</script>
|
||||
<?php } ?>
|
|
@ -171,4 +171,15 @@ class Reference
|
|||
return $row;
|
||||
}
|
||||
|
||||
//获得reference类型的附件
|
||||
public function getReferenceFiles()
|
||||
{
|
||||
$sql = "SELECT att.*,ref.attid,ref.id as refid FROM {$this->table->attachments} att
|
||||
LEFT JOIN {$this->table->reference} ref ON att.id=ref.attid
|
||||
WHERE att.filetype='reference'";
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue