首页 热门数据 修改为 最新数据集

This commit is contained in:
cuixin 2017-04-24 11:02:20 +08:00
parent d8adb0aacd
commit 24cc152742
2 changed files with 156 additions and 172 deletions

View File

@ -1,92 +1,86 @@
<?php <?php
class IndexController extends Zend_Controller_Action class IndexController extends Zend_Controller_Action {
{ function preDispatch () {
function preDispatch() $this->view->config = Zend_Registry::get('config');
{ $this->db = Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->db=Zend_Registry::get('db');
$this->view->theme = new Theme(); $this->view->theme = new Theme();
$this->submd = $this->view->config->sub->metadata; $this->submd = $this->view->config->sub->metadata;
$this->subnews = $this->view->config->sub->news; $this->subnews = $this->view->config->sub->news;
# $this->_helper->layout->setLayout('index'); # $this->_helper->layout->setLayout('index');
//$this->view->main_nav_pageID = "index"; //$this->view->main_nav_pageID = "index";
} }
function indexAction() function indexAction () {
{
//统计数据 //统计数据
$sql="select (select count(*) from users) as usernum,(select count(*) from {$this->submd}) as metanum, $sql = "select (select count(*) from users) as usernum,(select count(*) from {$this->submd}) as metanum,
(select count(distinct d.uuid) from dataorder d left join offlineapp f on d.offlineappid=f.id where d.uuid in (select uuid from meteorologymd) and d.ts_approved is not null and d.status in (0,5) ) as offlinenum, (select count(distinct d.uuid) from dataorder d left join offlineapp f on d.offlineappid=f.id where d.uuid in (select uuid from meteorologymd) and d.ts_approved is not null and d.status in (0,5) ) as offlinenum,
(select count(*) from datavisual where uuid in (select uuid from {$this->submd}) and status=1) as visualnum"; (select count(*) from datavisual where uuid in (select uuid from {$this->submd}) and status=1) as visualnum";
$row=$this->db->fetchRow($sql); $row = $this->db->fetchRow($sql);
$this->view->usernum=$row['usernum']; $this->view->usernum = $row['usernum'];
$this->view->metanum=$row['metanum']; $this->view->metanum = $row['metanum'];
$this->view->offlinenum=$row['offlinenum']; $this->view->offlinenum = $row['offlinenum'];
$this->view->visualnum=$row['visualnum']; $this->view->visualnum = $row['visualnum'];
/*$sql='select count(*) from metadata'; /*$sql='select count(*) from metadata';
$row=$this->db->fetchRow($sql); $row=$this->db->fetchRow($sql);
$this->view->metanum=$row['count'];*/ $this->view->metanum=$row['count'];*/
$sql="select sum(filesize) as sum,datatype from {$this->submd} group by datatype"; $sql = "select sum(filesize) as sum,datatype from {$this->submd} group by datatype";
$rows=$this->db->fetchAll($sql); $rows = $this->db->fetchAll($sql);
foreach($rows as $row) foreach ($rows as $row) {
{ if ($row['datatype']) $this->view->offlinesize = $row['sum']; else
if ($row['datatype']) $this->view->onlinesize = $row['sum'];
$this->view->offlinesize=$row['sum'];
else
$this->view->onlinesize=$row['sum'];
} }
//下载最多数据(top 5) //下载最多数据(top 5)
$sql="select uuid,title,id from {$this->submd} where id in (select m.id from {$this->submd} m left join dataorder d on m.uuid=d.uuid where m.datatype=0 group by m.id order by count(d.uuid) desc limit 5)"; $sql = "select uuid,title,id from {$this->submd} where id in (select m.id from {$this->submd} m left join dataorder d on m.uuid=d.uuid where m.datatype=0 group by m.id order by count(d.uuid) desc limit 5)";
//最新数据
$sql = "select id,uuid,title,ts_created from {$this->submd} order by ts_created desc limit 5";
$this->db->setFetchMode(Zend_Db::FETCH_BOTH); $this->db->setFetchMode(Zend_Db::FETCH_BOTH);
$this->view->mdtop=$this->db->fetchAll($sql); $this->view->mdtop = $this->db->fetchAll($sql);
$sql="select uuid,title,id from {$this->submd} where id in (select m.id from {$this->submd} m left join dataorder d on m.uuid=d.uuid where m.datatype=1 group by m.id order by count(d.uuid) desc limit 5)"; $sql = "select uuid,title,id from {$this->submd} where id in (select m.id from {$this->submd} m left join dataorder d on m.uuid=d.uuid where m.datatype=1 group by m.id order by count(d.uuid) desc limit 5)";
$this->view->offlinemdtop=$this->db->fetchAll($sql); $this->view->offlinemdtop = $this->db->fetchAll($sql);
$sql="select m.uuid,m.title,m.id,m.description from {$this->submd} m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()"; $sql = "select m.uuid,m.title,m.id,m.description from {$this->submd} m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()";
$this->view->mdrandom=$this->db->fetchRow($sql); $this->view->mdrandom = $this->db->fetchRow($sql);
//搜索 //搜索
$this->view->addHelperPath('helper','Zend_View_Helper_'); $this->view->addHelperPath('helper', 'Zend_View_Helper_');
$searchform=new SearchForm(); $searchform = new SearchForm();
//$searchform->removeElement('submit'); //$searchform->removeElement('submit');
$this->view->searchform=$searchform; $this->view->searchform = $searchform;
$News = new Archive($this->db); $News = new Archive($this->db);
$time = date("Y-m-d H:i:s",time()); $time = date("Y-m-d H:i:s", time());
$sql = "SELECT * FROM archive WHERE is_pub=true and sub='$this->subnews' AND ts_published<'$time' AND image!='' $sql = "SELECT * FROM archive WHERE is_pub=true and sub='$this->subnews' AND ts_published<'$time' AND image!=''
and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5"; and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v) foreach ($rows as $k => $v) {
{
$url = $News->getArchiveUrlByCid($v['id']); $url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url']; $rows[$k]['url'] = $url['archive_url'];
} }
$this->view->news = $rows; $this->view->news = $rows;
//$time = date("Y-m-d H:i:s",time()); //$time = date("Y-m-d H:i:s",time());
$sql = "SELECT * FROM archive WHERE is_pub=true and sub='$this->subnews' AND ts_published<now() $sql = "SELECT * FROM archive WHERE is_pub=true and sub='$this->subnews' AND ts_published<now()
and id in (select ar_catalog.aid from ar_catalog left join ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news') and id in (select ar_catalog.aid from ar_catalog left join ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news')
order by ts_published desc LIMIT 5 "; order by ts_published desc LIMIT 5 ";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v) foreach ($rows as $k => $v) {
{
$url = $News->getArchiveUrlByCid($v['id']); $url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url']; $rows[$k]['url'] = $url['archive_url'];
$rows[$k]['type_title'] = $url['type_title']; $rows[$k]['type_title'] = $url['type_title'];
$rows[$k]['type_url'] = $url['type_url']; $rows[$k]['type_url'] = $url['type_url'];
} }
$this->view->list_news = $rows; $this->view->list_news = $rows;
$sql="select * from $this->submd where uuid in (select uuid from datavisual) order by ts_created desc limit 5"; $sql = "select * from $this->submd where uuid in (select uuid from datavisual) order by ts_created desc limit 5";
$sth=$this->db->query($sql); $sth = $this->db->query($sql);
$this->view->visualdata = $sth->fetchAll(PDO::FETCH_BOTH); $this->view->visualdata = $sth->fetchAll(PDO::FETCH_BOTH);
} }
} }

View File

@ -1,127 +1,117 @@
<?php <?php
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('首页'); $this->headTitle('首页');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
?> ?>
</div><!-- 结束container容器实现banner全屏展示-->
<!-- Carousel
================================================== -->
<div class="container-fluid1 ">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active"> <img src="/sjyportal/img/slide-00.jpg" alt="" class="">
<div class="container">
<div class="carousel-caption">
<h2>青海54.6%国土被纳入三江源国家生态保护试验区</h2>
</div>
</div>
</div>
<div class="item"> <img src="/sjyportal/img/slide-01.jpg" alt="" class="">
<div class="container">
<div class="carousel-caption">
<h2>青海54.6%国土被纳入三江源国家生态保护试验区</h2>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"></a> <a class="right carousel-control" href="#myCarousel" data-slide="next"></a> </div>
</div> </div>
<!-- /.carousel --> <div class="container-fluid1 ">
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active"><img src="/sjyportal/img/slide-00.jpg" alt="" class="">
<div class="container">
<div class="carousel-caption">
<h2>青海54.6%国土被纳入三江源国家生态保护试验区</h2>
</div>
</div>
</div>
<div class="item"><img src="/sjyportal/img/slide-01.jpg" alt="" class="">
<div class="container">
<div class="carousel-caption">
<h2>青海54.6%国土被纳入三江源国家生态保护试验区</h2>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"></a></div>
</div>
<div class="container"> <div class="container">
<div class="row-fluid">
<!-- Three columns of text below the carousel --> <div class="span12">
<div class="row-fluid"> <div class="span3">
<div class="span12"> <div class="box">
<div class="span3"> <h4 class="box-title">本站统计</h4>
<div class="box"> <ul>
<h4 class="box-title">本站统计</h4> <li>数据集:<?= $this->metanum ?></li>
<ul> <li>在线数据<?= $this->onlinesize ?>MB</li>
<li>数据集:<?= $this->metanum ?></li> <li>离线数据<?= $this->offlinesize ?>MB</li>
<li>在线数据<?= $this->onlinesize ?>MB</li> <li>共有注册用户:<?= $this->usernum ?></li>
<li>离线数据<?= $this->offlinesize ?>MB</li> <li>离线申请:<?= $this->offlinenum ?>人次</li>
<li>共有注册用户:<?= $this->usernum ?></li> </ul>
<li>离线申请:<?= $this->offlinenum ?>人次</li> </div>
</ul> </div>
</div> <div class="span9">
</div> <div class="box">
<!-- /.span4 --> <h4 class="box-title">新闻公告</h4>
<div class="span9"> <ul>
<div class="box"> <?php foreach ($this->list_news as $k => $v) { ?>
<h4 class="box-title">新闻公告</h4> <li>
<ul> [<?= date('Y-m-d', strtotime($v['ts_published'])) ?>]<a href="<?= $v['url'] ?>"
<?php foreach($this->list_news as $k=>$v){ ?> title="<?= $v['title'] ?>"><i
<li> class=" icon-ok-sign"> </i><?= $v['title'] ?></a>
[<?= date('Y-m-d',strtotime($v['ts_published'])) ?>]<a href="<?= $v['url'] ?>" title="<?= $v['title'] ?>"><i class=" icon-ok-sign"> </i><?= $v['title'] ?></a> </li>
</li> <?php } ?>
<?php } ?> <span class="pull-right"><a href="/archives/" target="_blank" class="more">更多>></a></span>
<span class="pull-right"><a href="/archives/" target="_blank" class="more">更多>></a></span> </ul>
</ul> </div>
</div> </div>
</div> </div>
<!-- /.span4 --> <div style="margin-bottom:20px;"><img src="/sjyportal/img/protect.jpg" class="img-rounded"/></div>
<div class="row-fluid">
</div> <div class="span4">
<!-- /.row --> <div class="box">
<div style="margin-bottom:20px;"><img src="/sjyportal/img/protect.jpg" class="img-rounded" /></div> <h4 class="box-title">最新可视化数据</h4>
<ul>
<!-- Three columns of text below the carousel --> <?php foreach ($this->visualdata as $k => $v) { ?>
<div class="row-fluid"> <li>
<!-- /.span4 --> <a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i
<div class="span4"> class=" icon-map-marker"> </i><?= $v['title'] ?></a>
<div class="box"> </li>
<h4 class="box-title">最新可视化数据</h4> <?php } ?>
<ul> <span class="pull-right"><a href="/data/visual" target="_blank" class="more">更多>></a></span>
<?php foreach($this->visualdata as $k=>$v){ ?> </ul>
<li> </div>
<a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i class=" icon-map-marker"> </i><?= $v['title'] ?></a> </div>
</li> <div class="span4">
<?php } ?> <div class="box">
<span class="pull-right"><a href="/data/visual" target="_blank" class="more">更多>></a></span> <h4 class="box-title">最新数据集</h4>
</ul> <ul>
</div> <?php foreach ($this->mdtop as $k => $v) { ?>
</div> <li>
<div class="span4"> <a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i
<div class="box"> class=" icon-map-marker"> </i><?= $v['title'] ?></a>
<h4 class="box-title">热门在线数据集</h4> </li>
<ul> <?php } ?>
<?php foreach($this->mdtop as $k=>$v){ ?> <span class="pull-right"><a href="/data/onlinelist" target="_blank" class="more">更多>></a></span>
<li> </ul>
<a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i class=" icon-map-marker"> </i><?= $v['title'] ?></a> </div>
</li> </div>
<?php } ?> <div class="span4">
<span class="pull-right"><a href="/data/onlinelist" target="_blank" class="more">更多>></a></span> <div class="box">
</ul> <h4 class="box-title">热门离线数据集</h4>
</div> <ul>
</div> <?php foreach ($this->offlinemdtop as $k => $v) { ?>
<!-- /.span4 --> <li>
<div class="span4"> <a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i
<div class="box"> class=" icon-map-marker"> </i><?= $v['title'] ?></a>
<h4 class="box-title">热门离线数据集</h4> </li>
<ul> <?php } ?>
<?php foreach($this->offlinemdtop as $k=>$v){ ?> <span class="pull-right">
<li> <a href="/data/offlinelist" target="_blank" class="more">更多>></a>
<a href="/data/<?= $v['uuid'] ?>" title="<?= $v['title'] ?>"><i class=" icon-map-marker"> </i><?= $v['title'] ?></a> </span>
</li> </ul>
<?php } ?> </div>
<span class="pull-right"><a href="/data/offlinelist" target="_blank" class="more">更多>></a></span> </div>
</ul> </div>
</div> </div>
</div> <script>
<!-- /.span4 --> !function ($) {
$(function () {
</div> // carousel demo
<!-- /.row --> $('#myCarousel').carousel()
</div> })
}(window.jQuery)
<!-- /.container --> </script>
<script>
!function ($) {
$(function(){
// carousel demo
$('#myCarousel').carousel()
})
}(window.jQuery)
</script>