#495 修改了文件列表,添加了文件大小和时间的显示
This commit is contained in:
parent
6168aaafa4
commit
a12603a0de
|
@ -860,27 +860,48 @@ class ServiceController extends Zend_Controller_Action
|
|||
//不输出错误
|
||||
}//获取附件
|
||||
|
||||
//json 文件列表
|
||||
function filelistAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$uuid=$this->_request->getParam('uuid');
|
||||
$sql="select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.uuid=? and f.depth=1 and f.filename<>'/uuid.txt' order by f.isdir desc,f.filename";
|
||||
$files=$this->db->fetchAll($this->db->quoteInto($sql,$uuid));
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
echo Zend_Json::encode($files);
|
||||
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($files,JSON_NUMERIC_CHECK));
|
||||
return true;
|
||||
}
|
||||
|
||||
function subfilelistAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$uuid=$this->_request->getParam('uuid');
|
||||
$subpath=(int)$this->_request->getParam('subpath');
|
||||
$depth=(int)$this->_request->getParam('depth');
|
||||
$depth++;
|
||||
$sql="select f.filename,f.id,s.uuid,f.depth from datafile f,dataset s where s.id=f.dsid and s.uuid=? and f.depth=".$depth." and f.filename<>'/uuid.txt' and f.filename ilike (select filename from datafile where id=".$subpath.")||'%' order by f.isdir desc,f.filename";
|
||||
$sql="select f.* from datafile f,dataset s where s.id=f.dsid and s.uuid=? and f.depth=".$depth." and f.filename<>'/uuid.txt' and f.filename ilike (select filename from datafile where id=".$subpath.")||'%' order by f.isdir desc,f.filename";
|
||||
$files=$this->db->fetchAll($this->db->quoteInto($sql,$uuid));
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
echo Zend_Json::encode($files);
|
||||
|
||||
foreach($files as $k=>$v)
|
||||
{
|
||||
$files[$k]['ts_created'] = date("Y-m-d H:i",strtotime($v['ts_created']));
|
||||
$files[$k]['filesize'] = round($v['filesize']/1024,2) ."MB";
|
||||
$files[$k]['ext'] = "";
|
||||
$temp_arr = explode(".", $v['filename']);
|
||||
if($temp_arr)
|
||||
{
|
||||
$file_ext = array_pop($temp_arr);
|
||||
$file_ext = trim($file_ext);
|
||||
$files[$k]['ext'] = strtolower($file_ext);
|
||||
}
|
||||
}
|
||||
|
||||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($files,JSON_NUMERIC_CHECK));
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
?>
|
||||
<style>
|
||||
h3.gs_rt{font-size:110%;}
|
||||
#file-list li:hover {background-color: #f5f5f5;}
|
||||
#file-list li li:hover {background-color: #dedede;}
|
||||
#file-list li li li:hover {background-color: #eeeeee;}
|
||||
</style>
|
||||
<?php $md=$this->metadata;if ($md):?>
|
||||
<h3><?php echo $this->escape($md->title);
|
||||
|
@ -277,7 +280,7 @@ endforeach;
|
|||
<?php endif; ?>
|
||||
<div>
|
||||
<hr />
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" onclick="getFileList()" title=""><i class="icon-file"></i>文件列表</a></h4>
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" rel="<?= $md->uuid ?>"><i class="icon-file"></i>文件列表</a></h4>
|
||||
<ul class="inline unstyled well">
|
||||
<?php if ($md->fileformat) : ?>
|
||||
<li><strong>格式:</strong><?php echo $md->fileformat; ?></li>
|
||||
|
@ -450,6 +453,9 @@ $(function() {
|
|||
googleSearch('<?php echo $ev;?>');
|
||||
}
|
||||
});
|
||||
$('#show-list').click(function(e) {
|
||||
method.filelist.get($(this).attr('rel'));
|
||||
});
|
||||
});
|
||||
//ajax literature
|
||||
function literature(page){
|
||||
|
@ -466,10 +472,6 @@ function recommend(page){
|
|||
recommend_get(page,'<?= $md->uuid; ?>');
|
||||
}
|
||||
|
||||
function getFileList(){
|
||||
getFileList_h('<?php echo $md->uuid;?>');
|
||||
}
|
||||
|
||||
function ajaxpage(page){
|
||||
ajaxpage_get(page,'<?= $md->uuid; ?>');
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
<?= $this->render('breadcrumbs.phtml') ?>
|
||||
<style>
|
||||
h3.gs_rt{font-size:110%;}
|
||||
#file-list li:hover {background-color: #f5f5f5;}
|
||||
#file-list li li:hover {background-color: #dedede;}
|
||||
#file-list li li li:hover {background-color: #eeeeee;}
|
||||
</style>
|
||||
<?php $md=$this->metadata;if ($md):?>
|
||||
<div class="row">
|
||||
|
@ -301,7 +304,7 @@ endforeach;
|
|||
|
||||
<div>
|
||||
<hr />
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" onclick="getFileList()" title=""><i class="icon-file"></i>文件列表</a></h4>
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" rel="<?= $md->uuid ?>"><i class="icon-file"></i>文件列表</a></h4>
|
||||
<ul class="inline unstyled well">
|
||||
<?php if ($md->fileformat) : ?>
|
||||
<li><strong>格式:</strong><?php echo $md->fileformat; ?></li>
|
||||
|
@ -460,6 +463,9 @@ $(function() {
|
|||
googleSearch('<?php echo $ev;?>');
|
||||
}
|
||||
});
|
||||
$('#show-list').click(function(e) {
|
||||
method.filelist.get($(this).attr('rel'));
|
||||
});
|
||||
});
|
||||
//ajax literature
|
||||
function literature(page){
|
||||
|
@ -476,10 +482,6 @@ function recommend(page){
|
|||
recommend_get(page,'<?= $md->uuid; ?>');
|
||||
}
|
||||
|
||||
function getFileList(){
|
||||
getFileList_h('<?php echo $md->uuid;?>');
|
||||
}
|
||||
|
||||
function ajaxpage(page){
|
||||
ajaxpage_get(page,'<?= $md->uuid; ?>');
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
?>
|
||||
<style>
|
||||
h3.gs_rt{font-size:110%;}
|
||||
#file-list li:hover {background-color: #f5f5f5;}
|
||||
#file-list li li:hover {background-color: #dedede;}
|
||||
#file-list li li li:hover {background-color: #eeeeee;}
|
||||
</style>
|
||||
<?= $this->render('breadcrumbs.phtml'); ?>
|
||||
<?php $md=$this->metadata;if ($md):?>
|
||||
|
@ -42,6 +45,16 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
|||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-quote-left muted"></i>本数据引用方式<a class="btn btn-danger pull-right" href="/archives/help/dataplatformhelp/archive-23.html" ><i class="icon-comment"></i>数据引用帮助</a></h4>
|
||||
<p><?php if (empty($md->datadoi) || !strpos($md->citation,$md->datadoi)) : ?><span class="label label-info">文章的引用</span>
|
||||
<?php endif; echo $this->escape($md->citation);?></p>
|
||||
<?php if (!empty($md->datadoi) && !strpos($md->citation,$md->datadoi)) : ?>
|
||||
<p><span class="label label-info">数据的引用</span><?php
|
||||
echo substr($md->authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi;
|
||||
echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.$md->publish_year.'. doi:'.$md->doi.']';
|
||||
?> (下载引用:<a href="/service/ris/lang/cn/uuid/<?php echo $md->uuid; ?>">RIS格式</a> | <a href="/service/ris/lang/en/uuid/<?php echo $md->uuid; ?>">RIS英文格式</a> | <a href="/service/bibtex/lang/cn/uuid/<?php echo $md->uuid; ?>">Bibtex格式</a> | <a href="/service/bibtex/lang/en/uuid/<?php echo $md->uuid; ?>">Bibtex英文格式</a>)</p>
|
||||
<?php endif; endif; if ($this->ref) : ?>
|
||||
<hr />
|
||||
<h4><i class="icon-eye-open text-success"></i>建议参考文献</h4>
|
||||
<ol>
|
||||
<?php foreach($this->ref as $ref) :
|
||||
|
@ -277,7 +290,7 @@ endforeach;
|
|||
<?php endif; ?>
|
||||
<div>
|
||||
<hr />
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" onclick="getFileList()" title=""><i class="icon-file"></i>文件列表</a></h4>
|
||||
<h4>数据细节<a class="btn pull-right" href="javascript:void(0);" id="show-list" title="" rel="<?= $md->uuid;?>"><i class="icon-file"></i>文件列表</a></h4>
|
||||
<ul class="inline unstyled well">
|
||||
<?php if ($md->fileformat) : ?>
|
||||
<li><strong>格式:</strong><?php echo $md->fileformat; ?></li>
|
||||
|
@ -436,6 +449,9 @@ $(function() {
|
|||
googleSearch('<?php echo $ev;?>');
|
||||
}
|
||||
});
|
||||
$('#show-list').click(function(e) {
|
||||
method.filelist.get($(this).attr('rel'));
|
||||
});
|
||||
});
|
||||
//ajax literature
|
||||
function literature(page){
|
||||
|
|
|
@ -1,3 +1,75 @@
|
|||
var method = {};
|
||||
|
||||
method.filelist = {
|
||||
get : function(uuid){
|
||||
html ='<div id="window-outter">'
|
||||
+ '<div id="window-inner">'
|
||||
+ '<div id="window-content-container">'
|
||||
+ '<div id="window-loading"><div class="progress progress-striped active"><div class="bar" style="width:100%;"></div></div></div>'
|
||||
+ '<ol id="file-list">'
|
||||
+ '</ol>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+'</div>';
|
||||
$.colorbox({width:"80%",height:"80%",html:html});
|
||||
$.getJSON("/service/filelist/uuid/"+uuid, function(data) {
|
||||
items = method.filelist.makelist(data);
|
||||
$('#file-list').html(items.join(''));
|
||||
})
|
||||
.complete(function() {
|
||||
$('#window-loading').hide();
|
||||
});
|
||||
},
|
||||
getsub: function(uuid,id,depth){
|
||||
if($("#div_"+id).length>0)
|
||||
{
|
||||
$('#icon_'+id).attr('class','icon-folder-close-alt');
|
||||
$("#div_"+id).remove();
|
||||
return false;
|
||||
}else{
|
||||
$('#icon_'+id).attr('class','icon-folder-open-alt');
|
||||
}
|
||||
$('<div/>', {
|
||||
'style':'overflow:auto;',
|
||||
'id': 'div_'+id,
|
||||
"html": '<li><img src="/images/ajax-load-small.gif" />加载中</li>'
|
||||
}).appendTo('#li_'+id);
|
||||
url="/service/subfilelist/uuid/"+uuid+"/subpath/"+id+"/depth/"+depth;
|
||||
$.getJSON(url, function(data) {
|
||||
items = method.filelist.makelist(data);
|
||||
$("#div_"+id).html(items.join(''));
|
||||
}).complete(function(){
|
||||
if($("#div_"+id)){
|
||||
$('#span_'+id).html('-');
|
||||
}
|
||||
});
|
||||
},//sublist
|
||||
makelist : function(data)
|
||||
{
|
||||
items = [];
|
||||
$.each(data, function(key, val) {
|
||||
if(val['filename'].match(/\/$/))
|
||||
{
|
||||
html = '<li id="li_' + val['id'] + '">'
|
||||
+'<i class="icon-folder-close-alt" id="icon_'+val['id']+'"></i>'
|
||||
+'<a href="javascript:;" id="taget_'+val['id']+'" onclick="method.filelist.getsub(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a>'
|
||||
+'</li>'
|
||||
items.push(html);
|
||||
}else{
|
||||
html = '<li id="li_' + val['id'] + '">'
|
||||
+'<i class="icon-file" id="icon_'+val['id']+'"></i> '
|
||||
+ val['filename']
|
||||
+'<span class="pull-right" style="margin-left:15px;">[时间:'+val['ts_created']+']</span>'
|
||||
+'<span class="pull-right">[大小:'+val['filesize']+']</span>'
|
||||
'</li>';
|
||||
items.push(html);
|
||||
}
|
||||
});
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function literature_get(page,uuid){
|
||||
$.ajax({
|
||||
type:"GET",
|
||||
|
@ -48,37 +120,6 @@ function postcomment(){
|
|||
});
|
||||
}
|
||||
|
||||
function getSubFileList(uuid,id,depth){
|
||||
if($("#div_"+id).length>0)
|
||||
{
|
||||
$('#span_'+id).html('+');
|
||||
$("#div_"+id).remove();
|
||||
return false;
|
||||
}
|
||||
$('<div/>', {
|
||||
'style':'overflow:auto;',
|
||||
'id': 'div_'+id,
|
||||
"html": '<li><img src="/images/loading.gif" />加载中</li>'
|
||||
}).appendTo('#li_'+id);
|
||||
url="/service/subfilelist/uuid/"+uuid+"/subpath/"+id+"/depth/"+depth;
|
||||
$.getJSON(url, function(data) {
|
||||
var items = [];
|
||||
$.each(data, function(key, val) {
|
||||
if(val['filename'].match(/\/$/))
|
||||
{
|
||||
items.push('<li id="li_' + val['id'] + '"><span id="span_'+val['id']+'">+</span> <a href="javascript:;" id="taget_'+val['id']+'" onclick="getSubFileList(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a></li>');
|
||||
}else{
|
||||
items.push('<li id="' + key + '">' + val['filename'] + '</li>');
|
||||
}
|
||||
});
|
||||
$("#div_"+id).html(items.join(''));
|
||||
}).complete(function(){
|
||||
if($("#div_"+id)){
|
||||
$('#span_'+id).html('-');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function googleSearch(keyword){
|
||||
$.ajax({type:"POST",url:"/service/googlesearch",data:'q='+keyword,
|
||||
success:function(html){
|
||||
|
@ -195,39 +236,6 @@ function Alert(html){
|
|||
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
||||
}
|
||||
|
||||
function getFileList_h(uuid){
|
||||
html ='<div id="window-outter">'
|
||||
+ '<div id="window-inner">'
|
||||
+ '<div id="window-content-container">'
|
||||
+ '<div id="window-loading">加载中...</div>'
|
||||
+ '<ol id="file-list">'
|
||||
+ '</ol>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+'</div>';
|
||||
$.colorbox({width:"80%",height:"80%",html:html});
|
||||
$.getJSON("/service/filelist/uuid/"+uuid, function(data) {
|
||||
var items = [];
|
||||
if(data.length>0)
|
||||
{
|
||||
$.each(data, function(key, val) {
|
||||
if(val['filename'].match(/\/$/))
|
||||
{
|
||||
items.push('<li id="li_' + val['id'] + '"><span id="span_'+val['id']+'">+</span> <a href="javascript:;" id="taget_'+val['id']+'" onclick="getSubFileList(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a></li>');
|
||||
}else{
|
||||
items.push('<li id="li_' + val['id'] + '">' + val['filename'] + '</li>');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
items.push('<li>暂无数据</li>');
|
||||
}
|
||||
$('#file-list').html(items.join(''));
|
||||
})
|
||||
.complete(function() {
|
||||
$('#window-loading').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function ajaxpage_get(page,uuid){
|
||||
var url = "/data/comment/uuid/"+uuid;
|
||||
data='page='+page;
|
||||
|
|
Loading…
Reference in New Issue