From 08b268a6058667172b16d00d655b2cb946a03e34 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Mon, 10 Oct 2011 06:30:51 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/NewsController.php | 90 +++++++++++++--- .../admin/views/scripts/news/newsadd.phtml | 17 +-- .../admin/views/scripts/news/newsaddok.phtml | 102 ++++++++++++++++++ 3 files changed, 183 insertions(+), 26 deletions(-) create mode 100644 application/admin/views/scripts/news/newsaddok.phtml 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 '
  1. '.$k.'='.$v.'
  2. '; + $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 '
    文章发布失败:
    +
    +
      +
    1. '.$e->getMessage().'
    2. +
    +
    '; } - 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(){


- " disabled="disabled" /> + " readonly="readonly" /> e.g. 2011-10-28 9:35 or 2011-10-28 21:35

@@ -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; + } +?> + + +
+
+

新闻中心

+ +
+
+
+ + + +
+ +
+ + + + + + +
+ +

title;?>

+ + + +
+ + + + +
+ +
+ + \ No newline at end of file