增加了元数据评论后发送邮件到管理员邮箱的功能
This commit is contained in:
parent
a983f5c52d
commit
d517bcdee4
|
@ -255,7 +255,7 @@ class DataController extends Zend_Controller_Action
|
||||||
if (!empty($keyword))
|
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=?';
|
$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."】";
|
$this->view->codename.="【关键词:".$keyword."】";
|
||||||
}else{
|
}else{
|
||||||
$sql='select count(m.id) as count from normalmetadata m,dataseries d where m.id=d.id and d.sid=?';
|
$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) {
|
if ($code>0 && $code<20) {
|
||||||
$where=$this->db->quoteInto('code = ?',$code);
|
$where=$this->db->quoteInto('code = ?',$code);
|
||||||
$row=$this->db->fetchRow("select * from categorycode where ".$where);
|
$row=$this->db->fetchRow("select * from categorycode where ".$where);
|
||||||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
$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=?';
|
$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));
|
$row=$this->db->fetchRow($sql,array($code));
|
||||||
$sum=$row['count'];
|
$sum=$row['count'];
|
||||||
$select=$this->db->select();
|
$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);
|
$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->metadata=$this->db->fetchAll($select);
|
||||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||||
} else {
|
} else {
|
||||||
//提供全部分类列表
|
//提供全部分类列表
|
||||||
|
@ -524,8 +524,8 @@ class DataController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
function viewAction()
|
function viewAction()
|
||||||
{
|
{
|
||||||
$id = (int)$this->_request->getParam('id');
|
$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
|
$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 ";
|
left join thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid where ";
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$uuid = $this->_request->getParam('uuid');
|
$uuid = $this->_request->getParam('uuid');
|
||||||
|
@ -533,20 +533,20 @@ class DataController extends Zend_Controller_Action
|
||||||
$where=$this->db->quoteInto('m.uuid = ?',$uuid);
|
$where=$this->db->quoteInto('m.uuid = ?',$uuid);
|
||||||
} else {
|
} else {
|
||||||
$where=$this->db->quoteInto('m.id = ?',$id);
|
$where=$this->db->quoteInto('m.id = ?',$id);
|
||||||
}
|
}
|
||||||
$sql.=$where;
|
$sql.=$where;
|
||||||
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
|
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||||
$row=$this->db->fetchRow($sql);
|
$row=$this->db->fetchRow($sql);
|
||||||
if (!$row) $this->_redirect('/data');
|
if (!$row) $this->_redirect('/data');
|
||||||
$id=$row->id;
|
$id=$row->id;
|
||||||
$uuid=$row->uuid;
|
$uuid=$row->uuid;
|
||||||
$this->view->metadata=$row;
|
$this->view->metadata=$row;
|
||||||
//提前对表格进行预处理
|
//提前对表格进行预处理
|
||||||
$wiki=new WikiFormat();
|
$wiki=new WikiFormat();
|
||||||
$this->view->metadata->description=$wiki->parseTable($this->view->escape($row->description));
|
$this->view->metadata->description=$wiki->parseTable($this->view->escape($row->description));
|
||||||
//处理外部链接
|
//处理外部链接
|
||||||
$this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$this->view->metadata->description);
|
$this->view->metadata->description=preg_replace('/\[\s*(http:\/\/.+?)\s+(.*?)\]/m','<a href="$1">$2</a>',$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='/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);
|
$this->view->thumburl.='/public/'.str_replace('_s.','.',$row->filename);
|
||||||
if (is_numeric($row->projection))
|
if (is_numeric($row->projection))
|
||||||
{
|
{
|
||||||
|
@ -627,7 +627,8 @@ class DataController extends Zend_Controller_Action
|
||||||
if ($this->_request->isPost()) {
|
if ($this->_request->isPost()) {
|
||||||
include_once("bcspamblock.php");
|
include_once("bcspamblock.php");
|
||||||
$formdata=$this->_request->getPost();
|
$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(?,?,?,?,?,?,?,?,?)";
|
$sql="insert into comments (userid,uuid,author,email,url,ip,content,agent,type) values(?,?,?,?,?,?,?,?,?)";
|
||||||
$agent=$this->_request->getHeader('User-Agent');
|
$agent=$this->_request->getHeader('User-Agent');
|
||||||
$ip=$this->_request->getServer('REMOTE_ADDR');
|
$ip=$this->_request->getServer('REMOTE_ADDR');
|
||||||
|
@ -636,6 +637,25 @@ class DataController extends Zend_Controller_Action
|
||||||
$content=$stripper->filter($formdata['content']);
|
$content=$stripper->filter($formdata['content']);
|
||||||
$author=$stripper->filter($formdata['author']);
|
$author=$stripper->filter($formdata['author']);
|
||||||
$this->db->query($sql,array($formdata['uid'],$formdata['uuid'],$author,$formdata['email'],$formdata['url'],$ip,$content,$agent,$type));
|
$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']='';
|
$formdata['content']='';
|
||||||
}
|
}
|
||||||
} elseif ($user) {
|
} elseif ($user) {
|
||||||
|
@ -1365,34 +1385,34 @@ class DataController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$this->_helper->layout->disableLayout();
|
$this->_helper->layout->disableLayout();
|
||||||
$this->_helper->viewRenderer->setNoRender();
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
$uuid=$this->_request->getParam('uuid');
|
$uuid=$this->_request->getParam('uuid');
|
||||||
$review=$this->_request->getParam('review');
|
$review=$this->_request->getParam('review');
|
||||||
if (!empty($uuid))
|
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);
|
$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="select r.* from reference r left join mdref m on m.refid=r.id where m.uuid=?";
|
||||||
$sql=$this->db->quoteInto($sql,$uuid);
|
$sql=$this->db->quoteInto($sql,$uuid);
|
||||||
$ref=$this->db->fetchAll($sql);
|
$ref=$this->db->fetchAll($sql);
|
||||||
$reference='<ol>';
|
$reference='<ol>';
|
||||||
foreach($ref as $refer)
|
foreach($ref as $refer)
|
||||||
{
|
{
|
||||||
$reference.='<li>'.$refer['reference'].'</li>';
|
$reference.='<li>'.$refer['reference'].'</li>';
|
||||||
}
|
}
|
||||||
$reference.='</ol>';
|
$reference.='</ol>';
|
||||||
if (is_numeric($row['projection']))
|
if (is_numeric($row['projection']))
|
||||||
{
|
{
|
||||||
$sql="select proj4text from spatial_ref_sys where auth_srid=?";
|
$sql="select proj4text from spatial_ref_sys where auth_srid=?";
|
||||||
$rs=$this->db->fetchRow($sql,array($row['projection']));
|
$rs=$this->db->fetchRow($sql,array($row['projection']));
|
||||||
if ($rs) $projection=$rs['proj4text'];
|
if ($rs) $projection=$rs['proj4text'];
|
||||||
}
|
}
|
||||||
if (empty($projection)) $projection=$row['projection'];
|
if (empty($projection)) $projection=$row['projection'];
|
||||||
} else
|
} else
|
||||||
$projection='';
|
$projection='';
|
||||||
|
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->loadXML($row['data']);
|
$dom->loadXML($row['data']);
|
||||||
//提前对表格进行预处理
|
//提前对表格进行预处理
|
||||||
$wiki=new WikiFormat();
|
$wiki=new WikiFormat();
|
||||||
$abs=$wiki->parseTable($this->view->escape($row["description"]));
|
$abs=$wiki->parseTable($this->view->escape($row["description"]));
|
||||||
//处理外部链接
|
//处理外部链接
|
||||||
|
@ -1404,8 +1424,8 @@ class DataController extends Zend_Controller_Action
|
||||||
$xslt = new XSLTProcessor();
|
$xslt = new XSLTProcessor();
|
||||||
$xslt->registerPHPFunctions();
|
$xslt->registerPHPFunctions();
|
||||||
$xslt->setParameter('', 'thumburl', $thumburl);
|
$xslt->setParameter('', 'thumburl', $thumburl);
|
||||||
$xslt->setParameter('', 'abstract', $abs);
|
$xslt->setParameter('', 'abstract', $abs);
|
||||||
$xslt->setParameter('','projection',$projection);
|
$xslt->setParameter('','projection',$projection);
|
||||||
$xslt->setParameter('','reference',$reference);
|
$xslt->setParameter('','reference',$reference);
|
||||||
$XSL = new DOMDocument();
|
$XSL = new DOMDocument();
|
||||||
$XSL->load( '../data/doc.xsl', LIBXML_NOCDATA);
|
$XSL->load( '../data/doc.xsl', LIBXML_NOCDATA);
|
||||||
|
@ -1432,7 +1452,7 @@ class DataController extends Zend_Controller_Action
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>';
|
<body>';
|
||||||
$content.=$xslt->transformToXML($dom);
|
$content.=$xslt->transformToXML($dom);
|
||||||
if ($review==1) $content.=file_get_contents('../data/review-table.htm',true);
|
if ($review==1) $content.=file_get_contents('../data/review-table.htm',true);
|
||||||
$content.="</body></html>";
|
$content.="</body></html>";
|
||||||
$this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
|
$this->getResponse()->setHeader('Content-Type', 'application/vnd.ms-doc')
|
||||||
|
|
Loading…
Reference in New Issue