From ab243ec84f633c99e1f1b7a4bad077f90640f17b Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Tue, 6 Nov 2012 03:19:24 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E9=97=BB=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E5=90=8E=E5=8F=B0=E6=A0=8F=E7=9B=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E6=B5=81=E7=A8=8B=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E5=8F=B0=E6=96=B0=E9=97=BB=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/NewsController.php | 52 ++++++++++++++----- .../views/scripts/news/category-add.phtml | 38 ++++++++++---- .../default/controllers/NewsController.php | 9 +--- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/application/admin/controllers/NewsController.php b/application/admin/controllers/NewsController.php index 46968a08..b6d666b4 100644 --- a/application/admin/controllers/NewsController.php +++ b/application/admin/controllers/NewsController.php @@ -80,21 +80,49 @@ class Admin_NewsController extends Zend_Controller_Action if($add) { + $this->_helper->viewRenderer('category-add'); + $this->view->categories = $this->getAllcategory(); if(empty($submit)){ - $this->view->categories = $this->getAllcategory(); - $this->_helper->viewRenderer('category-add'); - }else{ - $title = $this->_request->getParam('ctitle'); - $url = $this->_request->getParam('url'); - $keyword = $this->_request->getParam('keyword'); - $description = $this->_request->getParam('description'); - $fid = $this->_request->getParam('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) + //$this->_helper->viewRenderer('category-add'); + }else{ + $data = array(); + + $data['title'] = $this->_request->getParam('ctitle'); + $data['url'] = $this->_request->getParam('url'); + $data['keywords'] = $this->_request->getParam('keyword'); + $data['description'] = $this->_request->getParam('description'); + $data['fid'] = $this->_request->getParam('fid'); + $data['display'] = 1; + + $this->view->info = $data; + + if(empty($data['title'])) { - $this->messenger->addMessage('提示信息:栏目添加成功!'); - $this->_redirect('/admin/news/catlog'); + $this->view->error = "请输入标题"; + return true; + } + + if(empty($data['url'])) + { + $this->view->error = "请输入栏目连接,如http://westdc.westgis.ac.cn/news/notice,则只需要输入notice"; + return true; + } + + if(!preg_match("/^[a-z]+$/",$data['url'])) + { + $this->view->error = "url格式不正确,仅允许26个小写字母"; + return true; + } + + if($this->db->insert("news_category",$data)) + { + $this->view->msg = '提示信息:栏目添加成功!'; + $this->view->jump_url = '/admin/news/catlog'; + return true; + }else{ + $this->view->error = "添加失败,请重试"; + return true; } } diff --git a/application/admin/views/scripts/news/category-add.phtml b/application/admin/views/scripts/news/category-add.phtml index 609ffb58..5095ce8c 100644 --- a/application/admin/views/scripts/news/category-add.phtml +++ b/application/admin/views/scripts/news/category-add.phtml @@ -13,15 +13,13 @@ partial('news/left.phtml'); ?>
-msg or $this->messages) :?> + +error)) :?>
-msg) : ?> -

msg; ?>

-messages): foreach($this->messages as $msg): ?> -

- +error;?>
- + +msg)) {?>
@@ -29,7 +27,7 @@


- +

@@ -38,7 +36,16 @@ categories)) :?> categories as $v) : ?> + info['fid'])) {?> + info['fid'] == $v['id']) + { ?> + + + + @@ -46,19 +53,21 @@


- (仅小写英文字母与数字) + (仅小写英文字母与数字) 如填写: technology 则前台访问地址为: http://westdc.westgis.ac.cn/news/technology


- + e.g. 高程,气象,地理


- + 80个汉字以内,不能使用折行

@@ -69,4 +78,11 @@
+ +
+ × + msg ?> +
+ +
\ No newline at end of file diff --git a/application/default/controllers/NewsController.php b/application/default/controllers/NewsController.php index b712461e..8cf6fb56 100644 --- a/application/default/controllers/NewsController.php +++ b/application/default/controllers/NewsController.php @@ -1,13 +1,13 @@ view->config = Zend_Registry::get('config'); $this->db=Zend_Registry::get('db'); - $this->messenger=$this->_helper->getHelper('FlashMessenger'); - $this->view->messages = $this->messenger->getMessages(); } function indexAction() @@ -116,11 +116,6 @@ class NewsController extends Zend_Controller_Action $sql .= " LEFT JOIN news_category type ON arc.typeid=type.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 = "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); $row = $rs->fetch();