From 3802a793be0e5842b2bb5285d8436efee47d117c Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Fri, 30 Nov 2012 09:03:41 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=B8=AA=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E9=80=89=E6=8B=A9=E5=A4=9A=E4=B8=AA=E6=A0=8F=E7=9B=AE?= =?UTF-8?q?=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 | 51 +++++++++++++++---- .../admin/views/scripts/news/newsadd.phtml | 28 +++++----- .../admin/views/scripts/news/newsedit.phtml | 28 +++++----- .../admin/views/scripts/news/newslist.phtml | 5 +- 4 files changed, 71 insertions(+), 41 deletions(-) diff --git a/application/admin/controllers/NewsController.php b/application/admin/controllers/NewsController.php index 86ea4040..83acf329 100644 --- a/application/admin/controllers/NewsController.php +++ b/application/admin/controllers/NewsController.php @@ -42,14 +42,19 @@ class Admin_NewsController extends Zend_Controller_Action left join ".$News->tbl_catalog." ct on ct.aid=n.id left join ".$News->tbl_categorys." c on c.id = ct.cid LEFT JOIN users u ON n.userid=u.id - WHERE c.id='$type' order by n.ts_created desc"; + WHERE c.id='$type' AND n.title IS NOT NULL order by n.ts_created desc"; }else { - $sql = "select n.*,c.id as typeid,c.title as catlog,c.code from ".$News->tbl_archives." n + $sql = "select + n.id,n.title,n.userid,n.ts_published,n.is_pub + from ".$News->tbl_archives." n left join ".$News->tbl_catalog." ct on ct.aid=n.id left join ".$News->tbl_categorys." c on c.id = ct.cid LEFT JOIN users u ON n.userid=u.id - order by n.ts_created desc"; + WHERE n.title IS NOT NULL + GROUP BY n.id + ORDER BY n.ts_created desc + "; } $rs = $this->db->query($sql); $rows = $rs->fetchAll(); @@ -277,7 +282,17 @@ class Admin_NewsController extends Zend_Controller_Action $News = new news($this->db); $id = $this->_request->getParam('id'); - $this->view->typeid = $id; + + $sql = "SELECT * FROM ar_catalog WHERE aid=$id"; + $sth = $this->db->query($sql); + $rows = $sth->fetchAll(); + + $types = array(); + foreach($rows as $k=>$v) + { + $types[$v['id']] = $v['cid']; + } + $this->view->typeid = $types; $sql = "select arc.*,ct.cid as typeid from ".$News->tbl_archives." arc LEFT JOIN ".$News->tbl_catalog." ct ON arc.id=ct.aid @@ -345,7 +360,11 @@ class Admin_NewsController extends Zend_Controller_Action if(mb_strlen($keyword)>200) $msg[] = "关键词长度不能超过200个字符,现在输入了".strlen($keyword)."个字符"; if(mb_strlen($description)>400) $msg[] = "内容描述不能超过200个字符,现在输入了".strlen($description)."个字符"; if(empty($body)) $msg[]="请填写内容"; - if($typeid==0) $msg[]="请选择栏目"; + if(empty($typeid)) $msg[]="请选择栏目"; + if(!is_array($typeid) || count($typeid)<1) + { + $msg[]="请选择栏目"; + } if(count($msg)>0) { @@ -399,9 +418,12 @@ class Admin_NewsController extends Zend_Controller_Action WHERE id=$update"; if($this->db->exec($sql)) { + if(!empty($keyword)) + { + $News->DeleteTags($update); + $News->MakeTags($update,$keyword); + } $News->ChangeCatalog($update,$typeid); - $News->DeleteTags($update); - $News->MakeTags($update,$keyword); echo '
修改成功!
'; @@ -430,8 +452,19 @@ class Admin_NewsController extends Zend_Controller_Action if($sth->execute()) { $temp = $sth->fetch(PDO::FETCH_ASSOC); - $News->ToCatalog($temp['id'],$typeid); - $News->MakeTags($temp['id'],$keyword); + if(is_array($typeid)) + { + foreach($typeid as $v) + { + $News->ToCatalog($temp['id'],$v); + } + }else{ + $News->ToCatalog($temp['id'],$typeid); + } + if(!empty($keyword)) + { + $News->MakeTags($temp['id'],$keyword); + } echo '
发布成功!
'; diff --git a/application/admin/views/scripts/news/newsadd.phtml b/application/admin/views/scripts/news/newsadd.phtml index 9e135151..d1073930 100644 --- a/application/admin/views/scripts/news/newsadd.phtml +++ b/application/admin/views/scripts/news/newsadd.phtml @@ -29,6 +29,8 @@ .tagInputSuggestedTagList .tag{ padding:1px 4px;cursor:pointer;display:inline-block;margin:2px 1px;border:1px solid #bbb;} .tagInputSuggestedTagList span.tag:hover{background-color:#bbb;color:#fff;} .tagInputSuggestedTagList .tagUsed{border:1px solid #999;background-color:#999;color:#fff;} +.width3{width:40%;} +.first{float:left;}