2012-03-27 07:02:36 +00:00
|
|
|
<?php
|
|
|
|
class NewsController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
private $limit=10;
|
|
|
|
function preDispatch()
|
|
|
|
{
|
|
|
|
$this->view->config = Zend_Registry::get('config');
|
|
|
|
$this->db=Zend_Registry::get('db');
|
|
|
|
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
|
|
|
$this->view->messages = $this->messenger->getMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
function indexAction()
|
|
|
|
{
|
2012-09-04 07:16:19 +00:00
|
|
|
include_once("news.php");
|
|
|
|
$news = new news($this->db);
|
|
|
|
$types = $news->getAllCategory();
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$this->view->types=$types;
|
|
|
|
|
2012-09-04 07:16:19 +00:00
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
$sql = "SELECT arc.*,t.title as typetitle,t.url FROM news_archives arc
|
|
|
|
LEFT JOIN news_category t ON arc.typeid=t.id
|
|
|
|
WHERE arc.ts_published<'$time' ORDER BY ts_published DESC";
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$rows = $rs->fetchAll();
|
|
|
|
|
|
|
|
$page = $this->_request->getParam('page');
|
2012-04-06 08:37:50 +00:00
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
$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 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-05 08:39:15 +00:00
|
|
|
$sql = "SELECT id,url,title FROM news_category WHERE url='$type' AND display>0 ";
|
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{
|
|
|
|
|
|
|
|
$this->view->url = $row['url'];
|
|
|
|
$this->view->title = $row['title'];
|
|
|
|
|
2012-09-04 07:16:19 +00:00
|
|
|
include_once("news.php");
|
|
|
|
$news = new news($this->db);
|
|
|
|
$types = $news->getAllCategory();
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$this->view->types=$types;
|
|
|
|
|
2012-11-05 08:39:15 +00:00
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
$sql = "SELECT arc.*,c.url FROM news_archives arc
|
2012-09-04 07:16:19 +00:00
|
|
|
left join news_category c ON arc.typeid=c.id
|
|
|
|
WHERE arc.typeid='{$row['id']}' AND arc.ts_published<'".$time."' AND arc.is_pub>=1
|
2012-03-27 07:02:36 +00:00
|
|
|
ORDER BY arc.ts_published DESC";
|
|
|
|
|
|
|
|
$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-09-04 07:16:19 +00:00
|
|
|
include_once("news.php");
|
|
|
|
$news = new news($this->db);
|
|
|
|
$types = $news->getAllCategory();
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
|
|
$this->view->types=$types;
|
|
|
|
|
2012-04-09 07:50:57 +00:00
|
|
|
$sql = "SELECT arc.*,type.url,type.title as typename,u.realname as author FROM news_archives arc";
|
2012-04-06 08:37:50 +00:00
|
|
|
$sql .= " LEFT JOIN news_category type ON arc.typeid=type.id";
|
2012-04-09 07:50:57 +00:00
|
|
|
$sql .= " LEFT JOIN users u ON arc.userid=u.id";
|
2012-04-06 08:37:50 +00:00
|
|
|
$sql .= " WHERE arc.is_pub>0 AND arc.ts_published<'now()' AND arc.id=$archive";
|
2012-11-05 08:39:15 +00:00
|
|
|
/*
|
2012-09-04 07:16:19 +00:00
|
|
|
$sql = "SELECT arc.* FROM news_archives arc";
|
|
|
|
$sql .= " LEFT JOIN news_category type ON arc.typeid=type.id";
|
|
|
|
$sql .= " WHERE arc.is_pub>0 AND ts_published<'$time' AND arc.id=$archive";
|
2012-11-05 08:39:15 +00:00
|
|
|
*/
|
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
|
|
|
}
|