增加了数据作者中所有数据的查看视图,增加了附件更新功能
This commit is contained in:
parent
21118617c2
commit
335fc86d06
|
@ -7,6 +7,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$this->view->config = Zend_Registry::get('config');
|
||||
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
||||
$this->view->messages = $this->messenger->getMessages();
|
||||
$this->debug = 1;
|
||||
}
|
||||
function postDispatch()
|
||||
{
|
||||
|
@ -254,6 +255,8 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$search = $this->_getParam('search');
|
||||
$keyword = $this->_getParam('keyword');
|
||||
$att=$this->_getParam('att');
|
||||
$attupdate = $this->_getParam('attupdate');
|
||||
|
||||
|
||||
if ($delete)
|
||||
{
|
||||
|
@ -1245,6 +1248,7 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$uuid = $this->_request->getParam('uuid');
|
||||
$mdtitle = $this->_request->getParam('mdtitle');
|
||||
$mdattdel = $this->_request->getParam('mdattdel');
|
||||
$attupdate = $this->_getParam('attupdate');
|
||||
|
||||
if(!empty($uuid)&&!empty($mdtitle))
|
||||
{
|
||||
|
@ -1261,6 +1265,58 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
}
|
||||
}//附件添加
|
||||
|
||||
elseif($attupdate)
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$id = $this->_getParam('attupdate');
|
||||
|
||||
$files=new files();
|
||||
$msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],empty($uuid)?'file':'md');
|
||||
|
||||
if(empty($msg['error']))
|
||||
{
|
||||
$msg['error']="";
|
||||
$filename = $msg['db_path'];
|
||||
$filesize = $msg['file_size'];
|
||||
$filedesc = $this->_request->getParam('filedesc');
|
||||
$filetype = $msg['file_type'];
|
||||
$realname = $msg['realname'];
|
||||
|
||||
|
||||
$sql = "UPDATE attachments SET filename=?,filetype=?,filesize=?,realname=? WHERE id=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$ds = $sth->execute(array($filename,$filetype,$filesize,$realname,$id));
|
||||
|
||||
if($ds)
|
||||
{
|
||||
$msg['html'] = $realname.'['. round($filesize/1024,2) .' kb]';
|
||||
$msg['ok']= 1;
|
||||
echo Zend_Json::encode($msg);
|
||||
exit();
|
||||
}else{
|
||||
@unlink($filename);
|
||||
$data = array("error"=>'附件上传失败:写入附件表出错');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
@unlink($filename);
|
||||
$data = array("error"=>'附件上传失败:'.$msg['error']);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$data = array("error"=>"处理中出现错误".$id);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
|
||||
}//附件文件更新
|
||||
|
||||
else if($mdattdel)
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
$this->headScript()->appendFile('/static/js/jquery-1.7.2.min.js');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->headLink()->appendStylesheet('/static/js/uploadify/uploadify.css');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/swfobject.js');
|
||||
$this->headScript()->appendFile('/static/js/uploadify/jquery.uploadify.v2.1.4.min.js');
|
||||
$this->breadcrumb('数据管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
|
@ -54,6 +57,7 @@
|
|||
<td>'.$v['downtimes'].'</td>
|
||||
<td>'.date('Y-m-d H:i:s',strtotime($v['ts_created'])).'</td>
|
||||
<td>
|
||||
<a href="#fileUpdate" class="inline" onclick="update('.$v['id'].')">更新文件</a>
|
||||
<a href="javascript:;" onclick="delmdatt('.$v['id'].')">从此元数据中移除</a>
|
||||
<a href="/service/attach/id/'.$v['id'].'">下载</a>
|
||||
</td>
|
||||
|
@ -62,6 +66,16 @@
|
|||
?>
|
||||
</tbody></table>
|
||||
</div>
|
||||
<div style="display:none;">
|
||||
<form id="fileUpdate" method="post">
|
||||
<input type="hidden" id="id" name="id" value="" />
|
||||
<p>注:要更新的文件只能选择一个<br />
|
||||
<ul id="datalist"></ul>
|
||||
<input id="file_upload" name="Filedata" type="file" />
|
||||
<input type="button" class="btn btn-small btn-green" onclick="$('#file_upload').uploadifyUpload();" value="更改" />
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function delmdatt(id){
|
||||
$.ajax({
|
||||
|
@ -80,6 +94,38 @@ function delmdatt(id){
|
|||
'error': function(){Alert('处理中出现问题,请重试');}
|
||||
});
|
||||
}
|
||||
function update(id){
|
||||
$('#file_upload').uploadify({
|
||||
'uploader' : '/static/js/uploadify/uploadify.swf',
|
||||
'scriptData': {'PHPSESSID' : '<?php echo session_id(); ?>'},
|
||||
'script' : '/admin/data/attachments/attupdate/'+id,
|
||||
'folder' : '/uploads',
|
||||
'multi' : false,
|
||||
'auto' : false,
|
||||
'displayData' : 'speed',
|
||||
'buttonImg' : '/static/js/uploadify/selectfile.gif',
|
||||
'onComplete' : function(event, ID, fileObj, response, data) {
|
||||
var obj = jQuery.parseJSON(response);
|
||||
var html;
|
||||
if(obj.error=='')
|
||||
{html = obj.html;}else{html = obj.error;}
|
||||
$('<li/>', {
|
||||
"id":'uploadedItem_'+obj.attid,
|
||||
"class":'uploadifyQueueItem',
|
||||
"html": html
|
||||
}).appendTo('#datalist');
|
||||
if(obj.ok!=null)
|
||||
{
|
||||
Alert('文件修改成功!');
|
||||
setTimeout("window.location.href=window.location.href; ",2000);
|
||||
}
|
||||
},
|
||||
'onError' : function (event,ID,fileObj,errorObj) {
|
||||
alert(errorObj.type + ' Error: ' + errorObj.info);
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".inline").colorbox({inline:true,'innerWidth':'50%','innerHeight':'50%'});
|
||||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4>'+html+'</h4>'});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->author);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headLink()->appendStylesheet('/css/colorbox.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
|
||||
$this->breadcrumb('数据作者管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<!-- 左侧导航 -->
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
</div>
|
||||
<!-- //左侧导航 -->
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div id="rightPanel">
|
||||
<div id="tabs-controller">
|
||||
<ul>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/author">作者管理</a></li>
|
||||
<li class="box-shadow"><a class="text-shadow" href="/admin/data/author/ac/list">查看所有数据作者</a></li>
|
||||
<li class="box-shadow active"><a class="text-shadow" href="/admin/data/author/ac/datas">所有数据</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<p>请输入元数据标题关键字进行搜索</p>
|
||||
<form id="datasearch" class="search_form" action="/admin/data/author/ac/datas">
|
||||
<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 id="datalist">
|
||||
<?php
|
||||
if (count($this->paginator)):
|
||||
if ($this->mdtitle) echo "<h2>元数据:".$this->mdtitle."</h2>";
|
||||
echo "<ul>";
|
||||
$autoindex=0;
|
||||
foreach ($this->paginator as $item):
|
||||
$autoindex++;?>
|
||||
<li id="list_<?php echo $item['id'];?>">
|
||||
<p><a href="/data/<?php echo $item['uuid'];?>" target="_blank"><?php echo $item['title'];?></a> </p>
|
||||
<p>
|
||||
<?php if ($item['c']) : ?>
|
||||
作者数量 :<span id="sumAuthor_<?php echo $item['id'];?>"><?php echo $item['c']; ?></span> | <a href="/admin/data/author/ac/edit/uuid/<?php echo $item['uuid']; ?>/window/iframe" class="iframe">作者管理</a> |
|
||||
<?php endif; ?>
|
||||
<span id="addauthor_<?php echo $item['id'];?>"><a href="javascript:;" onclick="AddAuthor(<?php echo $item['id']; ?>,'<?php echo $item['uuid']; ?>')">添加作者</a></span>
|
||||
<?php if($item['c']):?>
|
||||
| <span id="sendmail_<?php echo $item['id'];?>"><a href="javascript:;" onclick="SendMail('<?php echo $item['uuid']; ?>')">发邮件</a></span>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</li>
|
||||
<?php endforeach;
|
||||
echo "</ul>";
|
||||
endif; ?>
|
||||
<div class="pagenavi"><?= $this->paginator; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
<script>
|
||||
function AddAuthor(id,uuid){
|
||||
$('#addauthor_'+id).html('用户名:<input type="text" id="authorInp_'+id+'"/><button class="btn btn-green" onclick="addAuthor('+id+',\''+uuid+'\')">添加</button>');
|
||||
}
|
||||
function addAuthor(id,uuid){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/author',
|
||||
'data':'ac=add&uuid='+uuid+'&username='+$('#authorInp_'+id).val(),
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{Alert(data.error);return false;}
|
||||
if(typeof(data.msg)!='undefined')
|
||||
{Alert(data.msg);}
|
||||
if(typeof(data.added)!='undefined')
|
||||
{$('#addauthor_'+id).html('<a href="javascript:;" onclick="AddAuthor('+id+',\''+uuid+'\')">添加作者</a>');}
|
||||
}
|
||||
else{
|
||||
Alert('出现错误,请稍后再试');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
|
||||
}
|
||||
});
|
||||
}
|
||||
function SendMail(uuid){
|
||||
$('#sendmail_'+id).html('');
|
||||
}
|
||||
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
|
||||
$(".inline").colorbox({inline:true, width:"50%"});
|
||||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue