diff --git a/application/admin/controllers/NewsController.php b/application/admin/controllers/NewsController.php
index f8af0b12..d9a9e122 100644
--- a/application/admin/controllers/NewsController.php
+++ b/application/admin/controllers/NewsController.php
@@ -24,6 +24,8 @@ class Admin_NewsController extends Zend_Controller_Action
}//indexAction 首页
+ function listAction(){
+ }
function catlogAction()
{
@@ -94,12 +96,32 @@ class Admin_NewsController extends Zend_Controller_Action
function newsaddAction()
{
+ $id = $this->_request->getParam('id');
+ if($id>0)
+ {
+ $sql = "select id,title,pubtime,typeid from news_archives where id=$id";
+ $rs = $this->db->query($sql);
+ $rows = $rs->fetch();
+
+ if($rows['pubtime']>time())
+ {
+ $title = "《{$rows['title']}》将在".date('Y-m-d H:i',$rows['pubtime'])."发布";
+ }
+ else
+ {
+ $title = "《{$rows['title']}》发布成功!";
+ }
+
+ $this->view->title = $title;
+ $this->view->infos = $rows;
+ $this->_helper->viewRenderer('newsaddok');
+ }
$sql="select * from news_catlog order by displayorder desc";
$re = $this->db->query($sql);
$types = $re->fetchAll();
- $this->view->types=$types;
+ $this->view->types=$types;
}//newsadd 新闻添加
@@ -145,7 +167,11 @@ class Admin_NewsController extends Zend_Controller_Action
{
if(!empty($pubtimer))
{
- $pubtime = strtotime("2011-10-09 19:03");
+ $pubtime = strtotime($pubtime);
+ }
+ else
+ {
+ $pubtime = time();
}
$date=array(
@@ -158,23 +184,61 @@ class Admin_NewsController extends Zend_Controller_Action
'pubtime' => $pubtime,
'source' => $source,
'typeid' => $typeid,
- 'pub' => $pub
+ 'pub' => $pub,
+ 'body' => $body
);
- echo '
发布成功:
-
-
';
- foreach($date as $k=>$v)
- {
- if(in_array($k,$datavar))
+
+ $sql = "INSERT INTO news_archives (title,writer,keyword,description,image,writetime,pubtime,source,typeid,pub)
+ VALUES ('{$date['title']}',
+ '{$date['writer']}',
+ '{$date['keyword']}',
+ '{$date['description']}',
+ '{$date['image']}',
+ '{$date['writetime']}',
+ '{$date['pubtime']}',
+ '{$date['source']}',
+ '{$date['typeid']}',
+ '{$date['pub']}')
+ RETURNING id
+ ";
+
+ try{
+ $sth = $this->db->prepare($sql);
+ if($sth->execute())
{
- echo '- '.$k.'='.$v.'
';
+ $temp = $sth->fetch(PDO::FETCH_ASSOC);
+ $sql = "INSERT INTO news_archivesaddon (id,body) values ('{$temp['id']}','{$date['body']}')";
+ if($this->db->exec($sql)>0)
+ {
+ echo '发布成功!
';
+ }
+ else
+ {
+ $sql = "delete from news_archives where id={$temp['id']}";
+ $this->db->exec($sql);
+ echo '发布失败!写入附加表出错,请联系管理员
';
+ }
}
+
+ }catch(Exception $e){
+ echo '文章发布失败:
+
+
+ - '.$e->getMessage().'
+
+
';
}
- echo'
-
- ';
+
+
+
+
+
+
+
}
/*
diff --git a/application/admin/views/scripts/news/newsadd.phtml b/application/admin/views/scripts/news/newsadd.phtml
index 833975ec..2773905e 100644
--- a/application/admin/views/scripts/news/newsadd.phtml
+++ b/application/admin/views/scripts/news/newsadd.phtml
@@ -6,8 +6,6 @@
$this->headScript()->appendFile('/static/js/kindeditor-min.js');
$this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
$this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
-
-
?>
-
+
@@ -108,12 +106,6 @@ $(document).ready(function(){
-
-
-
-
-
-
@@ -156,7 +148,7 @@ $(document).ready(function(){
@@ -186,12 +178,12 @@ $(function(){
if($(this).is(":checked"))
{
$('#pubtimelable').html('定时发布时间');
- $('#pubtime').removeAttr('disabled');
+ $('#pubtime').removeAttr('readonly');
}
else
{
$('#pubtimelable').html('定时发布?');
- $('#pubtime').attr("disabled","disabled");
+ $('#pubtime').attr("readonly","readonly");
}
});
});
@@ -216,5 +208,4 @@ function addon(){
}
});
}
-
\ No newline at end of file
diff --git a/application/admin/views/scripts/news/newsaddok.phtml b/application/admin/views/scripts/news/newsaddok.phtml
new file mode 100644
index 00000000..9952c3ab
--- /dev/null
+++ b/application/admin/views/scripts/news/newsaddok.phtml
@@ -0,0 +1,102 @@
+headTitle($this->config->title->site);
+ $this->headTitle('后台管理');
+ $this->headTitle()->setSeparator(' - ');
+ $this->headScript()->appendFile('/static/js/jquery.tagInput.min.js');
+ $this->headScript()->appendFile('/static/js/kindeditor-min.js');
+ $this->headScript()->appendFile('/static/js/kindlang/zh_CN.js');
+ $this->headLink()->appendStylesheet('/static/css/kindskin/default/default.css');
+?>
+hasIdentity())
+ {
+ $user = $auth->getIdentity();
+ $uname=$user->username;
+ $realname = $user->realname;
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file