diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php
index 8705941c..129555aa 100644
--- a/application/default/controllers/AuthorController.php
+++ b/application/default/controllers/AuthorController.php
@@ -431,7 +431,7 @@ class AuthorController extends Zend_Controller_Action
if(empty($ac) || $ac=='list' || $ac=='search'){
$sql = "SELECT a.*,m.title,m.description,g.id as gid FROM normalmetadata m
- LEFT JOIN mdauthor a ON m.uuid=a.uuid
+ LEFT JOIN mdauthor a ON m.uuid=a.uuid
left join geonetworkmetadata g on m.uuid=g.uuid
WHERE a.userid=? AND status>=0";
if ($ac=='search')
@@ -1190,6 +1190,12 @@ class AuthorController extends Zend_Controller_Action
$user = $auth->getIdentity();
$u_id = $user->id;
}
+
+ //新闻列表
+ if(empty($ac) || $ac=="list")
+ {
+
+ }
//新闻发布
if($ac == "add")
@@ -1200,94 +1206,114 @@ class AuthorController extends Zend_Controller_Action
//新闻发布的ajax动作
if($ac =="addnews")
{
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $data = array();
-
- $data['title'] = $this->_request->getParam('title');
- $data['keyword'] = $this->_request->getParam('keyword');
- $data['body'] = $this->_request->getParam('body');
-
- //对参数进行预处理
- foreach($data as $k=>$v)
- {
- $data[$k]=preg_replace("#]*)>(.*)#i","",$v);
- $data[$k]=preg_replace("##i","",$v);
- $data[$k]=preg_replace("##i","",$v);
- $data[$k]=str_replace("\"","“",$v);
- $data[$k]=str_replace("\'","‘",$v);
+ try{
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $data = array();
+
+ $data['title'] = $this->_request->getParam('title');
+ $data['keyword'] = $this->_request->getParam('keyword');
+ $data['body'] = $this->_request->getParam('body');
+
+ //对参数进行预处理
+ foreach($data as $k=>$v)
+ {
+ $data[$k]=preg_replace("#]*)>(.*)#i","",$v);
+ $data[$k]=preg_replace("##i","",$v);
+ $data[$k]=preg_replace("##i","",$v);
+ $data[$k]=str_replace("\"","“",$v);
+ $data[$k]=str_replace("\'","‘",$v);
+ }
+
+ $msg = array();
+
+ // 合法性判断
+ if(mb_strlen($data['title'],"utf-8")<3)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = '标题太短,请重新填写';
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+
+ if(mb_strlen($data['title'],"utf-8")>60)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = '标题太长,请重新填写';
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+
+ if(mb_strlen($data['keyword'],"utf-8")<4)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = '关键词太短,请重新填写';
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+
+ if(mb_strlen($data['keyword'],"utf-8")>40)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = '关键词太长,请重新填写';
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+
+ if(mb_strlen($data['body'],"utf-8")<40)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = '新闻内容太短,请重新填写';
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+
+ //获得描述
+ //删除段落及html标记
+ $data['description'] = mb_substr(preg_replace(array("/<(.*)>|<(.*) \/>/i","/\s/i"),array(""," "),$data['body']),0,450,"UTF-8");
+
+ //默认填充数据
+ $data['source'] = "西部数据中心";
+ $data['typeid'] = 0;
+ $data['userid'] = $u_id;
+
+ $sql = "INSERT INTO news_archives
+ (userid,title,keywords,description,image,source,ts_publish,is_pub,body)
+ VALUES
+ (?,?,?,?,?,?,?,?,?)
+ ";
+
+ $sth = $this->db->prepare($sql);
+ $ex = $sth -> execute(array($data['userid'],$data['title'],$data['keyword'],$data['description'],'',$data['source'],'now()',1,$data['body']));
+
+ if($ex)
+ {
+ $msg['status'] = 1;
+ $msg['outstring'] = "新闻添加成功";
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }else{
+ $msg['status'] = 0;
+ $msg['error'] = "新闻添加失败,请重试";
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
+ }catch(Exception $e){
+ if($this->debug==0)
+ {
+ $msg['status'] = 0;
+ $msg['error'] = "新闻添加失败,请重试";
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }else{
+ $msg['status'] = 0;
+ $msg['error'] = "新闻添加失败,请重试:".$e->getMessage();
+ $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
+ return true;
+ }
}
- $msg = array();
-
- // 合法性判断
- if(mb_strlen($data['title'],"utf-8")<=6)
- {
- $msg['status'] = 0;
- $msg['error'] = '标题太短,请重新填写';
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
- }
-
- if(mb_strlen($data['title'],"utf-8")>=60)
- {
- $msg['status'] = 0;
- $msg['error'] = '标题太长,请重新填写';
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
- }
-
- if(mb_strlen($data['keyword'],"utf-8")<=4)
- {
- $msg['status'] = 0;
- $msg['error'] = '关键词太短,请重新填写';
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
- }
-
- if(mb_strlen($data['keyword'],"utf-8")>=40)
- {
- $msg['status'] = 0;
- $msg['error'] = '关键词太长,请重新填写';
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
- }
-
- if(mb_strlen($data['body'],"utf-8")<40)
- {
- $msg['status'] = 0;
- $msg['error'] = '新闻内容太短,请重新填写';
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
- }
-
- //获得描述
- $data['description'] = mb_substr(preg_replace("/<(.*)>.*<\/\1>|<(.*) \/>/","",$data['body']),0,450,"UTF-8");
-
- //默认填充数据
- $data['source'] = "西部数据中心";
- $data['typeid'] = 0;
- $data['userid'] = $u_id;
-
- $sql = "INSERT INTO news_archives
- (userid,title,keywords,description,image,source,ts_publish,is_pub,body)
- VALUES
- (?,?,?,?,?,?,?,?,?)
-
- ";
-
- $sth = $this->db->prepare($sql);
- $sth -> execute(array($data['userid'],$data['title'],$data['keyword'],$data['description'],'',$data['source'],'now()',1,$data['body']));
-
-
-
-
- $msg['status'] = 1;
- $msg['outstring'] = "新闻添加成功";
-
- $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($msg));
- return true;
}