修复拼写错误以及xml字段错误

This commit is contained in:
wlx 2012-05-21 09:34:04 +00:00
parent 5f627eabe4
commit 22c1a93e37
2 changed files with 69 additions and 53 deletions

View File

@ -2161,14 +2161,14 @@ class AuthorController extends Zend_Controller_Action
$sth=$this->db->prepare($sql); $sth=$this->db->prepare($sql);
$sth->execute(array($id)); $sth->execute(array($id));
$row=$sth->fetch(); $row=$sth->fetch();
if (!emtpy($row)) if (!empty($row))
{ {
$data = array("error"=>'错误的入口'); $data = array("error"=>'错误的入口');
$this->jsonexit($data); $this->jsonexit($data);
return true; return true;
} }
$sql="select uuid from geonetworkmetadata where id=? and owner=?"; $sql="select uuid,data from metadata where id=? and owner=?";
$sth=$this->wdb->prepare($sql); $sth=$this->wdb->prepare($sql);
$sth->execute(array($id,$u_id)); $sth->execute(array($id,$u_id));
$row=$sth->fetch(); $row=$sth->fetch();
@ -2180,7 +2180,7 @@ class AuthorController extends Zend_Controller_Action
} }
// 保存数据作者信息 // 保存数据作者信息
$sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)"; $sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
$sth=$this->db->query($sql,array($row['uuid'],$u_id)); $this->db->query($sql,array($row['uuid'],$u_id));
// 2. 保存变化记录 save changelog & userid for the latest version // 2. 保存变化记录 save changelog & userid for the latest version
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)"; $sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
@ -2189,7 +2189,7 @@ class AuthorController extends Zend_Controller_Action
// 3. 保存数据评审状态 // 3. 保存数据评审状态
//导入元数据 //导入元数据
$iso=new ISO19115(); $iso=new ISO19115();
$iso->saveDB($this->db,$row['xml']); @$iso->saveDB($this->db,$row['data']);
//进入评审库 //进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?"; $sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?";
$this->db->query($sql,array($u_id,$id)); $this->db->query($sql,array($u_id,$id));

View File

@ -11,7 +11,7 @@ class GlacierController extends DataController
function indexAction() function indexAction()
{ {
$sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and length(t.data)>2 order by random() limit 3"; $sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and length(t.data)>2 order by random() limit 3";
$this->view->meatdata=$this->db->fetchAll($sql); $this->view->meatdata=$this->db->fetchAll($sql);
} }
@ -23,11 +23,11 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') "); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') ");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$select=$this->db->select(); $select=$this->db->select();
$select->from('normalmetadata','*')->where(" uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') ")->order('title desc')->limitPage($page,$this->limit); $select->from('normalmetadata','*')->where(" uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') ")->order('title desc')->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);
$this->view->offset=$offset+1; $this->view->offset=$offset+1;
@ -38,12 +38,12 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') "); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') ");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$select=$this->db->select(); $select=$this->db->select();
$select->from('normalmetadata as m','m.*') $select->from('normalmetadata as m','m.*')
->where(" uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') ") ->where(" uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') ")
->order('m.title desc')->limitPage($page,$this->limit); ->order('m.title desc')->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);
@ -54,9 +54,9 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') ))"); $row=$this->db->fetchAll("select count(*) from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') ))");
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') )) order by reference limit ? offset ?"; $sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') )) order by reference limit ? offset ?";
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset)); $this->view->refs=$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->offset=$offset+1; $this->view->offset=$offset+1;
@ -67,10 +67,10 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP'))"); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP'))");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP')) order by timebegin,title limit ? offset ?"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP')) order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;
@ -81,15 +81,15 @@ class GlacierController extends DataController
$this->getmd('基础地理'); $this->getmd('基础地理');
} }
function coreAction() function typicalAction()
{ {
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验'))"); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验'))");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验')) order by timebegin,title limit ? offset ?"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验')) order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;
@ -105,23 +105,39 @@ class GlacierController extends DataController
$this->getmd('遥感影像'); $this->getmd('遥感影像');
} }
function waterAction() function qilianAction()
{ {
$this->getmd('水文地质'); $this->getmd('祁连山','place');
} }
function modelAction() function tianshanAction()
{ {
$page=(int)$this->_request->getParam('page'); $this->getmd('天山','place');
if (empty($page)) $page=1; }
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射'))"); function gonggaAction()
$row=$state->fetchAll(); {
$sum=$row[0]['count']; $this->getmd('贡嘎山','place');
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射')) order by timebegin,title limit ? offset ?"; }
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit); function namcoAction()
$this->view->offset=$offset+1; {
$this->getmd('纳木错流域','place');
}
function yangtzeAction()
{
$this->getmd('长江源','place');
}
function nianchuAction()
{
$this->getmd('年楚河','place');
}
function everestnorthAction()
{
$this->getmd('珠穆朗玛峰','place');
} }
function economicAction() function economicAction()
@ -129,10 +145,10 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济'))"); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济'))");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济')) order by timebegin,title limit ? offset ?"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济')) order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;
@ -143,10 +159,10 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化'))"); $state=$this->db->query("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化'))");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化')) order by timebegin,title limit ? offset ?"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化')) order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;
@ -183,7 +199,7 @@ class GlacierController extends DataController
function listAction() function listAction()
{ {
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') order by timebegin,title"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') order by timebegin,title";
$this->view->metadata=$this->db->fetchAll($sql); $this->view->metadata=$this->db->fetchAll($sql);
} }
@ -199,19 +215,19 @@ class GlacierController extends DataController
$state=$this->db->query($sql); $state=$this->db->query($sql);
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title,id,description from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keyword='".$key."') order by timebegin,title limit ? offset ?"; $sql="select uuid,title,id,description from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keyword='".$key."') order by timebegin,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);
} else { } else {
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='place' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by keyword.keyword order by count desc"); $state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='place' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by keyword.keyword order by count desc");
$k1=$state->fetchAll(); $k1=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by k.keyword order by k.keyword"); $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='theme' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword");
$k2=$state->fetchAll(); $k2=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='discipline' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by k.keyword order by k.keyword"); $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='discipline' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword");
$k3=$state->fetchAll(); $k3=$state->fetchAll();
$state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='stratum' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by k.keyword order by k.keyword"); $state=$this->db->query("select k.keyword,count(k.keyword) from keyword k left join normalmetadata m on k.id=m.id where k.keytype='stratum' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by k.keyword order by k.keyword");
$k4=$state->fetchAll(); $k4=$state->fetchAll();
$state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='temporal' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by keyword.keyword order by keyword.keyword"); $state=$this->db->query("select keyword.keyword,count(*) from keyword left join normalmetadata m on keyword.id=m.id where keyword.keytype='temporal' and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by keyword.keyword order by keyword.keyword");
$k5=$state->fetchAll(); $k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5); $this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
} }
@ -230,9 +246,9 @@ class GlacierController extends DataController
$page=@(int)$this->_request->getParam('page'); $page=@(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$row=$this->db->fetchAll("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and ".$where); $row=$this->db->fetchAll("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and ".$where);
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title,id,description from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and ".$where." order by timebegin,title limit ? offset ?"; $sql="select uuid,title,id,description from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and ".$where." order by timebegin,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;
@ -242,19 +258,19 @@ class GlacierController extends DataController
function timemapAction() function timemapAction()
{ {
$sql="select id,uuid,west,south,north,east,title,timebegin,timeend from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and timebegin is not null"; $sql="select id,uuid,west,south,north,east,title,timebegin,timeend from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and timebegin is not null";
$this->view->rows=$this->db->fetchAll($sql); $this->view->rows=$this->db->fetchAll($sql);
} }
function timelineAction() function timelineAction()
{ {
$fn="heihetime.xml"; $fn="glaciertime.xml";
$rows=$this->db->fetchAll("select ts_created from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') order by ts_created desc limit 1"); $rows=$this->db->fetchAll("select ts_created from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') 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";
$rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and timebegin is not null order by timebegin,title"); $rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and timebegin is not null order by timebegin,title");
$timexml='<data>'; $timexml='<data>';
foreach($rows as $row) { foreach($rows as $row) {
$timexml.='<event start="'.date($dateformat,strtotime($row['timebegin'])).' GMT+0800" '; $timexml.='<event start="'.date($dateformat,strtotime($row['timebegin'])).' GMT+0800" ';
@ -279,11 +295,11 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$this->view->category=$this->db->fetchAll("select c.code,name,name_zh,count(*) from category c left join normalmetadata m on c.id=m.id,categorycode cc where c.code=cc.code and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') group by c.code,cc.name,cc.name_zh"); $this->view->category=$this->db->fetchAll("select c.code,name,name_zh,count(*) from category c left join normalmetadata m on c.id=m.id,categorycode cc where c.code=cc.code and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') group by c.code,cc.name,cc.name_zh");
if ($code>0 && $code<20) { if ($code>0 && $code<20) {
$row=$this->db->fetchAll("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from category where code=".$code.")"); $row=$this->db->fetchAll("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from category where code=".$code.")");
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select uuid,title,description,id from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select distinct id from category where code=".$code.") order by timebegin,title limit ? offset ?"; $sql="select uuid,title,description,id from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select distinct id from category where code=".$code.") order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;
@ -299,11 +315,11 @@ class GlacierController extends DataController
$page=(int)$this->_request->getParam('page'); $page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1; if (empty($page)) $page=1;
$offset=$this->limit*($page-1); $offset=$this->limit*($page-1);
$state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='heihe' and m.id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')"); $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='glacier' and m.id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')");
$row=$state->fetchAll(); $row=$state->fetchAll();
$sum=$row[0]['count']; $sum=$row[0]['count'];
//@todo: add order with title //@todo: add order with title
$sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glacier') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,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->offset=$offset+1; $this->view->offset=$offset+1;