change metadata to en schema

This commit is contained in:
wlx 2013-11-09 15:47:23 +00:00
parent d9fbefbd5a
commit 44e0f00dc7
4 changed files with 362 additions and 138 deletions

View File

@ -604,7 +604,7 @@ class DataController extends Zend_Controller_Action
$this->view->downlists = $this->db->fetchAll($sql,array($uuid,$uuid)); $this->view->downlists = $this->db->fetchAll($sql,array($uuid,$uuid));
//数据附件 //数据附件
$sql = $this->db->quoteInto("select m.id,a.realname from en.mdattach m left join en.attachments a on m.id=a.id where m.uuid=?",$uuid); $sql = $this->db->quoteInto("select m.id,a.realname from mdattach m left join attachments a on m.id=a.id where language='en' and m.uuid=?",$uuid);
$this->view->attachments = $this->db->fetchAll($sql); $this->view->attachments = $this->db->fetchAll($sql);
//数据版本 //数据版本
$sql = "SELECT count(id) as c FROM en.mdversion WHERE uuid=? AND changelog IS NOT NULL"; $sql = "SELECT count(id) as c FROM en.mdversion WHERE uuid=? AND changelog IS NOT NULL";
@ -1605,11 +1605,11 @@ class DataController extends Zend_Controller_Action
{ {
view::Post($this,$service_type,$state['service_url']."?href=".urlencode(view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid); view::Post($this,$service_type,$state['service_url']."?href=".urlencode(view::getHostLink()."/data/order/")."&uuid=".$state['uuid']."&uid=".$userid);
}else{ }else{
$this->view->msg = view::Msg('alert-error',"无法申请:此元数据的数据类型未知"); $this->view->msg = view::Msg('alert-error',"Error: could not add this dataset.");
} }
} }
}else{ }else{
$this->view->msg = view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application.");
} }
if (empty($ac)) $ac='offline1'; if (empty($ac)) $ac='offline1';
@ -1620,7 +1620,7 @@ class DataController extends Zend_Controller_Action
{ {
if(empty($uuid)) if(empty($uuid))
{ {
$this->view->msg = view::Msg('alert-error',"无法申请:参数出错,请通过正确的途径访问"); $this->view->msg = view::Msg('alert-error',"Error: Wrong parameter.");
} }
$order = new Order(); $order = new Order();
@ -1630,7 +1630,7 @@ class DataController extends Zend_Controller_Action
{ {
$this->view->msg = view::Msg('alert-error',$state); $this->view->msg = view::Msg('alert-error',$state);
}else{ }else{
$this->view->msg = view::Msg('alert-success',"添加成功!您可以继续浏览数据或是继续提交申请表"); $this->view->msg = view::Msg('alert-success',"Success! You can add more dataset or submit your application.");
} }
if (empty($ac)) $ac='offline1'; if (empty($ac)) $ac='offline1';
@ -1644,7 +1644,7 @@ class DataController extends Zend_Controller_Action
{ {
$this->view->msg = view::Msg('alert-error',$state); $this->view->msg = view::Msg('alert-error',$state);
}else{ }else{
$this->view->msg = view::Msg('alert-success',"数据申请取消成功"); $this->view->msg = view::Msg('alert-success',"The order is canceled.");
} }
$this->_redirect('/data/order'); $this->_redirect('/data/order');
} }

View File

@ -47,7 +47,7 @@ class IndexController extends Zend_Controller_Action
$News = new Archive($this->db); $News = new Archive($this->db);
$time = date("Y-m-d H:i:s",time()); $time = date("Y-m-d H:i:s",time());
$sql = "SELECT * FROM en.archive WHERE is_pub=true AND ts_published<'$time' AND image!='' and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5"; $sql = "SELECT * FROM archive WHERE language='en' and is_pub=true AND ts_published<'$time' AND image!='' and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='featured') order by ts_published desc LIMIT 5";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);
@ -60,7 +60,7 @@ class IndexController extends Zend_Controller_Action
$this->view->news = $rows; $this->view->news = $rows;
//$time = date("Y-m-d H:i:s",time()); //$time = date("Y-m-d H:i:s",time());
$sql = "SELECT * FROM en.archive WHERE is_pub=true AND ts_published<now() and id in (select ar_catalog.aid from en.ar_catalog left join en.ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news') order by ts_published desc LIMIT 12 "; $sql = "SELECT * FROM archive WHERE language='en' and is_pub=true AND ts_published<now() and id in (select ar_catalog.aid from ar_catalog left join ar_category on ar_catalog.cid=ar_category.id where ar_category.ptype='news') order by ts_published desc LIMIT 12 ";
$sth = $this->db->query($sql); $sth = $this->db->query($sql);
$rows = $sth->fetchAll(PDO::FETCH_BOTH); $rows = $sth->fetchAll(PDO::FETCH_BOTH);

View File

@ -1406,7 +1406,7 @@ class ServiceController extends Zend_Controller_Action
$pageSize = 10;//每页容量 $pageSize = 10;//每页容量
$sql = "select md.title,md.uuid from mdref mr $sql = "select md.title,md.uuid from mdref mr
right join normalmetadata md on md.uuid=mr.uuid right join en.normalmetadata md on md.uuid=mr.uuid
where mr.refid=$id"; where mr.refid=$id";
$pagnation=""; $pagnation="";
if(isset($page)) if(isset($page))

View File

@ -40,213 +40,300 @@ class WaterController extends DataController
function indexAction() function indexAction()
{ {
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER - Watershed Allied Telemetry Experimental Research','about');
} }
function documentAction() function documentAction()
{ {
$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 m.uuid from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water'))"); $row=$this->db->fetchAll("select count(*) from reference where language<>'zh' and id in (select refid from mdref where uuid in (select m.uuid from en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water'))");
$sum=$row[0]['count']; $sum=$row[0]['count'];
$sql="select * from reference where id in (select refid from mdref where uuid in (select m.uuid from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water')) order by reference limit ? offset ?"; $sql="select * from reference where language<>'zh' and id in (select refid from mdref where uuid in (select m.uuid from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water')) 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,"Publications");
$this->view->offset=$offset+1; $this->view->offset=$offset+1;
} }
function surveystdAction()
{
}
function coldAction() function coldAction()
{ {
$this->getmd('上游寒区水文试验区'); $this->getmd('the cold region hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Cold region hydrology experiment','about');
$this->_helper->viewRenderer('base');
} }
function bgAction() function bgAction()
{ {
$this->getmd('冰沟流域加密观测区'); $this->getmd('Binggou watershed foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Binggou watershed foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function arAction() function arAction()
{ {
$this->getmd('阿柔加密观测区'); $this->getmd("A''rou foci experimental area",'place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive("WATER: Arou foci experimental area",'about');
$this->_helper->viewRenderer('base');
} }
function bdkAction() function bdkAction()
{ {
$this->getmd('扁都口加密观测区'); $this->getmd('Biandukou (BDK) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Biandukou (BDK) foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function ebAction() function ebAction()
{ {
$this->getmd('峨堡加密观测区'); $this->getmd('Ebao foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Ebao foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function forestAction() function forestAction()
{ {
$this->getmd('森林水文试验区'); $this->getmd('the forest hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Forest hydrology experimental area','about');
$this->_helper->viewRenderer('base');
} }
function dykAction() function dykAction()
{ {
$this->getmd('大野口流域加密观测区'); $this->getmd('Dayekou watershed foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Dayekou watershed foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function plgAction() function plgAction()
{ {
$this->getmd('排露沟流域加密观测区'); $this->getmd('Pailugou watershed (PLG) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Pailugou watershed (PLG) foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function aridAction() function aridAction()
{ {
$this->getmd('中游干旱区水文试验区'); $this->getmd('the arid region hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Arid region hydrology experimental area','about');
$this->_helper->viewRenderer('base');
} }
function hzzAction() function hzzAction()
{ {
$this->getmd('花寨子荒漠加密观测区'); $this->getmd('Huazhaizi foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Huazhaizi foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function ykAction() function ykAction()
{ {
$this->getmd('盈科绿洲加密观测区'); $this->getmd('Yingke oasis station','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Yingke oasis station','about');
$this->_helper->viewRenderer('base');
} }
function zyAction() function zyAction()
{ {
$this->getmd('张掖市加密观测区'); $this->getmd('Zhangye city (ZY) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Zhangye city (ZY) foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function zynocAction() function zynocAction()
{ {
$this->getmd('观象台加密观测区'); $this->getmd('National observatory on climatology at Zhangye (ZYNOC)','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: National observatory on climatology at Zhangye (ZYNOC)','about');
$this->_helper->viewRenderer('base');
} }
function lzgAction() function lzgAction()
{ {
$this->getmd('临泽草地加密观测区'); $this->getmd('Linze grassland foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Linze grassland foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function lzsAction() function lzsAction()
{ {
$this->getmd('临泽站加密观测区'); $this->getmd('Linze station foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Linze station foci experimental area','about');
$this->_helper->viewRenderer('base');
} }
function meteoAction() function meteoAction()
{ {
$this->getmd('气象水文','theme'); $this->getmd('meteorology and hydrology','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: meteorology and hydrology','about');
$this->_helper->viewRenderer('base');
} }
function autometeoAction() function autometeoAction()
{ {
$this->getmd('气象观测','theme'); $this->getmd('the meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the meteorological observation','about');
$this->_helper->viewRenderer('base');
} }
function mobilemeteoAction() function mobilemeteoAction()
{ {
$this->getmd('移动气象观测','theme'); $this->getmd('the mobile meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the mobile meteorological observation','about');
$this->_helper->viewRenderer('base');
} }
function ecAction() function ecAction()
{ {
$this->getmd('涡动相关','theme'); $this->getmd('eddy covariance','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: eddy covariance','about');
$this->_helper->viewRenderer('base');
} }
function lasAction() function lasAction()
{ {
$this->getmd('大孔径闪烁仪','theme'); $this->getmd('the large aperture scintillometer','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the large aperture scintillometer','about');
$this->_helper->viewRenderer('base');
} }
function normalmeteoAction() function normalmeteoAction()
{ {
$this->getmd('常规气象观测','theme'); $this->getmd('the routine meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the routine meteorological observation','about');
$this->_helper->viewRenderer('base');
} }
function regionalmeteoAction() function regionalmeteoAction()
{ {
$this->getmd('区域气象观测','theme'); $this->getmd('the regional meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the regional meteorological observation','about');
$this->_helper->viewRenderer('base');
} }
function dopplerAction() function dopplerAction()
{ {
$this->getmd('降雨','theme'); $this->getmd('dual-polarization Doppler weather radar','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: dual-polarization Doppler weather radar','about');
$this->_helper->viewRenderer('base');
} }
function hydroAction() function hydroAction()
{ {
$this->getmd('水文','theme'); $this->getmd('hydrology','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: hydrology','about');
$this->_helper->viewRenderer('base');
} }
function airsoundingAction() function airsoundingAction()
{ {
$this->getmd('大气廓线','theme'); $this->getmd('atmospheric profile','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: atmospheric profile','about');
$this->_helper->viewRenderer('base');
} }
function aireboneAction() function aireboneAction()
{ {
$this->getmd('航空遥感','theme'); $this->getmd('airborne remote sensing','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: airborne remote sensing','about');
$this->_helper->viewRenderer('base');
} }
function radiometerAction() function radiometerAction()
{ {
$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='water') and id in (select id from keyword where keytype='theme' and keyword ilike '%波段机载微波辐射计') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')"); $state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword ilike '%microwave radiometer') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$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='water') and id in (select id from keyword where keytype='theme' and keyword ilike '%波段机载微波辐射计') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword ilike '%microwave radiometer') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') 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;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Microwave radiometers','about');
$this->_helper->viewRenderer('base');
} }
function lidarAction() function lidarAction()
{ {
//$this->getmd('激光雷达','theme');
$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='water') and id in (select id from keyword where keytype='theme' and keyword='激光雷达') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')"); $state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='lidar') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$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='water') and id in (select id from keyword where keytype='theme' and keyword='激光雷达') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='lidar') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') 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;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: LiDAR','about');
$this->_helper->viewRenderer('base');
} }
function widasAction() function widasAction()
{ {
//$this->getmd('WiDAS','theme');
$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='water') and id in (select id from keyword where keytype='theme' and keyword='红外广角双模式成像仪WiDAS') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')"); $state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='Wide-angle Infrared Dual-mode line/area Array Scanner,WiDAS') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$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='water') and id in (select id from keyword where keytype='theme' and keyword='红外广角双模式成像仪WiDAS') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='Wide-angle Infrared Dual-mode line/area Array Scanner,WiDAS') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') 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;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: WiDAS','about');
$this->_helper->viewRenderer('base');
} }
function asdAction() function asdAction()
{ {
//$this->getmd('成像光谱仪OMIS-II','theme');
$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='water') and id in (select id from keyword where keytype='theme' and keyword='成像光谱仪OMIS-II') and id in (select id from keyword where keytype='theme' and keyword='航空遥感')"); $state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='SWPHI') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$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='water') and id in (select id from keyword where keytype='theme' and keyword='成像光谱仪OMIS-II') and id in (select id from keyword where keytype='theme' and keyword='航空遥感') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='SWPHI') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') 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;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: OMIS-II','about');
$this->_helper->viewRenderer('base');
} }
function satelliteAction() function satelliteAction()
{ {
$this->getmd('卫星遥感','theme'); $this->getmd('satellite remote sensing','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: satellite remote sensing','about');
$this->_helper->viewRenderer('base');
} }
function tagAction() function tagAction()
{ {
$key = $this->_request->getParam('key'); $key = $this->_request->getParam('key');
$keytype = $this->_request->getParam('keytype');
$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);
if (!empty($key)) { if (!empty($key)) {
$this->view->codename=$key; $this->view->codename=$key;
$sql=$this->db->quoteInto('select count(id) from keyword where keyword=?',$key); $sql=$this->db->quoteInto("select count(k.id) from en.keyword k left join en.normalmetadata m on k.id=m.id where length(k.keyword)>0 and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and k.keyword=?",$key);
$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='water') and id in (select id from keyword where keyword='".$key."') order by timebegin,title limit ? offset ?"; $sql="select uuid,title,id,description from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.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='water') group by keyword.keyword order by count desc"); $sql="select k.keyword,count(*),k.keytype from en.keyword k left join en.normalmetadata m on k.id=m.id where length(k.keyword)>0 and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') ";
$k1=$state->fetchAll(); if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" and k.keytype='".$keytype."'";
$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='water') group by k.keyword order by k.keyword"); $sql.=' group by k.keyword,k.keytype order by k.keytype,k.keyword,count desc';
$k2=$state->fetchAll(); $state=$this->db->query($sql);
$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='water') group by k.keyword order by k.keyword"); $this->view->keytype=$keytype;
$k3=$state->fetchAll(); $this->view->keywords=$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='water') group by k.keyword order by k.keyword");
$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='water') group by keyword.keyword order by keyword.keyword");
$k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
} }
} }
@ -263,9 +350,9 @@ class WaterController 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='water') and ".$where); $row=$this->db->fetchAll("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') 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='water') and ".$where." order by timebegin,title limit ? offset ?"; $sql="select uuid,title,id,description from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') 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;
@ -275,24 +362,24 @@ class WaterController 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='water') and timebegin is not null and timebegin::date>date('2007-01-01')"; $sql="select id,uuid,west,south,north,east,title,timebegin,timeend from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and timebegin is not null and timebegin::date>date('2007-01-01')";
$this->view->rows=$this->db->fetchAll($sql); $this->view->rows=$this->db->fetchAll($sql);
} }
function timelineAction() function timelineAction()
{ {
$fn="watertime.xml"; $fn="watertime.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='water') order by ts_created desc limit 1"); $rows=$this->db->fetchAll("select ts_created from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') 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='water') and timebegin is not null order by timebegin,title"); $rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') 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" ';
if ($row['timeend']!='' && $row['timeend']!=$row['timebegin']) $timexml.=' end="'.date($dateformat,strtotime($row['timeend'])).'" isDuration="true"'; if ($row['timeend']!='' && $row['timeend']!=$row['timebegin']) $timexml.=' end="'.date($dateformat,strtotime($row['timeend'])).'" isDuration="true"';
$timexml.= ' title="'.htmlspecialchars(mb_substr($row['title'],11,mb_strlen($row['title'],'UTF-8')-10,'UTF-8')).'" image="/images/westdc_40w.gif" link="/water/'.$row['uuid'].'">'; $timexml.= ' title="'.htmlspecialchars(mb_substr($row['title'],6,mb_strlen($row['title'],'UTF-8')-6,'UTF-8')).'" image="/images/westdc_40w.gif" link="/water/'.$row['uuid'].'">';
$desc_length=mb_strlen($row['description'],"UTF-8"); $desc_length=mb_strlen($row['description'],"UTF-8");
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8"); $desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
if ($desc_length>300) $desc.=" ..."; if ($desc_length>300) $desc.=" ...";
@ -329,18 +416,155 @@ class WaterController extends DataController
} }
private function getmd($keyword,$type='place') private function getmd($keyword,$type='theme')
{ {
$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='water') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')"); if (!is_array($keyword))
{
$keyword=array($keyword);
}
$key="(";
foreach($keyword as $k)
{
$key.="'".$k."',";
}
$key=substr($key,0,-1);
$key.=")";
$keyword=$key;
$state=$this->db->query("select count(m.*) from en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='water' and m.id in (select id from en.keyword where keytype='".$type."' and keyword in ".$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='water') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."') order by timebegin,title limit ? offset ?"; $sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='".$type."' and keyword in ".$keyword.") 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->offset=$offset+1; $this->view->offset=$offset+1;
} }
//获取多项条件并列关系的数据并必须满足limited条件
//$keyword:字符串或字符串数组
//$limited:限制字符串
private function getmdlimited($keyword,$limited)
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
if (!is_array($keyword))
{
$keyword=array($keyword);
}
$key="(";
foreach($keyword as $k)
{
$key.="'".$k."',";
}
$key=substr($key,0,-1);
$key.=")";
$keyword=$key;
$state=$this->db->query("select count(m.*) from en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='water' and m.id in (select id from en.keyword where keyword='".$limited."') and m.id in (select id from en.keyword where keyword in ".$keyword.")");
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keyword='".$limited."') and id in (select id from en.keyword where keyword in ".$keyword.") order by title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
}
//基于数据作者的浏览(包括认证后的数据作者以及未认证的数据作者)
function authorAction()
{
$ac = $this->_request->getParam('ac');
$id = (int)$this->_request->getParam('id');
if ($ac=='verified') {
//已经认证过的数据作者
$this->view->tabID='author-verified';
$this->view->ac='verified';
if ($id) {
//列出作者的数据
$sql="select username,realname from users where id=?";
$this->view->author=$this->db->fetchRow($sql,array($id));
$sql="select m.* from normalmetadata m left join mdauthor a on a.uuid=m.uuid where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and a.userid=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//已经认证过的数据作者
$sql="select u.username,u.realname,u.id,count(u.id) as count from mdauthor a left join users u on a.userid=u.id where a.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and a.status=1 and a.uuid in (select uuid from normalmetadata) group by u.id,u.username,u.realname";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(50);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
} else if ($ac=='unverified' || empty($ac)) {
//未认证的数据作者
$this->view->tabID='author-unverified';
$this->view->ac='unverified';
if ($id) {
//列出数据
$sql="select individual as username from responsible where id=?";
$this->view->author=$this->db->fetchRow($sql,array($id));
$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.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and r.role in ('pointOfContact','resourceProvider','owner') and s.id=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//列出所有作者
$sql="select distinct responsible.individual as username,responsible.id from responsible left join role on role.resid=responsible.id where role.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and role.role in ('pointOfContact','resourceProvider','owner')";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(50);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
}
}
function organizationAction()
{
$page = $this->_request->getParam('page');
$name = $this->_request->getParam('name');
$state=$this->db->query("select distinct responsible.organisation from en.responsible left join en.role on role.resid=responsible.id where role.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and role.role in ('pointOfContact','resourceProvider','owner')");
$this->view->organisation=$state->fetchAll();
if (!empty($name)) {
$this->view->codename=$name;
$sql="select distinct m.* from en.normalmetadata m left join en.role r on m.uuid=r.uuid left join en.responsible s on r.resid=s.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($name));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//提供全部分类列表
}
}
} }