#425 首页添加新闻的焦点轮播功能

This commit is contained in:
Li Jianxuan 2012-12-27 08:42:56 +00:00
parent 11dd20a220
commit c47de7ae12
6 changed files with 148 additions and 79 deletions

View File

@ -1,57 +1,75 @@
<?php
class IndexController extends Zend_Controller_Action
{
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 metadata) 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 metadata 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 datasetcd order by random()";
$this->view->datasetcd=$this->db->fetchRow($sql);
//下载最多数据(top 5)
$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 5)";
$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->addHelperPath('helper','Zend_View_Helper_');
$searchform=new SearchForm();
//$searchform->removeElement('submit');
$this->view->searchform=$searchform;
}
function preDispatch()
{
$this->view->config = Zend_Registry::get('config');
$this->db=Zend_Registry::get('db');
}
}
<?php
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();
}
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 metadata) 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 metadata 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 datasetcd order by random()";
$this->view->datasetcd=$this->db->fetchRow($sql);
//下载最多数据(top 5)
$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 5)";
$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->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());
$sql = "SELECT * FROM archive WHERE is_pub=true AND ts_published<'$time' AND image!='' LIMIT 5";
$sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH);
foreach($rows as $k=>$v)
{
$url = $News->getArchiveUrlByCid($v['id']);
$rows[$k]['url'] = $url['archive_url'];
}
$this->view->news = $rows;
}
}

View File

@ -3,6 +3,8 @@
$this->headTitle('首页');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/index.css');
$this->theme->AppendPlus($this,'jquery');
$this->theme->AppendPlus($this,'slides');
$auth = Zend_Auth::getInstance();
?>
<div id="index">
@ -101,16 +103,21 @@
<div id="rightPanel">
<div id="feature">
<div class="alpha-shadow">
<div><img src="<?= $this->feature['imgurl']; ?>" alt="特色数据集" style="border-width:1px;border-style:solid;" /></div>
</div>
<div class="title"><?= $this->feature['title']; ?></div>
<div class="description">
<?= $this->feature['description']; ?>
</div>
<span class="more"><a href="/data/feature" >以往推荐</a></span>
<span id="links"><a href="<?= $this->feature['detailurl']; ?>">详细</a></span>
<div id="slides">
<div class="slides_container">
<?php
foreach($this->news as $k=>$v)
{
echo '<div class="slide">'.
'<div class="thumb"><img src="'.$v['image'].'" /></div>'.
'<div class="description"><h2><a href="'.$v['url'].'">'.$v['title'].'</a></h2>'.
''.$v['description'].'</div>'.
''.
'</div>';
}
?>
</div>
</div>
</div>
<div id="itemCd">
<div class="alpha-shadow" id="image"><img src="<?= $this->datasetcd['img']; ?>" /></div>
@ -144,5 +151,16 @@
</div>
</div>
</div>
</div>
</div>
<script>
var startSlide = 1;
$('#slides').slides({
preload: true,
preloadImage: 'images/loading.gif',
generatePagination: true,
play: 5000,
pause: 2500,
hoverPause: true,
start: startSlide
});
</script>

View File

@ -68,4 +68,10 @@ textarea {resize: none}
.span3{width:200px;}
.input_arae{ margin:5px 0;}
.map_display_part{width:500px;height:300px;float:left;}
.map_display_part{width:500px;height:300px;float:left;}
.auto-complete-elements{height:140px;position:absolute;z-index:999;background:#FFF;border:1px solid #ccc; padding:2px;}
.auto-complete-elements ul{height:120px;overflow-y:scroll;}
.auto-complete-elements ul li{line-height:18px; cursor:pointer;height:18px; overflow:hidden;border:1px solid #FFF;}
.auto-complete-elements ul li:hover{height:18px;line-height:18px; border:1px solid #dedede;}
.auto-complete-elements .close-btn{height:18px;line-height:18px;border:1px solid #ccc;cursor:pointer; text-align:center}

View File

@ -114,6 +114,7 @@ input:focus,textarea:focus {
-webkit-focus-ring-color:none;
border-color:#c4c4c4;
background-color:#FFFFF0;
border-radius:3px;
}
fieldset {border:0 none;border-top:1px solid #ddd;margin:10px 0;padding:10px 0;}
legend {background:#fff;color:#93BB3A;font-weight:bold; padding:0 6px 0 0;}

View File

@ -147,17 +147,23 @@ color:Green; text-decoration:none;
#dataLink ul{padding:5px 0;}
#rightPanel #dataLink a{font-weight: bold;}
/*数据CD开始*/
/*新闻*/
#itemCd{ margin-top: 10px; border-bottom:1px dotted gray; overflow:hidden;}
#itemCd img { margin-top:-5px;margin-left:-5px;width:100px;height:100px;border-width:1px;border-style:solid;}
#itemCd #image{float: left; width: 110px; height: 105px;}
#itemCd #title{font-size: 105%; font-weight: bold; font-family: Tahoma; }
#itemCd #filesize{color: Gray;font-size: 95%;}
#itemCd #descript{margin: 10px 2% 5px 0px; font-family: Verdana;}
#itemCd #descript #intro {font-style: italic;}
#itemCd #link {margin-bottom: 10px;}
#dataLink ul{display:inline;float:left;list-style-type: none;margin-top:-5px;}
input{background:#ECF0F5;margin-bottom:6px;}
dd,dt{margin:0;}
#dataLink dd {padding-bottom:5px;margin-left:5px;margin-top:-5px;}
#dataLink dd {padding-bottom:5px;margin-left:5px;margin-top:-5px;}
#slides {overflow:hidden;}
#slides .slide{width:520px;}
#slides .slide { overflow:hidden;}
#slides .slide .thumb {float:left; overflow:hidden;}
#slides .slide .thumb img{max-height:150px;border:1px solid #CCC;padding:2px;margin:0 5px 0 0;}
#slides .slide .ctitle {float:left;overflow:hidden;}
#slides .slide .ctitle h2{font-weight:bold;display:block}
#slides .slide .description{float:left;}
#slides .pagination {}
#slides .pagination li{width:10px;height:16px;padding:2px;float:left;}
#slides .pagination li.current{background:#dedede;color:#FFF}

File diff suppressed because one or more lines are too long