修改前台数据页面的分平台控制

This commit is contained in:
wlx 2014-06-11 14:14:14 +00:00
parent 153a43956e
commit 417e587dbc
2 changed files with 30 additions and 162 deletions

View File

@ -84,7 +84,9 @@ class DataController extends Zend_Controller_Action
//展示最近20条离线神情记录情况 //展示最近20条离线神情记录情况
function offlineappAction() function offlineappAction()
{ {
$sql="select * from offlineapp where ts_approved is not null and pdflink<>'' and status>=0 order by ts_created desc limit 20"; $sql="select * from offlineapp where ts_approved is not null and pdflink<>'' and status>=0
and id in (select offlineappid from dataorder where uuid in (select uuid from $this->submd))
order by ts_created desc limit 20";
$this->view->rows=$this->db->fetchAll($sql); $this->view->rows=$this->db->fetchAll($sql);
} }
function requestAction() function requestAction()
@ -110,11 +112,11 @@ class DataController extends Zend_Controller_Action
if (empty($page)) $page=1; if (empty($page)) $page=1;
$limit=10; $limit=10;
$offset=$limit*($page-1); $offset=$limit*($page-1);
$state=$this->db->query('select count(*) from metadata'); $state=$this->db->query('select count(*) from $this->submd');
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$select=$this->db->select(); $select=$this->db->select();
$select->from('metadata','*')->order('id desc')->limitPage($page,$limit); $select->from($this->submd,'*')->order('id desc')->limitPage($page,$limit);
$this->view->metadata = $this->db->fetchAll($select); $this->view->metadata = $this->db->fetchAll($select);
$this->view->page=new Pagination($sum,$page,$limit); $this->view->page=new Pagination($sum,$page,$limit);
} }
@ -187,7 +189,7 @@ class DataController extends Zend_Controller_Action
if (empty($page)) $page=1; if (empty($page)) $page=1;
$limit=10; $limit=10;
$offset=$limit*($page-1); $offset=$limit*($page-1);
$state=$this->db->query('select s.id,name,count(*) from series s,dataseries d where d.sid=s.id group by s.id,s.name'); $state=$this->db->query('select s.id,name,count(*) from series s,dataseries d where d.sid=s.id and d.id in (select id from '.$this->submd.') group by s.id,s.name');
$this->view->serie=$state->fetchAll(); $this->view->serie=$state->fetchAll();
if ($id>0) { if ($id>0) {
//$where=$this->db->quoteInto('id = ?',$id); //$where=$this->db->quoteInto('id = ?',$id);
@ -195,22 +197,24 @@ class DataController extends Zend_Controller_Action
$this->view->codename=$row['name']; $this->view->codename=$row['name'];
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 $this->submd 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 $this->submd m,dataseries d where m.id=d.id and d.sid=?";
$row=$this->db->fetchAll($sql,array($id)); $row=$this->db->fetchAll($sql,array($id));
} }
$sum=$row[0]['count']; $sum=$row[0]['count'];
$select=$this->db->select(); $select=$this->db->select();
$select->from('normalmetadata','*')->join('dataseries','normalmetadata.id=dataseries.id')->where('dataseries.sid=?',$id)->order('normalmetadata.title')->limitPage($page,$limit); $select->from($this->submd. ' as m','*')->join('dataseries','m.id=dataseries.id')->where('dataseries.sid=?',$id)->order('m.title')->limitPage($page,$limit);
if (!empty($keyword)) $select->join('keyword','keyword.id=normalmetadata.id')->where('keyword.keyword=?',$keyword); if (!empty($keyword)) $select->join('keyword','keyword.id=m.id')->where('keyword.keyword=?',$keyword);
$this->view->metadata=$this->db->fetchAll($select); $this->view->metadata=$this->db->fetchAll($select);
$this->view->page=new Pagination($sum,$page,$limit); $this->view->page=new Pagination($sum,$page,$limit);
//$this->view->showtools=($sum>$page)?true:false; //$this->view->showtools=($sum>$page)?true:false;
//$this->view->form=new SearchForm(); //$this->view->form=new SearchForm();
$sql=$this->db->quoteInto("select keyword,count(*) as count from (select t.keyword,t.id from keyword t left join dataseries d on t.id=d.id where t.keytype='place' and d.sid=?) as f group by keyword order by count desc limit 30",$id); $sql=$this->db->quoteInto("select keyword,count(*) as count from
(select t.keyword,t.id from keyword t left join dataseries d on t.id=d.id where t.keytype='place' and d.id in (select id from $this->submd) and d.sid=?) as f
group by keyword order by count desc limit 30",$id);
$state=$this->db->query($sql); $state=$this->db->query($sql);
$row=$state->fetchAll(); $row=$state->fetchAll();
$this->view->places=$row; $this->view->places=$row;
@ -226,17 +230,17 @@ class DataController extends Zend_Controller_Action
{ {
$page = $this->_request->getParam('page'); $page = $this->_request->getParam('page');
$code = (int)$this->_request->getParam('code'); $code = (int)$this->_request->getParam('code');
$state=$this->db->query('select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh'); $state=$this->db->query("select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code and c.id in (select id from $this->submd) group by c.code,cc.name,cc.name_zh");
$this->view->category=$state->fetchAll(); $this->view->category=$state->fetchAll();
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 $this->submd 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($this->submd.' 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 {
@ -250,14 +254,12 @@ class DataController extends Zend_Controller_Action
function timelineAction() function timelineAction()
{ {
$fn="time1.xml"; $fn="time1.xml";
$rows=$this->db->fetchAll("select ts_created from normalmetadata order by ts_created desc limit 1"); $rows=$this->db->fetchAll("select ts_created from $this->submd order by ts_created desc limit 1");
$last_update=strtotime($rows[0]['ts_created']); $last_update=strtotime($rows[0]['ts_created']);
if (!file_exists($fn) || (filemtime($fn)<$last_update)) if (!file_exists($fn) || (filemtime($fn)<$last_update))
{ {
$dateformat="M j Y"; $dateformat="M j Y";
$md = new MetadataTable(); $state=$this->db->query("select id,uuid,description,title,timebegin,timeend from $this->submd where timebegin is not null order by timebegin");
$db=$md->getAdapter();
$state=$db->query('select id,uuid,description,title,timebegin,timeend from normalmetadata where timebegin is not null order by timebegin');
$rows=$state->fetchAll(); $rows=$state->fetchAll();
$timexml='<data>'; $timexml='<data>';
foreach($rows as $row) { foreach($rows as $row) {
@ -291,13 +293,11 @@ class DataController extends Zend_Controller_Action
*/ */
function jsonAction() function jsonAction()
{ {
$md=new MetadataTable();
$db=$md->getAdapter();
$id = (int)$this->_request->getParam('id'); $id = (int)$this->_request->getParam('id');
$where=''; $where='';
if (!empty($id)) { $where=' where id='.$id; } if (!empty($id)) { $where=' where id='.$id; }
$sql='select id,uuid,west,south,north,east,title from normalmetadata'.$where; $sql="select id,uuid,west,south,north,east,title from $this->submd".$where;
$state=$db->query($sql); $state=$this->db->query($sql);
$rows=$state->fetchAll(); $rows=$state->fetchAll();
$geomd=new GeoMetaData(); $geomd=new GeoMetaData();
foreach($rows as $row){ foreach($rows as $row){
@ -320,7 +320,7 @@ class DataController extends Zend_Controller_Action
*/ */
function timemapAction() function timemapAction()
{ {
$sql='select id,uuid,west,south,north,east,title,timebegin,timeend from normalmetadata where timebegin is not null'; $sql="select id,uuid,west,south,north,east,title,timebegin,timeend from $this->submd where timebegin is not null";
$this->view->rows=$this->db->fetchAll($sql); $this->view->rows=$this->db->fetchAll($sql);
} }
/* /*
@ -329,7 +329,7 @@ class DataController extends Zend_Controller_Action
function xmlAction() function xmlAction()
{ {
$uuid=$this->_request->getParam('uuid'); $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)); $row=$this->db->fetchRow("select xml.data from xml left join $this->submd m on xml.id=m.id where m.uuid=?",array($uuid));
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$this->getResponse()->setHeader('Content-Type', 'text/xml') $this->getResponse()->setHeader('Content-Type', 'text/xml')
@ -357,37 +357,7 @@ class DataController extends Zend_Controller_Action
//$this->getResponse()->setHeader('Content-Type', 'text/html') //$this->getResponse()->setHeader('Content-Type', 'text/html')
// ->setBody($proc->transformToXML($xml)); // ->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 normalmetadata 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();
}
/* /*
* todo: search * todo: search
*/ */
@ -407,58 +377,15 @@ class DataController extends Zend_Controller_Action
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$search=new Search($key); $search=new Search($key);
$where=$search->sql_expr(array("title","description")); $where=$search->sql_expr(array("title","description"));
$row=$this->db->fetchAll("select count(*) from normalmetadata where ".$where); $row=$this->db->fetchAll("select count(*) from $this->submd where ".$where);
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title,id,description from normalmetadata where ".$where." order by title limit ? offset ?"; $sql="select uuid,title,id,description from $this->submd where ".$where." order by title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset)); $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit); $this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->key=$key; $this->view->key=$key;
} }
} }
/*
* todo: 高级搜索
*/
function advancesearchAction()
{
$this->view->addHelperPath('helper','Zend_View_Helper_');
//$form=new SearchForm();
//$this->view->form=$form;
$md=new MetadataTable();
$db=$md->getAdapter();
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$limit=10;
$offset=$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');
if (!empty($key)) {
$sql='select count(*) from normalmetadata where east<? and west>? and north<? and south>? and (title ilike ? or description ilike ?)';
$row=$db->fetchAll($sql,array($e,$w,$n,$s,'%'.$key.'%','%'.$key.'%'));
} else {
$sql='select count(*) from normalmetadata where east<? and west>? and north<? and south>?';
$row=$db->fetchAll($sql,array($e,$w,$n,$s));
}
$sum=$row[0]['count'];
$select=$db->select();
$select->from('normalmetadata','*')->where('east<?',$e)->where('west>?',$w)->where('north<?',$n)->where('south>?',$s);
if (!empty($key)) $select->where('(title ilike ? or description ilike ?)','%'.$key.'%');
$select->order('title')->limit($limit,$offset);
$this->view->metadata = $db->fetchAll($select);
$this->view->page=new Pagination($sum,$page);
$this->view->key=$key;
}
}
/* /*
* 根据id或uuid来查看元数据 * 根据id或uuid来查看元数据
* id为一组数字uuid为唯一标识符 * id为一组数字uuid为唯一标识符
@ -466,7 +393,7 @@ 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,i.doi as datadoi,i.authors,i.author_en,i.publisher,i.publisher_en, date_part('year',i.ts_published) as publish_year from normalmetadata m left join mdstatus s on m.uuid=s.uuid $sql="select m.*,s.status,g.id as gid,t.filename,i.doi as datadoi,i.authors,i.author_en,i.publisher,i.publisher_en, date_part('year',i.ts_published) as publish_year from $this->submd 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 left join datadoi i on i.uuid=m.uuid where "; left join thumbnail t on t.id=m.id left join geonetworkmetadata g on m.uuid=g.uuid left join datadoi i on i.uuid=m.uuid where ";
if (empty($id)) { if (empty($id)) {
$uuid = $this->_request->getParam('uuid'); $uuid = $this->_request->getParam('uuid');
@ -1981,65 +1908,6 @@ class DataController extends Zend_Controller_Action
} }
/*
* 西部计划项目及其数据产出
*/
public function westeeAction()
{
//$sql="select w.*,m.uuid from westee w left join westeemd m on w.id=m.eeid order by w.id";
$sql="select * from westee order by id";
$this->view->westee=$this->db->fetchAll($sql);
$sql="select w.eeid,m.title,m.uuid from westeemd w left join metadata m on w.uuid=m.uuid order by w.eeid";
$this->view->westeemd=$this->db->fetchAll($sql);
}
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 normalmetadata";
$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 "<br>";
}
}
public function jsonexit($data){ public function jsonexit($data){
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK)); $this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
return true; return true;
@ -2053,7 +1921,7 @@ class DataController extends Zend_Controller_Action
$this->view->organisation=$state->fetchAll(); $this->view->organisation=$state->fetchAll();
if (!empty($name)) { if (!empty($name)) {
$this->view->codename=$name; $this->view->codename=$name;
$sql="select distinct m.* from normalmetadata m left join role r on m.uuid=r.uuid left join responsible s on r.resid=s.id where r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?"; $sql="select distinct m.* from $this->submd m left join role r on m.uuid=r.uuid left join responsible s on r.resid=s.id where r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(array($name)); $sth->execute(array($name));
$rows = $sth->fetchAll(); $rows = $sth->fetchAll();
@ -2074,7 +1942,7 @@ class DataController extends Zend_Controller_Action
$sql="select * from fund where id=?"; $sql="select * from fund where id=?";
$this->view->fund=$this->db->fetchRow($sql,array($id)); $this->view->fund=$this->db->fetchRow($sql,array($id));
if ($this->view->fund) { if ($this->view->fund) {
$sql="select distinct m.* from normalmetadata m left join mdfund mf on m.uuid=mf.uuid where mf.fid=?"; $sql="select distinct m.* from $this->submd m left join mdfund mf on m.uuid=mf.uuid where mf.fid=?";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(array($id)); $sth->execute(array($id));
$rows = $sth->fetchAll(); $rows = $sth->fetchAll();
@ -2087,7 +1955,7 @@ class DataController extends Zend_Controller_Action
} }
} else { } else {
//提供全部分类列表 //提供全部分类列表
$sql="select f.id,f.title,f.fund_id,f.fund_type,f.ts_created,count(m.id) as datacount,sum(md.filesize) as filesize from fund f left join mdfund m on f.id=m.fid left join metadata md on m.uuid=md.uuid where m.id is not null group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by datacount desc,f.ts_created desc"; $sql="select f.id,f.title,f.fund_id,f.fund_type,f.ts_created,count(m.id) as datacount,sum(md.filesize) as filesize from fund f left join mdfund m on f.id=m.fid left join $this->submd md on m.uuid=md.uuid where m.id is not null group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by datacount desc,f.ts_created desc";
$sth = $this->db->prepare($sql); $sth = $this->db->prepare($sql);
$sth->execute(); $sth->execute();
$rows = $sth->fetchAll(); $rows = $sth->fetchAll();

View File

@ -28,7 +28,7 @@
<?= $this->headLink() ?> <?= $this->headLink() ?>
<?= $this->headStyle() ?> <?= $this->headStyle() ?>
<link rel="shortcut icon" href="/favicon_64.png" /> <link rel="shortcut icon" href="/favicon_64.png" />
<link rel="alternate" type="application/rss+xml" title="WestDC RSS Feed" href="/data/feed" /> <link rel="alternate" type="application/rss+xml" title="WestDC RSS Feed" href="/service/feed" />
<link rel="pingback" href="http://westdc.westgis.ac.cn/data/pingback" /> <link rel="pingback" href="http://westdc.westgis.ac.cn/data/pingback" />
</head> </head>
<body> <body>