优化文件列表显示

This commit is contained in:
wlx 2013-06-18 12:08:28 +00:00
parent a12603a0de
commit 1e05da7fbe
3 changed files with 44 additions and 21 deletions

View File

@ -867,8 +867,23 @@ class ServiceController extends Zend_Controller_Action
$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";
$sql="select f.filename,f.id,s.uuid,f.depth,f.filesize as filesize,f.ts_created 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));
//文件大小处理
foreach($files as $k=>$v)
{
if ($v['filesize']<1024)
{
$files[$k]['filesize']=$v['filesize'].'Byte';
} elseif($v['filesize']<1024*1024) {
$files[$k]['filesize']=round($v['filesize']/1024,2).'KB';
} elseif($v['filesize']<1024*1024*1024) {
$files[$k]['filesize']=round($v['filesize']/1024/1024,2).'MB';
} else {
$files[$k]['filesize']=round($v['filesize']/1024/1024/1024,2).'GB';
}
$files[$k]['ts_created'] = date("Y-m-d H:i",strtotime($v['ts_created']));
}
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($files,JSON_NUMERIC_CHECK));
return true;
@ -883,13 +898,29 @@ class ServiceController extends Zend_Controller_Action
$subpath=(int)$this->_request->getParam('subpath');
$depth=(int)$this->_request->getParam('depth');
$depth++;
$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";
$sql="select f.*,s.uuid 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));
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";
if ($v['filesize']<1024)
{
$files[$k]['filesize']=$v['filesize'].'Byte';
} elseif($v['filesize']<1024*1024) {
$files[$k]['filesize']=round($v['filesize']/1024,2).'KB';
} elseif($v['filesize']<1024*1024*1024) {
$files[$k]['filesize']=round($v['filesize']/1024/1024,2).'MB';
} else {
$files[$k]['filesize']=round($v['filesize']/1024/1024/1024,2).'GB';
}
if ($v['isdir']==1)
{
$files[$k]['filename']=substr(strrchr(substr($v['filename'],0,-1),'/'),1).'/';}
else{
$files[$k]['filename']=substr(strrchr($v['filename'],'/'),1);
}
$files[$k]['ext'] = "";
$temp_arr = explode(".", $v['filename']);
if($temp_arr)

View File

@ -15,6 +15,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):?>
@ -299,7 +302,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>
@ -458,6 +461,9 @@ $(function() {
googleSearch('<?php echo $ev;?>');
}
});
$('#show-list').click(function(e) {
method.filelist.get($(this).attr('rel'));
});
});
//ajax literature
function literature(page){
@ -474,10 +480,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; ?>');
}

View File

@ -45,16 +45,6 @@ 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) :