2012-03-27 07:02:36 +00:00
|
|
|
<?php
|
|
|
|
class NewsController extends Zend_Controller_Action
|
|
|
|
{
|
2012-11-06 03:19:24 +00:00
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
private $limit=10;
|
2012-11-06 03:19:24 +00:00
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
function preDispatch()
|
|
|
|
{
|
|
|
|
$this->view->config = Zend_Registry::get('config');
|
|
|
|
$this->db=Zend_Registry::get('db');
|
|
|
|
}
|
|
|
|
|
|
|
|
function indexAction()
|
|
|
|
{
|
2012-11-30 15:12:27 +00:00
|
|
|
$News = new Archive($this->db);
|
|
|
|
$category = new ArchiveCategory($this->db);
|
2012-11-28 09:27:53 +00:00
|
|
|
$this->view->types = $category->GetCategory();
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2012-03-27 07:02:36 +00:00
|
|
|
|
2012-09-04 07:16:19 +00:00
|
|
|
$time = date("Y-m-d H:i:s",time());
|
2012-03-27 07:02:36 +00:00
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
$sql = "SELECT id,title,code FROM ".$News->tbl_categorys."";
|
2012-11-07 02:35:58 +00:00
|
|
|
$sth = $this->db->query($sql);
|
|
|
|
$rows = $sth->fetchAll();
|
2012-03-27 07:02:36 +00:00
|
|
|
|
2012-11-07 02:35:58 +00:00
|
|
|
$newslist = array();
|
|
|
|
|
|
|
|
foreach($rows as $v)
|
|
|
|
{
|
2012-11-27 03:57:27 +00:00
|
|
|
$sql = "SELECT n.*,c.title as typetitle,c.code FROM ".$News->tbl_archives." n
|
|
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
|
|
left join ".$News->tbl_categorys." c on c.id = ct.cid
|
|
|
|
WHERE n.ts_published<'$time' AND ct.cid={$v['id']}
|
|
|
|
ORDER BY ts_published DESC
|
|
|
|
LIMIT 10";
|
2012-11-07 02:35:58 +00:00
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$archives = $rs->fetchAll();
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
$newslist[$v['id']] = array("title"=>$v['title'],"code"=>$v['code'],"id"=>$v['id'],"list"=>$archives);
|
2012-11-07 02:35:58 +00:00
|
|
|
}
|
|
|
|
$this->view->lists = $newslist;
|
2012-04-06 08:37:50 +00:00
|
|
|
|
2012-11-07 02:35:58 +00:00
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function listAction()
|
|
|
|
{
|
|
|
|
$type = strtolower($this->_request->getParam('type'));
|
|
|
|
$page = $this->_request->getParam('page');
|
|
|
|
|
|
|
|
if(preg_match("/archive\-(\d+)\.html/",$page,$matches))
|
|
|
|
{
|
|
|
|
$this->_forward('archive', 'news', null, array('archive' => $matches['1'] , 'type'=> $type));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(preg_match("/[^a-z0-9]/",$type) || preg_match("/[^0-9]/",$page))
|
|
|
|
{
|
|
|
|
$this->_forward('error', 'error', null, null);
|
|
|
|
}
|
|
|
|
|
2012-11-27 03:57:27 +00:00
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
$News = new Archive($this->db);
|
2012-11-27 03:57:27 +00:00
|
|
|
|
|
|
|
$sql = "SELECT id,code,title FROM ".$News->tbl_categorys." WHERE code='$type' AND is_pub=true ";
|
2012-03-27 07:02:36 +00:00
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
|
|
|
if(empty($row['id']))
|
|
|
|
{
|
|
|
|
$this->_forward('error', 'error', null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
2012-11-27 03:57:27 +00:00
|
|
|
$this->view->url = $row['code'];
|
2012-03-27 07:02:36 +00:00
|
|
|
$this->view->title = $row['title'];
|
2012-11-28 09:27:53 +00:00
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
$category = new ArchiveCategory($this->db);
|
2012-11-28 09:27:53 +00:00
|
|
|
$this->view->types = $category->GetCategory();
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2012-03-27 07:02:36 +00:00
|
|
|
|
2012-11-05 08:39:15 +00:00
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
|
2012-11-27 03:57:27 +00:00
|
|
|
$sql = "SELECT n.*,c.code FROM ".$News->tbl_archives." n
|
|
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
|
|
left join ".$News->tbl_categorys." c ON ct.cid=c.id
|
|
|
|
WHERE c.id='{$row['id']}' AND n.ts_published<'".$time."' AND n.is_pub=true
|
|
|
|
ORDER BY n.ts_published DESC";
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$rows = $rs->fetchAll();
|
|
|
|
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
$paginator->setCurrentPageNumber($page);
|
|
|
|
$paginator->setItemCountPerPage($this->view->config->page->max);
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
$this->view->paginator=$paginator;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function archiveAction()
|
|
|
|
{
|
|
|
|
$type = $this->_request->getParam('type');
|
|
|
|
$archive = $this->_request->getParam('archive');
|
|
|
|
|
|
|
|
$this->view->type = $type;
|
|
|
|
|
|
|
|
if(preg_match("/[^a-z0-9]/",$type) || preg_match("/[^0-9]/",$archive))
|
|
|
|
{
|
|
|
|
$this->_forward('error', 'error', null, null);
|
|
|
|
}
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
$News = new Archive($this->db);
|
|
|
|
$category = new ArchiveCategory($this->db);
|
2012-11-28 09:27:53 +00:00
|
|
|
$this->view->types = $category->GetCategory();
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2012-03-27 07:02:36 +00:00
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
$time = date("Y-m-d",time());
|
2012-11-27 03:57:27 +00:00
|
|
|
|
|
|
|
$sql = "SELECT n.*,c.title as typename,c.code,u.realname as author FROM ".$News->tbl_archives." n
|
|
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
|
|
left join ".$News->tbl_categorys." c ON ct.cid=c.id
|
|
|
|
LEFT JOIN users u ON n.userid=u.id
|
|
|
|
WHERE c.code='".$type."' AND n.ts_published<'".$time."' AND n.is_pub=true AND n.id=".$archive."
|
|
|
|
ORDER BY n.ts_published DESC";
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
|
|
|
if(empty($row['id']))
|
|
|
|
{
|
|
|
|
$this->_forward('error', 'error', null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->view->infos = $row;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function searchAction()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-12 04:06:58 +00:00
|
|
|
}
|