From fd06b7bb695aa8c181565c3521b4fca2b178433b Mon Sep 17 00:00:00 2001 From: cuixin Date: Tue, 28 Mar 2017 17:42:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=95=B0=E6=8D=AE=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/controllers/IndexController.php | 117 +++++++++--------- .../default/views/scripts/index/index.phtml | 25 +++- 2 files changed, 78 insertions(+), 64 deletions(-) diff --git a/application/default/controllers/IndexController.php b/application/default/controllers/IndexController.php index 1b288097..3b3d4510 100755 --- a/application/default/controllers/IndexController.php +++ b/application/default/controllers/IndexController.php @@ -1,95 +1,96 @@ 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']; } - + $this->view->news = $rows; - + //$time = date("Y-m-d H:i:s",time()); $sql = "SELECT * FROM archive WHERE is_pub=true AND ts_publisheddb->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']; $rows[$k]['type_url'] = $url['type_url']; } - + $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; + } } diff --git a/application/default/views/scripts/index/index.phtml b/application/default/views/scripts/index/index.phtml index f2809a25..5c79b98e 100755 --- a/application/default/views/scripts/index/index.phtml +++ b/application/default/views/scripts/index/index.phtml @@ -64,26 +64,39 @@ $this->headLink()->appendStylesheet('/css/index.css');