修改 首页最新数据集

This commit is contained in:
cuixin 2017-03-28 17:42:11 +08:00
parent c09dbfa3b2
commit fd06b7bb69
2 changed files with 78 additions and 64 deletions

View File

@ -1,69 +1,62 @@
<?php
class IndexController extends Zend_Controller_Action
{
function preDispatch()
{
$this->view->config = Zend_Registry::get('config');
$this->db=Zend_Registry::get('db');
class IndexController extends Zend_Controller_Action {
function preDispatch () {
$this->view->config = Zend_Registry::get('config');
$this->db = Zend_Registry::get('db');
$this->view->theme = new Theme();
$this->view->main_nav_pageID = "index";
}
}
function indexAction()
{
//数据通讯
$l=new mydir($this->view->config->paths->newsletter,"newsletter_*.pdf");
$this->view->newsletter=$l->getLast();
$name=basename($this->view->newsletter,'.pdf');
list(,$this->view->newsletterno)=explode("_",$name);
function indexAction () {
//数据通讯
$l = new mydir($this->view->config->paths->newsletter, "newsletter_*.pdf");
$this->view->newsletter = $l->getLast();
$name = basename($this->view->newsletter, '.pdf');
list(, $this->view->newsletterno) = explode("_", $name);
//统计数据
$sql='select (select count(*) from users) as usernum,(select count(*) from normalmetadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum';
$row=$this->db->fetchRow($sql);
$this->view->usernum=$row['usernum'];
$this->view->metanum=$row['metanum'];
$this->view->offlinenum=$row['offlinenum'];
$sql = 'select (select count(*) from users) as usernum,(select count(*) from normalmetadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum';
$row = $this->db->fetchRow($sql);
$this->view->usernum = $row['usernum'];
$this->view->metanum = $row['metanum'];
$this->view->offlinenum = $row['offlinenum'];
/*$sql='select count(*) from metadata';
$row=$this->db->fetchRow($sql);
$this->view->metanum=$row['count'];*/
$sql="select sum(filesize) as sum,datatype from normalmetadata group by datatype";
$rows=$this->db->fetchAll($sql);
foreach($rows as $row)
{
if ($row['datatype'])
$this->view->offlinesize=$row['sum'];
else
$this->view->onlinesize=$row['sum'];
$sql = "select sum(filesize) as sum,datatype from normalmetadata group by datatype";
$rows = $this->db->fetchAll($sql);
foreach ($rows as $row) {
if ($row['datatype']) $this->view->offlinesize = $row['sum']; else
$this->view->onlinesize = $row['sum'];
}
//特色推荐
$sql="select * from datafeature order by id desc";
$this->view->feature=$this->db->fetchRow($sql);
$sql = "select * from datafeature order by id desc";
$this->view->feature = $this->db->fetchRow($sql);
//特色数据集
$sql="select * from datasetcd order by random()";
$this->view->datasetcd=$this->db->fetchRow($sql);
$sql = "select * from datasetcd order by random()";
$this->view->datasetcd = $this->db->fetchRow($sql);
//下载最多数据(top 6)
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata 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 6)";
$sql = "select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata 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 6)";
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$this->view->mdtop=$this->db->fetchAll($sql);
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata 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);
$sql="select m.uuid,m.title,m.id,m.description from normalmetadata 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->mdtop = $this->db->fetchAll($sql);
$sql = "select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata 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);
$sql = "select m.uuid,m.title,m.id,m.description from normalmetadata 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->addHelperPath('helper','Zend_View_Helper_');
$searchform=new SearchForm();
//$searchform->removeElement('submit');
$this->view->searchform=$searchform;
$this->view->addHelperPath('helper', 'Zend_View_Helper_');
$searchform = new SearchForm();
//$searchform->removeElement('submit');
$this->view->searchform = $searchform;
$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 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";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v)
{
foreach ($rows as $k => $v) {
$url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url'];
}
@ -75,8 +68,7 @@ class IndexController extends Zend_Controller_Action
$sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v)
{
foreach ($rows as $k => $v) {
$url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url'];
$rows[$k]['type_title'] = $url['type_title'];
@ -85,11 +77,20 @@ class IndexController extends Zend_Controller_Action
$this->view->list_news = $rows;
$sql="select d.*,m.ts_published as publish_year from datadoi d right join normalmetadata m on d.uuid=m.uuid where d.ts_published is not null order by ts_published desc limit 4";
$sql = "select d.*,m.ts_published as publish_year from datadoi d right join normalmetadata m on d.uuid=m.uuid where d.ts_published is not null order by ts_published desc limit 4";
$sth = $this->db->query($sql);
$this->view->dois = $sth->fetchAll();
}
/**
* 最新数据集
*/
$sql = "SELECT md.title,md.uuid FROM metadata md ORDER BY md.id DESC LIMIT 6";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
$this->view->latest_metadata = $rows;
}
}

View File

@ -64,26 +64,39 @@ $this->headLink()->appendStylesheet('/css/index.css');
<div class="data-list span4">
<ul class="unstyled">
<li>
<a href="/data/<?php echo $this->mdtop[0]->uuid; ?>"><?php echo $this->mdtop[0]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[0]['uuid']; ?>"
title="<?= $this->latest_metadata[0]['title']; ?>">
<?= mb_substr($this->latest_metadata[0]['title'], 0, 26, 'utf-8'); ?>
</li>
<li>
<a href="/data/<?php echo $this->mdtop[1]->uuid; ?>"><?php echo $this->mdtop[1]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[1]['uuid']; ?>"
title="<?= $this->latest_metadata[1]['title']; ?>">
<?= mb_substr($this->latest_metadata[1]['title'], 0, 26, 'utf-8'); ?>
</a>
</li>
<li>
<a href="/data/<?php echo $this->mdtop[2]->uuid; ?>"><?php echo $this->mdtop[2]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[2]['uuid']; ?>"
title="<?= $this->latest_metadata[2]['title']; ?>">
<?= mb_substr($this->latest_metadata[2]['title'], 0, 26, 'utf-8'); ?>
</li>
</ul>
</div>
<div class="data-list">
<ul class="unstyled">
<li>
<a href="/data/<?php echo $this->mdtop[3]->uuid; ?>"><?php echo $this->mdtop[3]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[3]['uuid']; ?>"
title="<?= $this->latest_metadata[3]['title']; ?>">
<?= mb_substr($this->latest_metadata[3]['title'], 0, 26, 'utf-8'); ?>
</li>
<li>
<a href="/data/<?php echo $this->mdtop[4]->uuid; ?>"><?php echo $this->mdtop[4]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[4]['uuid']; ?>"
title="<?= $this->latest_metadata[4]['title']; ?>">
<?= mb_substr($this->latest_metadata[4]['title'], 0, 26, 'utf-8'); ?>
</li>
<li>
<a href="/data/<?php echo $this->mdtop[5]->uuid; ?>"><?php echo $this->mdtop[5]->title; ?></a>
<a href="/data/<?= $this->latest_metadata[5]['uuid']; ?>"
title="<?= $this->latest_metadata[5]['title']; ?>">
<?= mb_substr($this->latest_metadata[4]['title'], 0, 26, 'utf-8'); ?>
</li>
</ul>
</div>