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');
|
$description = $this->_request->getParam('description');
|
||||||
$fid = $this->_request->getParam('fid');
|
$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)
|
if($this->db->exec($sql) > 0)
|
||||||
{
|
{
|
||||||
$this->messenger->addMessage('提示信息:栏目添加成功!');
|
$this->messenger->addMessage('提示信息:栏目添加成功!');
|
||||||
|
|
|
@ -12,15 +12,16 @@ class NewsController extends Zend_Controller_Action
|
||||||
|
|
||||||
function indexAction()
|
function indexAction()
|
||||||
{
|
{
|
||||||
$sql="select * from news_category order by displayorder asc";
|
include_once("news.php");
|
||||||
$re = $this->db->query($sql);
|
$news = new news($this->db);
|
||||||
$types = $re->fetchAll();
|
$types = $news->getAllCategory();
|
||||||
|
|
||||||
$this->view->types=$types;
|
$this->view->types=$types;
|
||||||
|
|
||||||
$sql = "SELECT a.*,t.title as typetitle,t.url FROM news_archives a
|
$time = date("Y-m-d H:i:s",time());
|
||||||
LEFT JOIN news_category t ON a.typeid=t.id
|
$sql = "SELECT arc.*,t.title as typetitle,t.url FROM news_archives arc
|
||||||
WHERE a.ts_published<'now()' AND is_pub>=1 ORDER BY ts_published DESC";
|
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);
|
$rs = $this->db->query($sql);
|
||||||
$rows = $rs->fetchAll();
|
$rows = $rs->fetchAll();
|
||||||
|
@ -51,7 +52,7 @@ class NewsController extends Zend_Controller_Action
|
||||||
$this->_forward('error', 'error', null, null);
|
$this->_forward('error', 'error', null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT id,url,title FROM news_category WHERE url='$type'";
|
$sql = "SELECT id,url,title FROM news_category WHERE url='$type' ";
|
||||||
$rs = $this->db->query($sql);
|
$rs = $this->db->query($sql);
|
||||||
$row = $rs->fetch();
|
$row = $rs->fetch();
|
||||||
|
|
||||||
|
@ -65,15 +66,15 @@ class NewsController extends Zend_Controller_Action
|
||||||
$this->view->url = $row['url'];
|
$this->view->url = $row['url'];
|
||||||
$this->view->title = $row['title'];
|
$this->view->title = $row['title'];
|
||||||
|
|
||||||
$sql="select * from news_category order by displayorder asc";
|
include_once("news.php");
|
||||||
$re = $this->db->query($sql);
|
$news = new news($this->db);
|
||||||
$types = $re->fetchAll();
|
$types = $news->getAllCategory();
|
||||||
|
|
||||||
$this->view->types=$types;
|
$this->view->types=$types;
|
||||||
|
|
||||||
$sql = "SELECT arc.*,c.url FROM news_archives arc
|
$sql = "SELECT arc.*,c.url FROM news_archives arc
|
||||||
LEFT JOIN news_category c ON arc.typeid=c.id
|
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
|
WHERE arc.typeid='{$row['id']}' AND arc.ts_published<'".$time."' AND arc.is_pub>=1
|
||||||
ORDER BY arc.ts_published DESC";
|
ORDER BY arc.ts_published DESC";
|
||||||
|
|
||||||
$rs = $this->db->query($sql);
|
$rs = $this->db->query($sql);
|
||||||
|
@ -103,9 +104,9 @@ class NewsController extends Zend_Controller_Action
|
||||||
$this->_forward('error', 'error', null, null);
|
$this->_forward('error', 'error', null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql="select * from news_category order by displayorder asc";
|
include_once("news.php");
|
||||||
$re = $this->db->query($sql);
|
$news = new news($this->db);
|
||||||
$types = $re->fetchAll();
|
$types = $news->getAllCategory();
|
||||||
|
|
||||||
$this->view->types=$types;
|
$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 .= " 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 .= " 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);
|
$rs = $this->db->query($sql);
|
||||||
$row = $rs->fetch();
|
$row = $rs->fetch();
|
||||||
|
|
|
@ -24,9 +24,19 @@ $this->headMeta()->appendName('description', mb_substr($this->infos['description
|
||||||
if(count($this->types))
|
if(count($this->types))
|
||||||
{
|
{
|
||||||
foreach($this->types as $k=>$v)
|
foreach($this->types as $k=>$v)
|
||||||
|
{
|
||||||
|
if($v['fid']==0)
|
||||||
{
|
{
|
||||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
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>
|
</ul>
|
||||||
|
|
|
@ -18,9 +18,19 @@ $this->breadcrumb()->setSeparator(' > ');
|
||||||
if(count($this->types))
|
if(count($this->types))
|
||||||
{
|
{
|
||||||
foreach($this->types as $k=>$v)
|
foreach($this->types as $k=>$v)
|
||||||
|
{
|
||||||
|
if($v['fid']==0)
|
||||||
{
|
{
|
||||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
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>
|
</ul>
|
||||||
|
|
|
@ -19,9 +19,19 @@ $this->breadcrumb()->setSeparator(' > ');
|
||||||
if(count($this->types))
|
if(count($this->types))
|
||||||
{
|
{
|
||||||
foreach($this->types as $k=>$v)
|
foreach($this->types as $k=>$v)
|
||||||
|
{
|
||||||
|
if($v['fid']==0)
|
||||||
{
|
{
|
||||||
echo '<li><a href="/news/'.$v['url'].'">'.$v['title'].'</a></li>';
|
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>
|
</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