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 '