diff --git a/application/default/controllers/ServiceController.php b/application/default/controllers/ServiceController.php index d02f88f7..21e1b5c3 100644 --- a/application/default/controllers/ServiceController.php +++ b/application/default/controllers/ServiceController.php @@ -1,46 +1,46 @@ -_helper->viewRenderer->setNoRender(); - $this->_helper->layout->disableLayout(); - } - - function preDispatch() - { - $this->db=Zend_Registry::get('db'); - $this->view->config = Zend_Registry::get('config'); - $this->messenger=$this->_helper->getHelper('FlashMessenger'); - $this->view->messages = $this->messenger->getMessages(); - } - - /* - * 返回XML源文件 - */ - function xmlAction() - { - $uuid=$this->_request->getParam('uuid'); - $row=$this->db->fetchRow("select xml.data from xml left join metadata on xml.id=metadata.id where metadata.uuid=?",array($uuid)); - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - $this->getResponse()->setHeader('Content-Type', 'text/xml') - ->setBody($row['data']); - } - /* - * 查看数据缩略图 - */ - function thumbAction() - { - $id = (int)$this->_request->getParam('id'); +_helper->viewRenderer->setNoRender(); + $this->_helper->layout->disableLayout(); + } + + function preDispatch() + { + $this->db=Zend_Registry::get('db'); + $this->view->config = Zend_Registry::get('config'); + $this->messenger=$this->_helper->getHelper('FlashMessenger'); + $this->view->messages = $this->messenger->getMessages(); + } + + /* + * 返回XML源文件 + */ + function xmlAction() + { + $uuid=$this->_request->getParam('uuid'); + $row=$this->db->fetchRow("select xml.data from xml left join metadata on xml.id=metadata.id where metadata.uuid=?",array($uuid)); + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $this->getResponse()->setHeader('Content-Type', 'text/xml') + ->setBody($row['data']); + } + /* + * 查看数据缩略图 + */ + function thumbAction() + { + $id = (int)$this->_request->getParam('id'); if (empty($id)) { $uuid = $this->_request->getParam('uuid'); if (empty($uuid)) $this->_redirect('/data'); $where=$this->db->quoteInto('m.uuid = ?',$uuid); } else { $where=$this->db->quoteInto('m.id = ?',$id); - } + } $sql="select t.* from thumbnail t left join metadata m on t.id=m.id where ".$where; $thumb=$this->db->fetchRow($sql); $this->_helper->layout->disableLayout(); @@ -54,22 +54,22 @@ class ServiceController extends Zend_Controller_Action } else { header("Content-Type:image/".$thumb['filetype']); print base64_decode($thumb['data']); - } - } - - /* - * 查看数据缩略大图 - */ - function bigthumbAction() - { - $id = (int)$this->_request->getParam('id'); + } + } + + /* + * 查看数据缩略大图 + */ + function bigthumbAction() + { + $id = (int)$this->_request->getParam('id'); if (empty($id)) { $uuid = $this->_request->getParam('uuid'); if (empty($uuid)) $this->_redirect('/data'); $where=$this->db->quoteInto('m.uuid = ?',$uuid); } else { $where=$this->db->quoteInto('m.id = ?',$id); - } + } $sql="select g.id as gid,t.filename,t.filetype from geonetworkmetadata g left join metadata m on g.uuid=m.uuid left join thumbnail t on t.id=m.id where ".$where; $thumb=$this->db->fetchRow($sql); $this->_helper->layout->disableLayout(); @@ -80,181 +80,181 @@ class ServiceController extends Zend_Controller_Action $file=fopen("images/nothumb.png",'r'); fpassthru($file); exit; - } else { - $url=$this->view->config->bigthumb->path.sprintf('%05d',floor(($thumb['gid']+0.1)/100)*100).'-'.sprintf('%05d',ceil(($thumb['gid']+0.1)/100)*100-1)."/".$thumb['gid']; + } else { + $url=$this->view->config->bigthumb->path.sprintf('%05d',floor(($thumb['gid']+0.1)/100)*100).'-'.sprintf('%05d',ceil(($thumb['gid']+0.1)/100)*100-1)."/".$thumb['gid']; $url.='/public/'.str_replace('_s.','.',$thumb['filename']); header("Content-Type:image/".$thumb['filetype']); $file=fopen($url,'r'); fpassthru($file); exit; - } - } - /* - * 搜索, no page, json output - */ - function searchAction() - { - $this->view->addHelperPath('helper','Zend_View_Helper_'); - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - //$page=(int)$this->_request->getParam('page'); - //if (empty($page)) $page=1; - //$offset=$this->limit*($page-1); - $key=$this->_request->getParam('q'); - $n=(int)$this->_request->getParam('n'); - $s=(int)$this->_request->getParam('s'); - $e=(int)$this->_request->getParam('e'); - $w=(int)$this->_request->getParam('w'); - if (!(empty($n) && empty($key))) { - if (empty($n)) $n=90; - if (empty($s)) $s=-90; - if (empty($e)) $e=180; - if (empty($w)) $w=-180; - //$start=$this->_request->getParam('start'); - //$end=$this->_request->getParam('end'); - $sql="select id,title,uuid,description,filesize,fileformat from metadata where east? and north?"; - if (!empty($key)) { - $sql.= " and (title ilike ? or description ilike ?)"; - $sql.= " order by title"; - $rows=$this->db->fetchAll($sql,array($e,$w,$n,$s,'%'.$key.'%','%'.$key.'%')); - } else { - $sql.= " order by title"; - $rows=$this->db->fetchAll($sql,array($e,$w,$n,$s)); - } - $this->_helper->json($rows); - } - } - - - /* - * 产生geojson数据 - */ - function jsonAction() - { - $md=new MetadataTable(); - $db=$md->getAdapter(); - $id = (int)$this->_request->getParam('id'); - $where=''; - if (!empty($id)) { $where=' where id='.$id; } - $sql='select id,uuid,west,south,north,east,title from metadata'.$where; - $state=$db->query($sql); - $rows=$state->fetchAll(); - $geomd=new GeoMetaData(); - foreach($rows as $row){ - if ($id) - $box=new GeoBox($row['west'],$row['south'],$row['east'],$row['north']); - else - $box=new GeoBoxLine($row['west'],$row['south'],$row['east'],$row['north']); - $feature=new Geofeature(); - $feature->id=$row['id']; - $feature->addProperties('title',$row['title']); - $feature->addProperties('uuid',$row['uuid']); - $feature->addProperties('id',$row['id']); - $feature->geometry=$box; - $geomd->addFeature($feature); - } - $this->_helper->json($geomd); - } - - function detailAction() - { - $id=(int)$this->_request->getParam('id'); - $xml=new XmlTable(); - $db=$xml->getAdapter(); - $where=$db->quoteInto('id=?',$id); - $order='id desc'; - $row=$xml->fetchRow($where,$order); - // Load the XML source - $xml = new DOMDocument; - $xml->loadXML($row->data); - $xsl = new DOMDocument; - $xsl->load($this->view->config->westdc->xsl); - // Configure the transformer - $proc = new XSLTProcessor; - $proc->importStyleSheet($xsl); // attach the xsl rules - $this->view->xml=$proc->transformToXML($xml); - //$this->_helper->layout->disableLayout(); - //$this->_helper->viewRenderer->setNoRender(); - //$this->getResponse()->setHeader('Content-Type', 'text/html') - // ->setBody($proc->transformToXML($xml)); - } - function feedAction() - { - $feedArray = array( - 'title' => '中国西部环境与生态科学数据中心', - 'link' => 'http://'.$_SERVER['SERVER_NAME'].'/data/feed', - 'description' => '共享西部计划产生的数据', - 'language' => 'zh-CN', - 'charset' => 'utf-8', - 'published' => time(), - //'generator' => 'Zend Framework Zend_Feed', - 'entries' => array() - ); - $sql="select * from metadata order by ts_created desc"; - $rs=$this->db->fetchAll($sql); - $feedArray['published']=strtotime($rs[0]['ts_created']); - foreach($rs as $r) - { - $feedArray['entries'][] = array( - 'title' => $r['title'], - 'link' => 'http://'.$_SERVER['SERVER_NAME'].'/data/' . $r['uuid'], - 'guid' => 'http://'.$_SERVER['SERVER_NAME'].'/data/' . $r['uuid'], - //'content'=>$r['description'], - 'description' => $r['description'], - 'lastUpdate' => strtotime($r['ts_created']) - ); - } - $feed = Zend_Feed::importArray($feedArray,'rss'); - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - $feed->send(); - } - - public function pingbackAction() - { - $this->_helper->ViewRenderer->setNoRender(); - $this->_helper->layout->disableLayout(); - $server = new Zend_XmlRpc_Server(); - $server->setClass('PingbackRpc', 'pingback'); - echo $server->handle(); - } - - public function pingtestAction() - { - $this->_helper->ViewRenderer->setNoRender(); - $this->_helper->layout->disableLayout(); - $client = new Zend_XmlRpc_Client('http://test.westgis.ac.cn/data/pingback'); - $arg1 = 'http://wlx.westgis.ac.cn/567/'; - $arg2 = 'http://test.westgis.ac.cn/data/487591d0-d437-4114-b810-cbef7c4ee4b2'; - //$result = $client->call('pingback.ping', array($arg1, $arg2)); - $test = $client->getProxy('pingback'); - $test->ping($arg1,$arg2); - //var_dump($result); - } - public function outputAction() - { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - $sql="select title,datatype,filesize,id from metadata"; - $md=$this->db->fetchAll($sql); - foreach($md as $m) - { - print $m["title"].","; - print ($m["datatype"]?"内部":"公开").","; - print ($m["filesize"]==1?" ":$m["filesize"]).","; - $sql1="select keyword from keyword where id=".$m["id"]." and keytype='place'"; - $kd=$this->db->fetchAll($sql1); - foreach ($kd as $p) print $p["keyword"]." "; - print ","; - $sql1="select keyword from keyword where id=".$m["id"]." and keytype='temporal'"; - $kd=$this->db->fetchAll($sql1); - foreach ($kd as $p) print $p["keyword"]." "; - print ","; - print "
"; - } - - } - + } + } + /* + * 搜索, no page, json output + */ + function searchAction() + { + $this->view->addHelperPath('helper','Zend_View_Helper_'); + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + //$page=(int)$this->_request->getParam('page'); + //if (empty($page)) $page=1; + //$offset=$this->limit*($page-1); + $key=$this->_request->getParam('q'); + $n=(int)$this->_request->getParam('n'); + $s=(int)$this->_request->getParam('s'); + $e=(int)$this->_request->getParam('e'); + $w=(int)$this->_request->getParam('w'); + if (!(empty($n) && empty($key))) { + if (empty($n)) $n=90; + if (empty($s)) $s=-90; + if (empty($e)) $e=180; + if (empty($w)) $w=-180; + //$start=$this->_request->getParam('start'); + //$end=$this->_request->getParam('end'); + $sql="select id,title,uuid,description,filesize,fileformat from metadata where east? and north?"; + if (!empty($key)) { + $sql.= " and (title ilike ? or description ilike ?)"; + $sql.= " order by title"; + $rows=$this->db->fetchAll($sql,array($e,$w,$n,$s,'%'.$key.'%','%'.$key.'%')); + } else { + $sql.= " order by title"; + $rows=$this->db->fetchAll($sql,array($e,$w,$n,$s)); + } + $this->_helper->json($rows); + } + } + + + /* + * 产生geojson数据 + */ + function jsonAction() + { + $md=new MetadataTable(); + $db=$md->getAdapter(); + $id = (int)$this->_request->getParam('id'); + $where=''; + if (!empty($id)) { $where=' where id='.$id; } + $sql='select id,uuid,west,south,north,east,title from metadata'.$where; + $state=$db->query($sql); + $rows=$state->fetchAll(); + $geomd=new GeoMetaData(); + foreach($rows as $row){ + if ($id) + $box=new GeoBox($row['west'],$row['south'],$row['east'],$row['north']); + else + $box=new GeoBoxLine($row['west'],$row['south'],$row['east'],$row['north']); + $feature=new Geofeature(); + $feature->id=$row['id']; + $feature->addProperties('title',$row['title']); + $feature->addProperties('uuid',$row['uuid']); + $feature->addProperties('id',$row['id']); + $feature->geometry=$box; + $geomd->addFeature($feature); + } + $this->_helper->json($geomd); + } + + function detailAction() + { + $id=(int)$this->_request->getParam('id'); + $xml=new XmlTable(); + $db=$xml->getAdapter(); + $where=$db->quoteInto('id=?',$id); + $order='id desc'; + $row=$xml->fetchRow($where,$order); + // Load the XML source + $xml = new DOMDocument; + $xml->loadXML($row->data); + $xsl = new DOMDocument; + $xsl->load($this->view->config->westdc->xsl); + // Configure the transformer + $proc = new XSLTProcessor; + $proc->importStyleSheet($xsl); // attach the xsl rules + $this->view->xml=$proc->transformToXML($xml); + //$this->_helper->layout->disableLayout(); + //$this->_helper->viewRenderer->setNoRender(); + //$this->getResponse()->setHeader('Content-Type', 'text/html') + // ->setBody($proc->transformToXML($xml)); + } + function feedAction() + { + $feedArray = array( + 'title' => '中国西部环境与生态科学数据中心', + 'link' => 'http://'.$_SERVER['SERVER_NAME'].'/data/feed', + 'description' => '共享西部计划产生的数据', + 'language' => 'zh-CN', + 'charset' => 'utf-8', + 'published' => time(), + //'generator' => 'Zend Framework Zend_Feed', + 'entries' => array() + ); + $sql="select * from metadata order by ts_created desc"; + $rs=$this->db->fetchAll($sql); + $feedArray['published']=strtotime($rs[0]['ts_created']); + foreach($rs as $r) + { + $feedArray['entries'][] = array( + 'title' => $r['title'], + 'link' => 'http://'.$_SERVER['SERVER_NAME'].'/data/' . $r['uuid'], + 'guid' => 'http://'.$_SERVER['SERVER_NAME'].'/data/' . $r['uuid'], + //'content'=>$r['description'], + 'description' => $r['description'], + 'lastUpdate' => strtotime($r['ts_created']) + ); + } + $feed = Zend_Feed::importArray($feedArray,'rss'); + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $feed->send(); + } + + public function pingbackAction() + { + $this->_helper->ViewRenderer->setNoRender(); + $this->_helper->layout->disableLayout(); + $server = new Zend_XmlRpc_Server(); + $server->setClass('PingbackRpc', 'pingback'); + echo $server->handle(); + } + + public function pingtestAction() + { + $this->_helper->ViewRenderer->setNoRender(); + $this->_helper->layout->disableLayout(); + $client = new Zend_XmlRpc_Client('http://test.westgis.ac.cn/data/pingback'); + $arg1 = 'http://wlx.westgis.ac.cn/567/'; + $arg2 = 'http://test.westgis.ac.cn/data/487591d0-d437-4114-b810-cbef7c4ee4b2'; + //$result = $client->call('pingback.ping', array($arg1, $arg2)); + $test = $client->getProxy('pingback'); + $test->ping($arg1,$arg2); + //var_dump($result); + } + public function outputAction() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $sql="select title,datatype,filesize,id from metadata"; + $md=$this->db->fetchAll($sql); + foreach($md as $m) + { + print $m["title"].","; + print ($m["datatype"]?"内部":"公开").","; + print ($m["filesize"]==1?" ":$m["filesize"]).","; + $sql1="select keyword from keyword where id=".$m["id"]." and keytype='place'"; + $kd=$this->db->fetchAll($sql1); + foreach ($kd as $p) print $p["keyword"]." "; + print ","; + $sql1="select keyword from keyword where id=".$m["id"]." and keytype='temporal'"; + $kd=$this->db->fetchAll($sql1); + foreach ($kd as $p) print $p["keyword"]." "; + print ","; + print "
"; + } + + } + /* * 转换元数据为WORD DOC格式 */ @@ -343,8 +343,8 @@ class ServiceController extends Zend_Controller_Action ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') ->setHeader('Pragma','public') ->setBody($content); - } - + } + /* * 转换元数据为PDF格式 */ @@ -353,50 +353,50 @@ class ServiceController extends Zend_Controller_Action $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $uuid=$this->_request->getParam('uuid'); - $review=$this->_request->getParam('review'); + $review=$this->_request->getParam('review'); error_reporting(1); if (!empty($uuid)) { - $sql="select x.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.south,m.east,m.west,m.north,m.timebegin,m.timeend,m.title_en,m.uuid,m.description,g.id,m.projection,t.filetype, - cc.name as category, cc.name_zh as category_zh - from xml x left join metadata m on m.id=x.id left join thumbnail t on x.id=t.id - left join category c on c.id=m.id left join categorycode cc on c.code=cc.code + $sql="select x.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.south,m.east,m.west,m.north,m.timebegin,m.timeend,m.title_en,m.uuid,m.description,g.id,m.projection,t.filetype, + cc.name as category, cc.name_zh as category_zh + from xml x left join metadata m on m.id=x.id left join thumbnail t on x.id=t.id + left join category c on c.id=m.id left join categorycode cc on c.code=cc.code left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid); $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); + $ref=$this->db->fetchAll($sql); $reference=""; foreach($ref as $k=>$refer) { $reference.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$refer['reference'])."\r\n"; - } - $row['reference']=$reference; - $sql="select u.uselimit from mdlimit ml left join metadata m on ml.uuid=m.uuid left join uselimit u on ml.lid=u.id where m.uuid=?"; + } + $row['reference']=$reference; + $sql="select u.uselimit from mdlimit ml left join metadata m on ml.uuid=m.uuid left join uselimit u on ml.lid=u.id where m.uuid=?"; $sql=$this->db->quoteInto($sql,$uuid); - $limits=$this->db->fetchAll($sql); + $limits=$this->db->fetchAll($sql); $uselimits=""; foreach($limits as $k=>$limit) { - //$uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; + //$uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; $uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; - } - $row['uselimits']=$uselimits; - $sql="select ol.* from onlineresource ol left join metadata m on ol.uuid=m.uuid where m.uuid=?"; + } + $row['uselimits']=$uselimits; + $sql="select ol.* from onlineresource ol left join metadata m on ol.uuid=m.uuid where m.uuid=?"; $sql=$this->db->quoteInto($sql,$uuid); - $row['resources']=$this->db->fetchAll($sql); - $sql="select r.role,s.* from role r left join responsible s on r.resid=s.id left join metadata m on m.uuid=r.uuid where m.uuid=? order by r.role,r.id"; + $row['resources']=$this->db->fetchAll($sql); + $sql="select r.role,s.* from role r left join responsible s on r.resid=s.id left join metadata m on m.uuid=r.uuid where m.uuid=? order by r.role,r.id"; $sql=$this->db->quoteInto($sql,$uuid); - $row['contacts']=$this->db->fetchAll($sql); - - $sql="select k.keyword, k.keytype from keyword k left join metadata m on k.id=m.id where m.uuid=? order by k.keytype"; + $row['contacts']=$this->db->fetchAll($sql); + + $sql="select k.keyword, k.keytype from keyword k left join metadata m on k.id=m.id where m.uuid=? order by k.keytype"; $sql=$this->db->quoteInto($sql,$uuid); - $keys=$this->db->fetchAll($sql); - $keyword=array(); - foreach($keys as $key) - { - @$keyword[$key['keytype']].=$key['keyword'].','; - } + $keys=$this->db->fetchAll($sql); + $keyword=array(); + foreach($keys as $key) + { + @$keyword[$key['keytype']].=$key['keyword'].','; + } $row['keyword']=$keyword; if (is_numeric($row['projection'])) @@ -410,93 +410,93 @@ class ServiceController extends Zend_Controller_Action $projection=''; $dom = new DOMDocument(); - $dom->loadXML($row['data']); + $dom->loadXML($row['data']); $xpath = new DOMXpath($dom); - $row['rfdenom']=@$dom->getElementsByTagName('rfDenom')->item(0)->nodeValue; - $row['resolution']=@$xpath->query('//scaleDist/value/Real')->item(0)->nodeValue; - $row['resolution'].=@$dom->getElementsByTagName('uomName')->item(0)->nodeValue; + $row['rfdenom']=@$dom->getElementsByTagName('rfDenom')->item(0)->nodeValue; + $row['resolution']=@$xpath->query('//scaleDist/value/Real')->item(0)->nodeValue; + $row['resolution'].=@$dom->getElementsByTagName('uomName')->item(0)->nodeValue; //提前对表格进行预处理 /*$wiki=new WikiFormat(); - $row['description']=$wiki->parseTable($row["description"]); - preg_match_all('/[\s\S]*?<\/table>/im', $row['description'],$tables); - foreach($tables as $k=>$table) - { - $row['description']=str_replace($tables[$k],"\n 【表格内容暂不支持,请访问网站查看,此处请忽略】\n",$row['description']); - }*/ - $pdf=new MetadataPDF(); - $pdf->metadata=$row; - $pdf->Draw(); - $pdf->setTitle($row['title'],true); - $pdf->setAuthor('中国西部环境与生态科学数据中心',true); + $row['description']=$wiki->parseTable($row["description"]); + preg_match_all('/
[\s\S]*?<\/table>/im', $row['description'],$tables); + foreach($tables as $k=>$table) + { + $row['description']=str_replace($tables[$k],"\n 【表格内容暂不支持,请访问网站查看,此处请忽略】\n",$row['description']); + }*/ + $pdf=new MetadataPDF(); + $pdf->metadata=$row; + $pdf->Draw(); + $pdf->setTitle($row['title'],true); + $pdf->setAuthor('中国西部环境与生态科学数据中心',true); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); - //->setHeader('Content-Disposition','inline; filename="'.$row['title'].'.pdf"'); + //->setHeader('Content-Disposition','inline; filename="'.$row['title'].'.pdf"'); $pdf->Output($row['title'].'.pdf','I'); //die(); - } - public function odtAction() - { + } + public function odtAction() + { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $uuid=$this->_request->getParam('uuid'); - $review=$this->_request->getParam('review'); - //error_reporting(1); + $review=$this->_request->getParam('review'); + //error_reporting(1); if (!empty($uuid)) { - $sql="select x.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.south,m.east,m.west,m.north,m.timebegin,m.timeend,m.title_en,m.uuid,m.description,g.id,m.projection,t.filetype, - cc.name as category, cc.name_zh as category_zh - from xml x left join metadata m on m.id=x.id left join thumbnail t on x.id=t.id - left join category c on c.id=m.id left join categorycode cc on c.code=cc.code + $sql="select x.data,m.title,m.citation,m.suppinfo,m.doi,m.filesize,m.fileformat,m.south,m.east,m.west,m.north,m.timebegin,m.timeend,m.title_en,m.uuid,m.description,g.id,m.projection,t.filetype, + cc.name as category, cc.name_zh as category_zh + from xml x left join metadata m on m.id=x.id left join thumbnail t on x.id=t.id + left join category c on c.id=m.id left join categorycode cc on c.code=cc.code left join geonetworkmetadata g on g.uuid=m.uuid where m.uuid=".$this->db->quote($uuid); $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); + $ref=$this->db->fetchAll($sql); $reference=""; foreach($ref as $k=>$refer) { $reference.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$refer['reference'])."\r\n"; - } - $row['reference']=$reference; - $sql="select u.uselimit from mdlimit ml left join metadata m on ml.uuid=m.uuid left join uselimit u on ml.lid=u.id where m.uuid=?"; + } + $row['reference']=$reference; + $sql="select u.uselimit from mdlimit ml left join metadata m on ml.uuid=m.uuid left join uselimit u on ml.lid=u.id where m.uuid=?"; $sql=$this->db->quoteInto($sql,$uuid); - $limits=$this->db->fetchAll($sql); + $limits=$this->db->fetchAll($sql); $uselimits=""; foreach($limits as $k=>$limit) { - //$uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; + //$uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; $uselimits.=($k+1).'. '.str_replace(array("\r\n", "\n", "\r"),'',$limit['uselimit'])."\r\n"; - } - $row['uselimits']=$uselimits; - $sql="select ol.* from onlineresource ol left join metadata m on ol.uuid=m.uuid where m.uuid=?"; + } + $row['uselimits']=$uselimits; + $sql="select ol.* from onlineresource ol left join metadata m on ol.uuid=m.uuid where m.uuid=?"; $sql=$this->db->quoteInto($sql,$uuid); - $res=$this->db->fetchAll($sql); - $resource=""; - foreach($res as $k=>$r) - { - $resource.=($k+1).". ".$r['name'].' '.$r['linkage']."\n"; - } - $row['resources']=$resource; - $sql="select r.role,s.* from role r left join responsible s on r.resid=s.id left join metadata m on m.uuid=r.uuid where m.uuid=? order by r.role,r.id"; + $res=$this->db->fetchAll($sql); + $resource=""; + foreach($res as $k=>$r) + { + $resource.=($k+1).". ".$r['name'].' '.$r['linkage']."\n"; + } + $row['resources']=$resource; + $sql="select r.role,s.* from role r left join responsible s on r.resid=s.id left join metadata m on m.uuid=r.uuid where m.uuid=? order by r.role,r.id"; $sql=$this->db->quoteInto($sql,$uuid); - $contact=$this->db->fetchAll($sql); - $contacts=""; - $party_zh=array('resourceProvider'=>'资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'数据调查与处理者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者'); - foreach($contact as $k=>$c) - { - @$contacts.=($k+1).". ".$party_zh[$c['role']]."\n"; - @$contacts.=$c['individual'].' 单位:'.$c['organisation']."\n"; - @$contacts.='地址:'.$c['country'].' '.$c['administractive'].' '.$c['city'].' '.$c['delivery']."\n"; - @$contacts.='邮编:'.$c['postal'].' 电话:'.$c['phone'].' 邮件:'.$c['email']."\n\n"; - } - $row['contacts']=$contacts; - $sql="select k.keyword, k.keytype from keyword k left join metadata m on k.id=m.id where m.uuid=? order by k.keytype"; + $contact=$this->db->fetchAll($sql); + $contacts=""; + $party_zh=array('resourceProvider'=>'资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'数据调查与处理者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者'); + foreach($contact as $k=>$c) + { + @$contacts.=($k+1).". ".$party_zh[$c['role']]."\n"; + @$contacts.=$c['individual'].' 单位:'.$c['organisation']."\n"; + @$contacts.='地址:'.$c['country'].' '.$c['administractive'].' '.$c['city'].' '.$c['delivery']."\n"; + @$contacts.='邮编:'.$c['postal'].' 电话:'.$c['phone'].' 邮件:'.$c['email']."\n\n"; + } + $row['contacts']=$contacts; + $sql="select k.keyword, k.keytype from keyword k left join metadata m on k.id=m.id where m.uuid=? order by k.keytype"; $sql=$this->db->quoteInto($sql,$uuid); - $keys=$this->db->fetchAll($sql); - $keyword=array(); - foreach($keys as $key) - { - @$keyword[$key['keytype']].=$key['keyword'].','; - } + $keys=$this->db->fetchAll($sql); + $keyword=array(); + foreach($keys as $key) + { + @$keyword[$key['keytype']].=$key['keyword'].','; + } $row['keyword']=$keyword; if (is_numeric($row['projection'])) @@ -510,75 +510,128 @@ class ServiceController extends Zend_Controller_Action $projection=''; $dom = new DOMDocument(); - $dom->loadXML($row['data']); + $dom->loadXML($row['data']); $xpath = new DOMXpath($dom); - $row['rfdenom']=@$dom->getElementsByTagName('rfDenom')->item(0)->nodeValue; - $row['resolution']=@$xpath->query('//scaleDist/value/Real')->item(0)->nodeValue; - $row['resolution'].=@$dom->getElementsByTagName('uomName')->item(0)->nodeValue; + $row['rfdenom']=@$dom->getElementsByTagName('rfDenom')->item(0)->nodeValue; + $row['resolution']=@$xpath->query('//scaleDist/value/Real')->item(0)->nodeValue; + $row['resolution'].=@$dom->getElementsByTagName('uomName')->item(0)->nodeValue; //提前对表格进行预处理 $wiki=new WikiFormat(); - $row['description']=$wiki->parseTable($row["description"]); - preg_match_all('/
[\s\S]*?<\/table>/im', $row['description'],$tables); - $search=array(); - $replace=array(); - foreach($tables as $k=>$table) - { - /*$search[]="
"; - $replace[]=''.str_repeat('',substr_count($table[0],'"; - $replace[]=""; - $search[]=""; - $replace[]=""; - $search[]=""; - $replace[]=""; - $search[]="
')); - $search[]="
"; - $replace[]=""; - $search[]=""; - $replace[]=""; - $search[]=""; - $replace[]=""; - $search[]="
"; - $replace[]=""; - $table=str_replace($search,$replace,$table[0]);*/ - $row['description']=str_replace($tables[$k][0],"\n 【表格内容暂不支持,请访问网站查看,此处请忽略】\n",$row['description']); - } - - require_once('odtphp/library/odf.php'); - $config["PATH_TO_TMP"]="/tmp/zip"; - $config["ZIP_PROXY"]="ZipArchive"; - $odf=new Odf("../data/metadata-template.odt",$config); - $odf->setVars('title',$row['title'],true,'utf-8'); - @$odf->setVars('title_en',$row['title_en'],true,'utf-8'); - $odf->setVars('uuid',$row['uuid'],true,'utf-8'); - $odf->setVars('datetime',date('Y-m-d')); - $odf->setVars('abstract',$row['description'],true,'utf-8'); - @$odf->setVars('theme_keyword',$row['keyword']['theme'],true,'utf-8'); - @$odf->setVars('place_keyword',$row['keyword']['place'],true,'utf-8'); - @$odf->setVars('temporal_keyword',empty($row['keyword']['temporal'])?'':$row['keyword']['temporal'],true,'utf-8'); - @$odf->setVars('discipline_keyword',$row['keyword']['discipline'],true,'utf-8'); - @$odf->setVars('stratum_keyword',$row['keyword']['stratum'],true,'utf-8'); - @$odf->setVars('category',$row['category'].' '.$row['category_zh'],true,'utf-8'); - @$odf->setVars('rfdenom',$row['rfdenom'],true,'utf-8'); - @$odf->setVars('resolution',$row['resolution'],true,'utf-8'); - @$odf->setVars('projection',$row['projection'],true,'utf-8'); - @$odf->setVars('filesize',$row['filesize'],true,'utf-8'); - @$odf->setVars('fileformat',$row['fileformat'],true,'utf-8'); - @$odf->setVars('timebegin',$row['timebegin'],true,'utf-8'); - @$odf->setVars('timeend',$row['timeend'],true,'utf-8'); - @$odf->setVars('citation',$row['citation'],true,'utf-8'); - @$odf->setVars('reference',$row['reference'],true,'utf-8'); - @$odf->setVars('doi',$row['doi'],true,'utf-8'); - @$odf->setVars('suppinfo',$row['suppinfo'],true,'utf-8'); - @$odf->setVars('uselimits',$row['uselimits'],true,'utf-8'); - @$odf->setVars('resources',$row['resources'],true,'utf-8'); - @$odf->setVars('contacts',$row['contacts'],true,'utf-8'); - @$odf->setVars('north',$row['north'],true,'utf-8'); - @$odf->setVars('south',$row['south'],true,'utf-8'); - @$odf->setVars('west',$row['west'],true,'utf-8'); - @$odf->setVars('east',$row['east'],true,'utf-8'); - $odf->setImage('bigthumb', 'http://test.westgis.ac.cn/service/bigthumb/uuid/'.$row['uuid']); - $odf->setImage('thumb', 'http://test.westgis.ac.cn/service/thumb/uuid/'.$row['uuid']); - $odf->exportAsAttachedFile($row['title'].'.odt'); - } -} - + $row['description']=$wiki->parseTable($row["description"]); + preg_match_all('/[\s\S]*?<\/table>/im', $row['description'],$tables); + $search=array(); + $replace=array(); + foreach($tables as $k=>$table) + { + /*$search[]="
"; + $replace[]=''.str_repeat('',substr_count($table[0],'"; + $replace[]=""; + $search[]=""; + $replace[]=""; + $search[]=""; + $replace[]=""; + $search[]="
')); + $search[]="
"; + $replace[]=""; + $search[]=""; + $replace[]=""; + $search[]=""; + $replace[]=""; + $search[]="
"; + $replace[]=""; + $table=str_replace($search,$replace,$table[0]);*/ + $row['description']=str_replace($tables[$k][0],"\n 【表格内容暂不支持,请访问网站查看,此处请忽略】\n",$row['description']); + } + + require_once('odtphp/library/odf.php'); + $config["PATH_TO_TMP"]="/tmp/zip"; + $config["ZIP_PROXY"]="ZipArchive"; + $odf=new Odf("../data/metadata-template.odt",$config); + $odf->setVars('title',$row['title'],true,'utf-8'); + @$odf->setVars('title_en',$row['title_en'],true,'utf-8'); + $odf->setVars('uuid',$row['uuid'],true,'utf-8'); + $odf->setVars('datetime',date('Y-m-d')); + $odf->setVars('abstract',$row['description'],true,'utf-8'); + @$odf->setVars('theme_keyword',$row['keyword']['theme'],true,'utf-8'); + @$odf->setVars('place_keyword',$row['keyword']['place'],true,'utf-8'); + @$odf->setVars('temporal_keyword',empty($row['keyword']['temporal'])?'':$row['keyword']['temporal'],true,'utf-8'); + @$odf->setVars('discipline_keyword',$row['keyword']['discipline'],true,'utf-8'); + @$odf->setVars('stratum_keyword',$row['keyword']['stratum'],true,'utf-8'); + @$odf->setVars('category',$row['category'].' '.$row['category_zh'],true,'utf-8'); + @$odf->setVars('rfdenom',$row['rfdenom'],true,'utf-8'); + @$odf->setVars('resolution',$row['resolution'],true,'utf-8'); + @$odf->setVars('projection',$row['projection'],true,'utf-8'); + @$odf->setVars('filesize',$row['filesize'],true,'utf-8'); + @$odf->setVars('fileformat',$row['fileformat'],true,'utf-8'); + @$odf->setVars('timebegin',$row['timebegin'],true,'utf-8'); + @$odf->setVars('timeend',$row['timeend'],true,'utf-8'); + @$odf->setVars('citation',$row['citation'],true,'utf-8'); + @$odf->setVars('reference',$row['reference'],true,'utf-8'); + @$odf->setVars('doi',$row['doi'],true,'utf-8'); + @$odf->setVars('suppinfo',$row['suppinfo'],true,'utf-8'); + @$odf->setVars('uselimits',$row['uselimits'],true,'utf-8'); + @$odf->setVars('resources',$row['resources'],true,'utf-8'); + @$odf->setVars('contacts',$row['contacts'],true,'utf-8'); + @$odf->setVars('north',$row['north'],true,'utf-8'); + @$odf->setVars('south',$row['south'],true,'utf-8'); + @$odf->setVars('west',$row['west'],true,'utf-8'); + @$odf->setVars('east',$row['east'],true,'utf-8'); + $odf->setImage('bigthumb', 'http://test.westgis.ac.cn/service/bigthumb/uuid/'.$row['uuid']); + $odf->setImage('thumb', 'http://test.westgis.ac.cn/service/thumb/uuid/'.$row['uuid']); + $odf->exportAsAttachedFile($row['title'].'.odt'); + } + + function uploadAction(){ + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + try{ + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $userid = $user->id; + } + + if(empty($userid)||!is_numeric($userid)){ + $msg['error'] = "请先登录"; + echo Zend_Json::encode($msg); + exit(); + } + + $files=new files(); + $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'reviewatt'); + + if(empty($msg['error'])) + { + $msg['error']=""; + $filename = $msg['db_path']; + $filesize = $msg['file_size']; + $filedesc = $this->_request->getParam('filedesc'); + $filetype = $this->_request->getParam('dir'); + $realname = $msg['realname']; + + + $sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','reviewatt','$filedesc','$userid','$filesize','$realname') RETURNING id"; + $sth = $this->db->prepare($sql); + $sth->execute(); + $att = $sth->fetch(PDO::FETCH_ASSOC); + $msg['attid'] = $attid = $att['id']; + $msg['html'] = $realname.'[已完成]
'; + echo Zend_Json::encode($msg); + exit(); + }else{ + $msg['error'] = '附件上传失败:'.$msg['error']; + @unlink($filename); + echo Zend_Json::encode($msg); + exit(); + } + + }catch(Exception $e){ + $msg['error'] = "错误:".$e->getMessage(); + echo Zend_Json::encode($msg); + exit(); + } + } +} + diff --git a/application/default/views/scripts/review/review.phtml b/application/default/views/scripts/review/review.phtml index f99c0c58..d209b266 100755 --- a/application/default/views/scripts/review/review.phtml +++ b/application/default/views/scripts/review/review.phtml @@ -189,7 +189,7 @@ $(document).ready(function() { $('#file_upload').uploadify({ 'uploader' : '/static/js/uploadify/uploadify.swf', 'scriptData': {'PHPSESSID' : ''}, - 'script' : '/upload', + 'script' : '/service/upload', 'cancelImg' : '/static/js/uploadify/cancel.png', 'folder' : '/uploads', 'multi' : false,