westdc-zf1/application/admin/controllers/NewsController.php

114 lines
2.7 KiB
PHP
Raw Normal View History

<?php
class Admin_NewsController extends Zend_Controller_Action
{
function preDispatch()
{
$this->db=Zend_Registry::get('db');
$this->view->config = Zend_Registry::get('config');
$this->messenger=$this->_helper->getHelper('FlashMessenger');
$this->view->messages = $this->messenger->getMessages();
$this->_helper->layout->setLayout('administry');//新UI
}
function postDispatch()
{
$this->view->messages = $this->messenger->getMessages();
}
function indexAction()
{
}//indexAction 首页
function catlogAction()
{
$add = $this->_request->getParam('add');
$submit = $this->_request->getParam('submit');
$delete = $this->_request->getParam('delete');
$edit = $this->_request->getParam('edit');
if($add)
{
if(empty($submit))
$this->_helper->viewRenderer('catlogadd');
else{
$title = $this->_request->getParam('ctitle');
$keyword = $this->_request->getParam('keyword');
$discript = $this->_request->getParam('discript');
$sql="insert into news_catlog (title,keyword,discript) values ('$title','$keyword','$discript')";
if($this->db->exec($sql) > 0)
{
$this->messenger->addMessage('提示信息:栏目添加成功!');
$this->_redirect('/admin/news/catlog');
}
}
}//栏目添加
if($delete>0)
{
$sql = "delete from news_catlog where id='$delete'";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('提示信息:栏目删除成功!');
$this->_redirect('/admin/news/catlog');
}
}//栏目删除
if($edit>0)
{
$title = $this->_request->getParam('ctitle');
$keyword = $this->_request->getParam('keyword');
$discript = $this->_request->getParam('discript');
$orders = $this->_request->getParam('orders');
$sql="update news_catlog set title='$title',keyword='$keyword',discript='$discript',orders='$orders' where id='$edit'";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('提示信息:栏目编辑成功!');
$this->_redirect('/admin/news/catlog');
}
}//栏目编辑
else
{
$sql="select * from news_catlog order by orders desc";
$re=$this->db->query($sql);
$catlogs=$re->fetchAll();
$this->view->catlogs=$catlogs;
}//栏目列表
}//栏目管理
function newsaddAction()
{
$sql="select * from news_catlog order by orders";
$re = $this->db->query($sql);
$types = $re->fetchAll();
$this->view->types=$types;
}//newsadd 新闻添加
}