fix #324, 实现缩略图浏览

This commit is contained in:
wlx 2012-03-28 14:04:00 +00:00
parent fd6f60751a
commit 2038c67289
3 changed files with 50 additions and 17 deletions

View File

@ -1342,22 +1342,17 @@ class DataController extends Zend_Controller_Action
*/
function thumbAction()
{
$id = (int)$this->_request->getParam('id');
if ($id>0) {
$thumb=$this->db->fetchRow($this->db->quoteInto('select * from thumbnail where id=?',$id));
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
if (empty($thumb['data'])) {
header("Content-Type:image/png");
header("Content-Length: " . filesize("images/nothumb.png"));
$file=fopen("images/nothumb.png",'r');
fpassthru($file);
exit;
} else {
header("Content-Type:image/".$thumb['filetype']);
print base64_decode($thumb['data']);
}
}
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$select=$this->db->select();
$select->from('normalmetadata as m','m.*')
->order('m.title desc')->limitPage($page,$this->limit);
$this->view->metadata = $this->db->fetchAll($select);
$this->view->page=new Pagination($sum,$page,$this->limit);
}
/*

View File

@ -50,7 +50,9 @@ if (is_array($kcg) && count($kcg)>0 ) :
<?php endif;endforeach; ?>
</div>
<div class="fieldlist">
<ul><li><a href="/data/timeline">时间轴浏览</a></li>
<ul>
<li><a href="/data/thumb">缩略图浏览</a></li>
<li><a href="/data/timeline">时间轴浏览</a></li>
<li><a href="/data/map">空间浏览</a></li>
<li><a href="/data/timemap">时空浏览</a></li>
<li><a href="/data/browse">数据列表浏览</a></li>

View File

@ -0,0 +1,36 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle('缩略图浏览');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/water.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
$this->breadcrumb('缩略图浏览');
$this->breadcrumb()->setSeparator(' > ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/jquery.colorbox-min.js');
$this->headLink()->appendStylesheet('/css/colorbox.css');
?>
<?php echo $this->page->getNavigation(); ?>
<hr />
<div id="mdlist">
<?php foreach($this->metadata as $md) : ?>
<div class="thumb">
<div class="thumbtitle">
<a href="/data/view/uuid/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']); ?> </a>
</div>
<a class="colorbox" href="/service/bigthumb/id/<?php echo $md['id'];?>" title="<?php echo $this->escape($md['title']); ?>">
<img src="/service/thumb/id/<?php echo $md['id'];?>" alt="<?php echo $this->escape($md['title']);?>" title="<?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?>" />
</a>
</div>
<?php endforeach; ?>
</div>
<hr style="clear:left;"/>
<?php echo $this->page->getNavigation(); ?>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){$(".colorbox").colorbox({rel:"colorbox",photo:"true",transition:"fade"});});
</script>