merge branch news r2728
This commit is contained in:
parent
31e57813d7
commit
76337e2ea5
|
@ -90,7 +90,7 @@ class Admin_NewsController extends Zend_Controller_Action
|
|||
$description = $this->_request->getParam('description');
|
||||
$fid = $this->_request->getParam('fid');
|
||||
|
||||
$sql="insert into news_category (title,keywords,description,url,fid) values ('$title','$keyword','$description','$url','$fid')";
|
||||
$sql="insert into news_category (title,keywords,description,url,fid,display) values ('$title','$keyword','$description','$url','$fid',1)";
|
||||
if($this->db->exec($sql) > 0)
|
||||
{
|
||||
$this->messenger->addMessage('提示信息:栏目添加成功!');
|
||||
|
|
|
@ -12,15 +12,16 @@ class NewsController extends Zend_Controller_Action
|
|||
|
||||
function indexAction()
|
||||
{
|
||||
$sql="select * from news_category order by displayorder asc";
|
||||
$re = $this->db->query($sql);
|
||||
$types = $re->fetchAll();
|
||||
include_once("news.php");
|
||||
$news = new news($this->db);
|
||||
$types = $news->getAllCategory();
|
||||
|
||||
$this->view->types=$types;
|
||||
|
||||
$sql = "SELECT a.*,t.title as typetitle,t.url FROM news_archives a
|
||||
LEFT JOIN news_category t ON a.typeid=t.id
|
||||
WHERE a.ts_published<'now()' AND is_pub>=1 ORDER BY ts_published DESC";
|
||||
$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";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
$rows = $rs->fetchAll();
|
||||
|
@ -65,15 +66,15 @@ class NewsController extends Zend_Controller_Action
|
|||
$this->view->url = $row['url'];
|
||||
$this->view->title = $row['title'];
|
||||
|
||||
$sql="select * from news_category order by displayorder asc";
|
||||
$re = $this->db->query($sql);
|
||||
$types = $re->fetchAll();
|
||||
include_once("news.php");
|
||||
$news = new news($this->db);
|
||||
$types = $news->getAllCategory();
|
||||
|
||||
$this->view->types=$types;
|
||||
|
||||
$sql = "SELECT arc.*,c.url FROM news_archives arc
|
||||
LEFT JOIN news_category c ON arc.typeid=c.id
|
||||
WHERE arc.typeid='{$row['id']}' AND arc.ts_published<'now()' AND arc.is_pub>=1
|
||||
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
|
||||
ORDER BY arc.ts_published DESC";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
|
@ -103,9 +104,9 @@ class NewsController extends Zend_Controller_Action
|
|||
$this->_forward('error', 'error', null, null);
|
||||
}
|
||||
|
||||
$sql="select * from news_category order by displayorder asc";
|
||||
$re = $this->db->query($sql);
|
||||
$types = $re->fetchAll();
|
||||
include_once("news.php");
|
||||
$news = new news($this->db);
|
||||
$types = $news->getAllCategory();
|
||||
|
||||
$this->view->types=$types;
|
||||
|
||||
|
@ -114,6 +115,9 @@ class NewsController extends Zend_Controller_Action
|
|||
$sql .= " LEFT JOIN users u ON arc.userid=u.id";
|
||||
$sql .= " WHERE arc.is_pub>0 AND arc.ts_published<'now()' AND arc.id=$archive";
|
||||
|
||||
$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";
|
||||
|
||||
$rs = $this->db->query($sql);
|
||||
$row = $rs->fetch();
|
||||
|
|
|
@ -24,9 +24,19 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
|
|||
if(count($this->types))
|
||||
{
|
||||
foreach($this->types as $k=>$v)
|
||||
{
|
||||
if($v['fid']==0)
|
||||
{
|
||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
||||
}
|
||||
foreach($this->types as $vd)
|
||||
{
|
||||
if($vd['fid']==$v['id'])
|
||||
{
|
||||
echo '<li> - <a href="/news/'.$vd['url'].'">'.$vd['title'].'</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
@ -18,9 +18,19 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
if(count($this->types))
|
||||
{
|
||||
foreach($this->types as $k=>$v)
|
||||
{
|
||||
if($v['fid']==0)
|
||||
{
|
||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
||||
}
|
||||
foreach($this->types as $vd)
|
||||
{
|
||||
if($vd['fid']==$v['id'])
|
||||
{
|
||||
echo '<li> - <a href="/news/'.$vd['url'].'">'.$vd['title'].'</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
@ -19,9 +19,19 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
if(count($this->types))
|
||||
{
|
||||
foreach($this->types as $k=>$v)
|
||||
{
|
||||
if($v['fid']==0)
|
||||
{
|
||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
||||
}
|
||||
foreach($this->types as $vd)
|
||||
{
|
||||
if($vd['fid']==$v['id'])
|
||||
{
|
||||
echo '<li> - <a href="/news/'.$vd['url'].'">'.$vd['title'].'</a></li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
class news
|
||||
{
|
||||
var $db; //传入PDO对象
|
||||
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/*
|
||||
递归获得所有栏目
|
||||
*/
|
||||
function getAllCategory($hide = 0){
|
||||
|
||||
$sql = "SELECT c.* FROM news_category c
|
||||
WHERE display>0
|
||||
ORDER BY displayorder asc";
|
||||
$re = $this->db->query($sql);
|
||||
$categorys = $re->fetchAll();
|
||||
|
||||
return $categorys;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue