2011-09-23 03:49:10 +00:00
|
|
|
|
<?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');
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$description = $this->_request->getParam('description');
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$sql="insert into news_catlog (title,keyword,description) values ('$title','$keyword','$description')";
|
2011-09-23 03:49:10 +00:00
|
|
|
|
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');
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$description = $this->_request->getParam('description');
|
|
|
|
|
$displayorder = $this->_request->getParam('displayorder');
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$sql="update news_catlog set title='$title',keyword='$keyword',description='$description',displayorder='$displayorder' where id='$edit'";
|
2011-09-23 03:49:10 +00:00
|
|
|
|
if($this->db->exec($sql)>0)
|
|
|
|
|
{
|
|
|
|
|
$this->messenger->addMessage('提示信息:栏目编辑成功!');
|
|
|
|
|
$this->_redirect('/admin/news/catlog');
|
|
|
|
|
}
|
|
|
|
|
}//栏目编辑
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$sql="select * from news_catlog order by displayorder desc";
|
2011-09-23 03:49:10 +00:00
|
|
|
|
$re=$this->db->query($sql);
|
|
|
|
|
$catlogs=$re->fetchAll();
|
|
|
|
|
|
|
|
|
|
$this->view->catlogs=$catlogs;
|
|
|
|
|
|
|
|
|
|
}//栏目列表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//栏目管理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function newsaddAction()
|
|
|
|
|
{
|
|
|
|
|
|
2011-09-28 08:29:01 +00:00
|
|
|
|
$sql="select * from news_catlog order by displayorder desc";
|
2011-09-23 03:49:10 +00:00
|
|
|
|
$re = $this->db->query($sql);
|
|
|
|
|
$types = $re->fetchAll();
|
|
|
|
|
|
2011-10-09 10:15:50 +00:00
|
|
|
|
$this->view->types=$types;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
|
|
|
|
}//newsadd 新闻添加
|
|
|
|
|
|
2011-10-09 10:15:50 +00:00
|
|
|
|
function archivesaddAction()
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$datavar = array(
|
|
|
|
|
'title','writer','source','image','body','typeid','pub','pubtimer','pubtime','description','keyword'
|
|
|
|
|
);
|
|
|
|
|
foreach($_POST as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if(in_array($k,$datavar))
|
|
|
|
|
{
|
|
|
|
|
$$k=$v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg=array();
|
|
|
|
|
if(empty($title)) $msg[]="标题不能为空";
|
|
|
|
|
if(strlen($title)>40) $msg[]="标题长度不能超过40个字符";
|
|
|
|
|
if(strlen($writer)>50) $msg[]="作者长度不能超过50个字符";
|
|
|
|
|
if(strlen($keyword)>200) $msg[] = "关键词长度不能超过200个字符,现在输入了".strlen($keyword)."个字符";
|
|
|
|
|
if(strlen($description)>200) $msg[] = "内容描述不能超过200个字符,现在输入了".strlen($description)."个字符";
|
|
|
|
|
if(empty($body)) $msg[]="请填写内容";
|
|
|
|
|
if($typeid==0) $msg[]="请选择栏目";
|
|
|
|
|
|
|
|
|
|
if(count($msg)>0)
|
|
|
|
|
{
|
|
|
|
|
echo '<div class="box box-error">发布失败:</div>
|
|
|
|
|
<div class="box box-error-msg">
|
|
|
|
|
<ol>';
|
|
|
|
|
foreach ($msg as $v)
|
|
|
|
|
{
|
|
|
|
|
echo '<li>'.$v.'</li>';
|
|
|
|
|
}
|
|
|
|
|
echo'</ol>
|
|
|
|
|
</div>
|
|
|
|
|
';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(!empty($pubtimer))
|
|
|
|
|
{
|
|
|
|
|
$pubtime = strtotime("2011-10-09 19:03");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$date=array(
|
|
|
|
|
'title' => $title,
|
|
|
|
|
'writer' => $writer,
|
|
|
|
|
'keyword' => $keyword,
|
|
|
|
|
'description'=> $description,
|
|
|
|
|
'image' => $image,
|
|
|
|
|
'writetime' => time(),
|
|
|
|
|
'pubtime' => $pubtime,
|
|
|
|
|
'source' => $source,
|
|
|
|
|
'typeid' => $typeid,
|
|
|
|
|
'pub' => $pub
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo '<div class="box box-success">发布成功:</div>
|
|
|
|
|
<div class="box box-error-msg">
|
|
|
|
|
<ol>';
|
|
|
|
|
foreach($date as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if(in_array($k,$datavar))
|
|
|
|
|
{
|
|
|
|
|
echo '<li>'.$k.'='.$v.'</li>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo'</ol>
|
|
|
|
|
</div>
|
|
|
|
|
';
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
<div class="box box-info">Info box sample</div>
|
|
|
|
|
<div class="box box-warning">Warning box sample</div>
|
|
|
|
|
<div class="box box-error">Error box sample</div>
|
|
|
|
|
<div class="box box-error-msg">
|
|
|
|
|
<ol>
|
|
|
|
|
<li>Credit card number entered is invalid</li>
|
|
|
|
|
<li>Credit card verification number must be a valid number</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="box box-success">Success box sample</div>
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|