diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php index 0b67055d..56be0ff0 100755 --- a/application/default/controllers/DataController.php +++ b/application/default/controllers/DataController.php @@ -255,7 +255,7 @@ class DataController extends Zend_Controller_Action if (!empty($keyword)) { $sql='select count(m.id) as count from normalmetadata m,dataseries d,keyword k where m.id=d.id and m.id=k.id and d.sid=? and k.keyword=?'; - $row=$this->db->fetchAll($sql,array($id,$keyword)); + $row=$this->db->fetchAll($sql,array($id,$keyword)); $this->view->codename.="【关键词:".$keyword."】"; }else{ $sql='select count(m.id) as count from normalmetadata m,dataseries d where m.id=d.id and d.sid=?'; @@ -290,13 +290,13 @@ class DataController extends Zend_Controller_Action if ($code>0 && $code<20) { $where=$this->db->quoteInto('code = ?',$code); $row=$this->db->fetchRow("select * from categorycode where ".$where); - $this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']); - $sql='select count(m.id) from normalmetadata m left join category c on m.id=c.id where c.code=?'; - $row=$this->db->fetchRow($sql,array($code)); - $sum=$row['count']; - $select=$this->db->select(); - $select->from('normalmetadata as m','*')->joinLeft('category as c','m.id=c.id')->where('c.code=?',$code)->order('m.title')->limitPage($page,$this->limit); - $this->view->metadata=$this->db->fetchAll($select); + $this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']); + $sql='select count(m.id) from normalmetadata m left join category c on m.id=c.id where c.code=?'; + $row=$this->db->fetchRow($sql,array($code)); + $sum=$row['count']; + $select=$this->db->select(); + $select->from('normalmetadata as m','*')->joinLeft('category as c','m.id=c.id')->where('c.code=?',$code)->order('m.title')->limitPage($page,$this->limit); + $this->view->metadata=$this->db->fetchAll($select); $this->view->page=new Pagination($sum,$page,$this->limit); } else { //提供全部分类列表 @@ -524,8 +524,8 @@ class DataController extends Zend_Controller_Action */ function viewAction() { - $id = (int)$this->_request->getParam('id'); - $sql="select m.*,s.status,g.id as gid,t.filename from normalmetadata m left join mdstatus s on m.uuid=s.uuid + $id = (int)$this->_request->getParam('id'); + $sql="select m.*,s.status,g.id as gid,t.filename from normalmetadata m left join mdstatus s on m.uuid=s.uuid left join thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid where "; if (empty($id)) { $uuid = $this->_request->getParam('uuid'); @@ -533,20 +533,20 @@ class DataController extends Zend_Controller_Action $where=$this->db->quoteInto('m.uuid = ?',$uuid); } else { $where=$this->db->quoteInto('m.id = ?',$id); - } - $sql.=$where; - $this->db->setFetchMode(Zend_Db::FETCH_OBJ); + } + $sql.=$where; + $this->db->setFetchMode(Zend_Db::FETCH_OBJ); $row=$this->db->fetchRow($sql); if (!$row) $this->_redirect('/data'); $id=$row->id; $uuid=$row->uuid; $this->view->metadata=$row; - //提前对表格进行预处理 + //提前对表格进行预处理 $wiki=new WikiFormat(); $this->view->metadata->description=$wiki->parseTable($this->view->escape($row->description)); //处理外部链接 - $this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','$2',$this->view->metadata->description); - $this->view->thumburl='/gndata/'.sprintf('%05d',floor(($row->gid+0.1)/100)*100).'-'.sprintf('%05d',ceil(($row->gid+0.1)/100)*100-1)."/".$row->gid; + $this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','$2',$this->view->metadata->description); + $this->view->thumburl='/gndata/'.sprintf('%05d',floor(($row->gid+0.1)/100)*100).'-'.sprintf('%05d',ceil(($row->gid+0.1)/100)*100-1)."/".$row->gid; $this->view->thumburl.='/public/'.str_replace('_s.','.',$row->filename); if (is_numeric($row->projection)) { @@ -627,7 +627,8 @@ class DataController extends Zend_Controller_Action if ($this->_request->isPost()) { include_once("bcspamblock.php"); $formdata=$this->_request->getPost(); - if (bcspamblock_verify() && $commentForm->isValid($formdata)) { + //if (bcspamblock_verify() && $commentForm->isValid($formdata)) { + if ( $commentForm->isValid($formdata)) { $sql="insert into comments (userid,uuid,author,email,url,ip,content,agent,type) values(?,?,?,?,?,?,?,?,?)"; $agent=$this->_request->getHeader('User-Agent'); $ip=$this->_request->getServer('REMOTE_ADDR'); @@ -636,6 +637,25 @@ class DataController extends Zend_Controller_Action $content=$stripper->filter($formdata['content']); $author=$stripper->filter($formdata['author']); $this->db->query($sql,array($formdata['uid'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type)); + $patt = array(); + $patt['user'] = $author; + $patt['uuid'] = $formdata['uuid']; + $patt['title']= $this->view->metadata->title; + $patt['content']= $content; + /* + $patt = array( + 'user' =>$author, + 'uuid' =>$formdata['uuid'], + 'title' =>$this->view->metadata['title'], + //'content' =>$content + );*/ + $mailtp=new EmailText($this->db,"data-comments-posted",$patt); + $mail=new WestdcMailer($this->view->config->smtp); + $mail->setBodyText($mailtp->getBody()); + $mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); + $mail->addTo($this->view->config->service->email); + $mail->setSubject($mailtp->getSubject()); + @$mail->send(); $formdata['content']=''; } } elseif ($user) { @@ -1365,34 +1385,34 @@ class DataController extends Zend_Controller_Action { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); - $uuid=$this->_request->getParam('uuid'); + $uuid=$this->_request->getParam('uuid'); $review=$this->_request->getParam('review'); if (!empty($uuid)) { $sql="select x.data,m.title,m.description,g.id,m.projection from xml x left join metadata m on m.id=x.id left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid); - $row=$this->db->fetchRow($sql); + $row=$this->db->fetchRow($sql); $sql="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?"; $sql=$this->db->quoteInto($sql,$uuid); - $ref=$this->db->fetchAll($sql); - $reference='