2009-03-06 03:20:46 +00:00
< ? 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 );
//统计数据
2009-11-19 09:03:42 +00:00
$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' ;
2009-03-06 03:20:46 +00:00
$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 );
//特色数据集
2011-10-28 09:49:16 +00:00
$sql = " select * from datasetcd order by random() " ;
2009-03-06 03:20:46 +00:00
$this -> view -> datasetcd = $this -> db -> fetchRow ( $sql );
//下载最多数据(top 5)
2011-12-05 02:27:13 +00:00
$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) " ;
2009-03-06 03:20:46 +00:00
$this -> db -> setFetchMode ( Zend_Db :: FETCH_OBJ );
$this -> view -> mdtop = $this -> db -> fetchAll ( $sql );
2011-12-05 02:27:13 +00:00
$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) " ;
2011-10-29 12:13:12 +00:00
$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 );
2009-03-06 03:20:46 +00:00
//搜索
$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' );
}
}