update controllers
This commit is contained in:
parent
f06f42a44d
commit
1174ae3617
|
@ -1,392 +0,0 @@
|
|||
<?php
|
||||
class GlacierController extends DataController
|
||||
{
|
||||
private $limit=20;
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
parent::preDispatch();
|
||||
//$this->_helper->layout->setLayout('glacier');
|
||||
$acName = $this->_request->getActionName();
|
||||
if(in_array($acName,array("rs","dem")))
|
||||
{
|
||||
$this->view->pageIn = "collapse1";
|
||||
}
|
||||
if(in_array($acName,array("glacier","lake")))
|
||||
{
|
||||
$this->view->pageIn = "collapse2";
|
||||
}
|
||||
if(in_array($acName,array("meteo","hydro","gps",'lidar','material','movement','physical','photogrammetry','frozensoil','vegetation','quatemary')))
|
||||
{
|
||||
$this->view->pageIn = "collapse3";
|
||||
}
|
||||
$this->view->pageID = "glacier-".$acName;
|
||||
}
|
||||
|
||||
function indexAction()
|
||||
{
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-项目简介','about');
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据浏览
|
||||
*/
|
||||
function browseAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='glacier') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$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='glacier') ")->order('title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function thumbAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='glacier') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$select=$this->db->select();
|
||||
$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='glacier') ")
|
||||
->order('m.title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
}
|
||||
|
||||
function documentAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='glacier') ))");
|
||||
$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='glacier') )) order by reference limit ? offset ?";
|
||||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function geobaseAction()
|
||||
{
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-基础数据','about');
|
||||
$this->getmd(array('遥感影像','DEM'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function demAction()
|
||||
{
|
||||
$this->getmd('DEM');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-DEM','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function rsAction()
|
||||
{
|
||||
$this->getmd('遥感影像');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-遥感影像','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function inventoryAction()
|
||||
{
|
||||
$this->getmd(array('冰川编目','冰湖编目'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川冰湖编目','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function glacierAction()
|
||||
{
|
||||
$this->getmd('冰川编目');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川编目','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function lakeAction()
|
||||
{
|
||||
$this->getmd('冰湖编目');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰湖编目','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function fieldAction()
|
||||
{
|
||||
$this->getmd(array('水文','流量','水质','同位素','径流','水位','气象','雨量','GPS',
|
||||
'雷达','雷达测厚','冰川厚度','物质平衡','花杆','运动速度','花杆消融观测','冰舌',
|
||||
'冰雪物理过程','冰温','摄影测量','照片','第四纪','冻土','植被'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-野外考察与定位观测','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function meteoAction()
|
||||
{
|
||||
$this->getmd(array('气象','雨量'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-气象','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function hydroAction()
|
||||
{
|
||||
$this->getmd(array('水文','流量','水质','同位素','径流','水位'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-水文','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function gpsAction()
|
||||
{
|
||||
$this->getmd('GPS','theme');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-GPS','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function lidarAction()
|
||||
{
|
||||
$this->getmd(array('雷达','雷达测厚','冰川厚度'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-雷达测厚','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function materialAction()
|
||||
{
|
||||
$this->getmd(array('物质平衡','花杆'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-物质平衡','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function movementAction()
|
||||
{
|
||||
$this->getmd(array('运动速度','花杆消融观测','冰舌'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰川运动','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function physicalAction()
|
||||
{
|
||||
$this->getmd(array('冰雪物理过程','冰温'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冰雪物理过程','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function photogrammetryAction()
|
||||
{
|
||||
$this->getmd(array('摄影测量','照片'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-近景摄影测量','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function vegetationAction()
|
||||
{
|
||||
$this->getmd('植被');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-植被调查','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function frozensoilAction()
|
||||
{
|
||||
$this->getmd('冻土');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-冻土调查','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function quatemaryAction()
|
||||
{
|
||||
$this->getmd('第四纪');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('中国冰川资源及其变化调查-第四纪','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
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='glacier') order by timebegin,title";
|
||||
$this->view->metadata=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function tagAction()
|
||||
{
|
||||
$key = $this->_request->getParam('key');
|
||||
$keytype = $this->_request->getParam('keytype');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $page=1;
|
||||
$offset=$this->limit*($page-1);
|
||||
if (!empty($key)) {
|
||||
$this->view->codename=$key;
|
||||
$sql=$this->db->quoteInto("select count(k.id) from keyword k left join normalmetadata m on k.id=m.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='glaicer') and k.keyword=?",$key);
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$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='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->page=new Pagination($sum,$page,$this->limit);
|
||||
} else {
|
||||
$sql="select k.keyword,count(*),k.keytype from keyword k left join 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='glacier') ";
|
||||
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" and k.keytype='".$keytype."'";
|
||||
$sql.=' group by k.keyword,k.keytype order by k.keytype,k.keyword,count desc';
|
||||
$state=$this->db->query($sql);
|
||||
$this->view->keytype=$keytype;
|
||||
$this->view->keywords=$state->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
function searchAction()
|
||||
{
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
$form=new SearchForm();
|
||||
$this->view->form=$form;
|
||||
//$form->submit->setLabel('快速搜索');
|
||||
$key=$this->_request->getParam('q');
|
||||
if (!empty($key)) {
|
||||
$search=new Search($key);
|
||||
$where=$search->sql_expr(array("title","description"));
|
||||
$page=@(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='glacier') and ".$where);
|
||||
$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='glacier') and ".$where." 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);
|
||||
$this->view->key=$key;
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
}
|
||||
|
||||
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='glacier') and timebegin is not null";
|
||||
$this->view->rows=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function timelineAction()
|
||||
{
|
||||
$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='glacier') order by ts_created desc limit 1");
|
||||
$last_update=strtotime($rows[0]['ts_created']);
|
||||
if (!file_exists($fn) || (filemtime($fn)<$last_update))
|
||||
{
|
||||
$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='glacier') and timebegin is not null order by timebegin,title");
|
||||
$timexml='<data>';
|
||||
foreach($rows as $row) {
|
||||
$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"';
|
||||
$timexml.= ' title="'.htmlspecialchars($row['title']).'" image="/images/westdc_40w.gif" link="/glacier/view/uuid/'.$row['uuid'].'">';
|
||||
$desc_length=mb_strlen($row['description'],"UTF-8");
|
||||
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
|
||||
if ($desc_length>300) $desc.=" ...";
|
||||
$timexml.=htmlspecialchars($desc);
|
||||
$timexml.="</event>\n";
|
||||
}
|
||||
$timexml.='</data>';
|
||||
$fp=fopen($fn,'w');
|
||||
fwrite($fp,$timexml);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function categoryAction()
|
||||
{
|
||||
$code = (int)$this->_request->getParam('code');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='glacier') group by c.code,cc.name,cc.name_zh");
|
||||
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='glacier') and id in (select id from category where code=".$code.")");
|
||||
$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='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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
|
||||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
|
||||
private function getmd($keyword,$type='theme')
|
||||
{
|
||||
$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 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 in ".$keyword.")");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='glacier') and id in (select id from keyword where keytype='".$type."' and keyword in ".$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);
|
||||
$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 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 keyword='".$limited."') and m.id in (select id from keyword where keyword in ".$keyword.")");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='glacier') and id in (select id from keyword where keyword='".$limited."') and id in (select id from 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;
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
class HaiheController extends DataController
|
||||
{
|
||||
private $limit=20;
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
parent::preDispatch();
|
||||
$this->debug = 1;
|
||||
$acName = $this->_request->getActionName();
|
||||
$this->view->pageID = "haihe-".$acName;
|
||||
//$this->_helper->layout->setLayout('heihe');
|
||||
}
|
||||
|
||||
function indexAction()
|
||||
{
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('海河流域多尺度地表通量与气象要素观测数据集','about');
|
||||
}
|
||||
|
||||
function documentAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='haihe') ))");
|
||||
$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='haihe') )) order by reference limit ? offset ?";
|
||||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function daxingAction()
|
||||
{
|
||||
$this->getmd(array('大兴区'),'place');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function miyunAction()
|
||||
{
|
||||
$this->getmd(array('密云'),'place');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function guantaoAction()
|
||||
{
|
||||
$this->getmd(array('馆陶县'),'place');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function huailaiAction()
|
||||
{
|
||||
$this->getmd(array('怀来县'),'place');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function viewAction()
|
||||
{
|
||||
parent::viewAction();
|
||||
$this->_helper->viewRenderer('haihe/view');
|
||||
}
|
||||
|
||||
private function getmd($keyword,$type='theme')
|
||||
{
|
||||
$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 normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='haihe' and m.id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.")");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='haihe') and id in (select id from 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,859 +0,0 @@
|
|||
<?php
|
||||
class HiwaterController extends DataController
|
||||
{
|
||||
private $limit=20;
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
parent::preDispatch();
|
||||
//$this->_helper->layout->setLayout('hiwater');
|
||||
$this->debug = 1;
|
||||
$acName = $this->_request->getActionName();
|
||||
if(in_array($acName,array("aviation","radiometer","lidar","ccdlidar","widas",'ccdwidas',"nearvis","thermal")))
|
||||
{
|
||||
$this->view->pageIn = "collapse1";
|
||||
}
|
||||
else if(in_array($acName,array("airborne","demdsm","reflectance","vegtypeair","vegparam","temperature","soilmoisture")))
|
||||
{
|
||||
$this->view->pageIn = "collapse2";
|
||||
}
|
||||
else if(in_array($acName,array("hmon",'hmon2012','hmon2013','hmon2014','hmon2015','hmon2016','hmon2012up','hmon2012middle','hmon2012down','hmon2013up','hmon2013middle','hmon2013down','hmon2014up','hmon2014middle','hmon2014down','hmon2015up','hmon2015middle','hmon2015down','hmon2016up','hmon2016middle','hmon2016down','super','normal','prec')))
|
||||
{
|
||||
$this->view->pageIn = "collapse3";
|
||||
}
|
||||
else if(in_array($acName,array("cgs","calibration","ground",'sync')))
|
||||
{
|
||||
$this->view->pageIn = "collapse4";
|
||||
}
|
||||
else if(in_array($acName,array("wsn","waternet","soilnet","bnunet",'bnulai')))
|
||||
{
|
||||
$this->view->pageIn = "collapse5";
|
||||
}
|
||||
else if(in_array($acName,array("mso","autometeo","ec",'las',"cosmos","tdp","isotope")))
|
||||
{
|
||||
$this->view->pageIn = "collapse6";
|
||||
}
|
||||
else if(in_array($acName,array("rsproduct","dem","precipitation",'sm',"snow","vegtype","vegcov",'phenology','npp','lst')))
|
||||
{
|
||||
$this->view->pageIn = "collapse7";
|
||||
}
|
||||
else if(in_array($acName,array("browse","thumb","fund","tag","timeline","timemap",'author','organization')))
|
||||
{
|
||||
$this->view->pageIn = "collapse10";
|
||||
}
|
||||
else if(in_array($acName,array("other")))
|
||||
{
|
||||
$this->view->pageIn = "collapse9";
|
||||
}
|
||||
$this->view->pageID = "hiwater-".$acName;
|
||||
// $this->_helper->layout->setLayout('heihe');
|
||||
}
|
||||
|
||||
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='hiwater') and length(t.data)>2 order by random() limit 3";
|
||||
$this->view->meatdata=$this->db->fetchAll($sql);
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:黑河流域生态-水文过程综合遥感观测联合试验','about');
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据浏览
|
||||
*/
|
||||
function browseAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='hiwater') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$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='hiwater') ")->order('title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function thumbAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='hiwater') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$select=$this->db->select();
|
||||
$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='hiwater') ")
|
||||
->order('m.title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
}
|
||||
|
||||
function documentAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='hiwater') ))");
|
||||
$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='hiwater') )) order by reference limit ? offset ?";
|
||||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function aviationAction()
|
||||
{
|
||||
$this->getmdlimited(array('WiDAS','PLMR','Lidar','CASI','热红外高光谱数据'),'航空遥感');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function radiometerAction()
|
||||
{
|
||||
$this->getmdlimited('PLMR','航空遥感');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function lidarAction()
|
||||
{
|
||||
$this->getmdlimited('激光雷达','航空遥感',array('CCD'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function ccdlidarAction()
|
||||
{
|
||||
$this->getmdrestricted(array('CCD','航空遥感',"激光雷达"));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function widasAction()
|
||||
{
|
||||
$this->getmdlimited('WIDAS','航空遥感',array('CCD'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function ccdwidasAction()
|
||||
{
|
||||
$this->getmdrestricted(array('CCD','航空遥感','WIDAS'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function nearvisAction()
|
||||
{
|
||||
$this->getmdlimited('CASI','航空遥感');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function thermalAction()
|
||||
{
|
||||
$this->getmdlimited('热红外高光谱数据','航空遥感');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function airborneAction()
|
||||
{
|
||||
$this->getmdlimited(array('DEM','DSM','DOM','地表反照率','地表反射率','植被类型','植被结构参数','土壤水分','地表温度'),'航空遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function demdsmAction()
|
||||
{
|
||||
$this->getmdlimited(array('DEM','DSM','DOM'),"航空遥感产品");
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function reflectanceAction()
|
||||
{
|
||||
$this->getmdlimited(array('地表反照率','地表反射率'),"航空遥感产品");
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function vegtypeairAction()
|
||||
{
|
||||
$this->getmdlimited(array('植被类型'),'航空遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function vegparamAction()
|
||||
{
|
||||
$this->getmdlimited(array("",'植被结构参数'),"航空遥感产品");
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function soilmoistureAction()
|
||||
{
|
||||
$this->getmdlimited(array('','土壤水分'),"航空遥感产品");
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function temperatureAction()
|
||||
{
|
||||
$this->getmdlimited(array('','地表温度'),"航空遥感产品");
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function hmonAction()
|
||||
{
|
||||
$this->getmd(array('水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function superAction()
|
||||
{
|
||||
$this->getmdlimited(array('阿柔超级站','大满超级站','四道桥超级站'),'水文气象');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function normalAction()
|
||||
{
|
||||
$this->getmdlimited(array('景阳岭站','峨堡站','黄草沟站','阿柔阴坡站','阿柔阳坡站','黄藏寺站','大沙龙站','寺大隆站','排露沟林前气象站','水源涵养林研究院观测站','巴吉滩戈壁站','神沙窝沙漠站','张掖湿地站',
|
||||
'花寒子荒漠站','五里墩气象站','四道桥混合林站','四道桥胡杨林站','四道桥裸地站','四道桥农田站','黑河上游生态-水文试验研究站','临泽内陆河流域研究站','阿拉善荒漠生态-水文实验研究站'),'水文气象');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function autometeoAction()
|
||||
{
|
||||
$this->getmdlimited(array('','自动气象站'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
|
||||
}
|
||||
function ecAction()
|
||||
{
|
||||
$this->getmdlimited(array('','涡动相关仪'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
|
||||
}
|
||||
function lasAction()
|
||||
{
|
||||
$this->getmdlimited(array('','大孔径闪烁仪'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
|
||||
|
||||
}
|
||||
function precAction()
|
||||
{
|
||||
$this->getmd(array('','河川径流观测'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function cgsAction()
|
||||
{
|
||||
$this->getmd(array('定标观测','地基遥感观测','地面同步观测'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function calibrationAction()
|
||||
{
|
||||
$this->getmd(array('','定标观测'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function groundAction()
|
||||
{
|
||||
$this->getmd(array('','地基遥感观测'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function syncAction()
|
||||
{
|
||||
$this->getmd(array('','地面同步观测'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function wsnAction()
|
||||
{
|
||||
$this->getmd(array('WATERNET','SoilNET','BNUNET','BNULAI'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function waternetAction()
|
||||
{
|
||||
$this->getmd(array('','WATERNET'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function soilnetAction()
|
||||
{
|
||||
$this->getmd(array('','SoilNET'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function bnunetAction()
|
||||
{
|
||||
$this->getmd(array('','BNUNET'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function bnulaiAction()
|
||||
{
|
||||
$this->getmdlimited('LAI','生态水文无线传感器网络');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function satelliteAction()
|
||||
{
|
||||
$this->getmd(array('','卫星遥感'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function soilAction()
|
||||
{
|
||||
$this->getmd(array('','卫星遥感'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function meteoAction()
|
||||
{
|
||||
$this->getmd('气象','theme');
|
||||
}
|
||||
|
||||
function hydroAction()
|
||||
{
|
||||
$this->getmd('水文观测','theme');
|
||||
}
|
||||
function irragationAction()
|
||||
{
|
||||
$this->getmd('灌溉','theme');
|
||||
}
|
||||
|
||||
function obsAction()
|
||||
{
|
||||
$this->getmd('试验','theme');
|
||||
}
|
||||
|
||||
function msoAction()
|
||||
{
|
||||
$this->getmdlimited(array('自动气象站','涡动相关仪','大孔径闪烁仪','稳定同位素观测系统','热扩散液流计(TDP)','宇宙射线土壤水分'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
|
||||
}
|
||||
|
||||
function isotopeAction()
|
||||
{
|
||||
$this->getmdlimited(array('','稳定同位素观测系统'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function tdpAction()
|
||||
{
|
||||
$this->getmdlimited(array('','热扩散液流计(TDP)'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function cosmosAction()
|
||||
{
|
||||
$this->getmdlimited(array('','宇宙射线土壤水分'),'通量观测矩阵');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function rsproductAction()
|
||||
{
|
||||
$this->getmd(array('卫星遥感产品'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function demAction()
|
||||
{
|
||||
$this->getmdlimited(array('DEM','DOM'),'数据产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function precipitationAction()
|
||||
{
|
||||
$this->getmdlimited(array('降水',''),'数据产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function smAction()
|
||||
{
|
||||
$this->getmdlimited(array('土壤水分',""),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function snowAction()
|
||||
{
|
||||
$this->getmdlimited(array('积雪',""),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function vegtypeAction()
|
||||
{
|
||||
$this->getmdlimited(array('植被类型',''),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function vegcovAction()
|
||||
{
|
||||
$this->getmdlimited(array('植被覆盖度',''),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function phenologyAction()
|
||||
{
|
||||
$this->getmdlimited(array('物候期',''),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function nppAction()
|
||||
{
|
||||
$this->getmdlimited(array('NPP',''),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function lstAction()
|
||||
{
|
||||
$this->getmdlimited(array('地表温度',''),'卫星遥感产品');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2012Action()
|
||||
{
|
||||
$this->getmdrestricted(array('2012','水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2013Action()
|
||||
{
|
||||
$this->getmdrestricted(array('2013','水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2014Action()
|
||||
{
|
||||
$this->getmdrestricted(array('2014','水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2012upAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2012','上游寒区水文试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2012middleAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2012','中游人工绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2012downAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2012','下游天然绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2013upAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2013','上游寒区水文试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2013middleAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2013','中游人工绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2013downAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2013','下游天然绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2014upAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2014','上游寒区水文试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2014middleAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2014','中游人工绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2014downAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2014','下游天然绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function hmon2015Action()
|
||||
{
|
||||
$this->getmdrestricted(array('2015','水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2015upAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2015','上游寒区水文试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2015middleAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2015','中游人工绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2015downAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2015','下游天然绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
function hmon2016Action()
|
||||
{
|
||||
$this->getmdrestricted(array('2016','水文气象观测网'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('HiWATER:流域水文气象观测网','about');
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2016upAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2016','上游寒区水文试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2016middleAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2016','中游人工绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
function hmon2016downAction()
|
||||
{
|
||||
$this->getmdrestricted(array('2016','下游天然绿洲试验区','水文气象观测网'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
}
|
||||
|
||||
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='hiwater') order by timebegin,title";
|
||||
$this->view->metadata=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function tagAction()
|
||||
{
|
||||
$key = $this->_request->getParam('key');
|
||||
$keytype = $this->_request->getParam('keytype');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $page=1;
|
||||
$offset=$this->limit*($page-1);
|
||||
if (!empty($key)) {
|
||||
$this->view->codename=$key;
|
||||
$sql=$this->db->quoteInto("select count(k.id) from keyword k left join normalmetadata m on k.id=m.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 k.keyword=?",$key);
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$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='hiwater') 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->page=new Pagination($sum,$page,$this->limit);
|
||||
} else {
|
||||
$sql="select k.keyword,count(*),k.keytype from keyword k left join normalmetadata m on k.id=m.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') ";
|
||||
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" and k.keytype='".$keytype."'";
|
||||
$sql.=' group by k.keyword,k.keytype order by k.keytype,k.keyword,count desc';
|
||||
$state=$this->db->query($sql);
|
||||
$this->view->keytype=$keytype;
|
||||
$this->view->keywords=$state->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
function searchAction()
|
||||
{
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
$form=new SearchForm();
|
||||
$this->view->form=$form;
|
||||
//$form->submit->setLabel('快速搜索');
|
||||
$key=$this->_request->getParam('q');
|
||||
if (!empty($key)) {
|
||||
$search=new SimpleSearch($key);
|
||||
$where=$search->sql_expr(array("title","description"));
|
||||
$page=@(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='hiwater') and ".$where);
|
||||
$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='hiwater') and ".$where." 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);
|
||||
$this->view->key=$key;
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
}
|
||||
|
||||
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='hiwater') and timebegin is not null";
|
||||
$this->view->rows=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function timelineAction()
|
||||
{
|
||||
$fn="hiwatertime.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='hiwater') order by ts_created desc limit 1");
|
||||
$last_update=strtotime($rows[0]['ts_created']);
|
||||
if (!file_exists($fn) || (filemtime($fn)<$last_update))
|
||||
{
|
||||
$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='hiwater') and timebegin is not null order by timebegin,title");
|
||||
$timexml='<data>';
|
||||
foreach($rows as $row) {
|
||||
$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"';
|
||||
$timexml.= ' title="'.htmlspecialchars($row['title']).'" image="/images/westdc_40w.gif" link="/hiwater/view/uuid/'.$row['uuid'].'">';
|
||||
$desc_length=mb_strlen($row['description'],"UTF-8");
|
||||
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
|
||||
if ($desc_length>300) $desc.=" ...";
|
||||
$timexml.=htmlspecialchars($desc);
|
||||
$timexml.="</event>\n";
|
||||
}
|
||||
$timexml.='</data>';
|
||||
$fp=fopen($fn,'w');
|
||||
fwrite($fp,$timexml);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function categoryAction()
|
||||
{
|
||||
$code = (int)$this->_request->getParam('code');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='hiwater') group by c.code,cc.name,cc.name_zh");
|
||||
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='hiwater') and id in (select id from category where code=".$code.")");
|
||||
$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='hiwater') 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
|
||||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
|
||||
function viewAction()
|
||||
{
|
||||
parent::viewAction();
|
||||
$this->_helper->viewRenderer('hiwater/view');
|
||||
}
|
||||
|
||||
private function getmd($keyword,$type='theme')
|
||||
{
|
||||
$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 normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='hiwater' and m.id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.")");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='hiwater') and id in (select id from 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
//获取多项条件并列关系的数据并必须满足limited条件
|
||||
//$keyword:字符串或字符串数组
|
||||
//$limited:限制字符串
|
||||
//$without:明确不包含的字符串数组
|
||||
private function getmdlimited($keyword,$limited,$without='')
|
||||
{
|
||||
$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;
|
||||
|
||||
if (!empty($without))
|
||||
{
|
||||
if (!is_array($without))
|
||||
{
|
||||
$without=array($without);
|
||||
}
|
||||
$withoutkey="(";
|
||||
foreach ($without as $wo)
|
||||
{
|
||||
$withoutkey.="'".$wo."',";
|
||||
}
|
||||
$withoutkey=substr($withoutkey,0,-1);
|
||||
$withoutkey.=")";
|
||||
}
|
||||
|
||||
$sql="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='hiwater' and m.id in (select id from keyword where keyword='".$limited."')
|
||||
and m.id in (select id from keyword where keyword in ".$keyword.")";
|
||||
if (!empty($without)) $sql.=" and m.id not in (select id from keyword where keyword in $withoutkey)";
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='hiwater')
|
||||
and id in (select id from keyword where keyword='".$limited."')
|
||||
and id in (select id from keyword where keyword in ".$keyword.")";
|
||||
if (!empty($without)) $sql.=" and id not in (select id from keyword where keyword in $withoutkey)";
|
||||
$sql.=" 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;
|
||||
}
|
||||
|
||||
//获取多项必须满足的条件
|
||||
//$keyword:字符串或字符串数组
|
||||
private function getmdrestricted($keyword)
|
||||
{
|
||||
$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.="m.id in (select id from keyword where keyword='".$k."') and ";
|
||||
}
|
||||
$key=substr($key,0,-4);
|
||||
$key.=")";
|
||||
$keyword=$key;
|
||||
|
||||
$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='hiwater' and $keyword");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@todo: add order with title
|
||||
$sql="select uuid,title from normalmetadata m where m.uuid in
|
||||
(select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater')
|
||||
and $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 fundAction()
|
||||
{
|
||||
$id = (int)$this->_request->getParam('id');
|
||||
if (!empty($id)) {
|
||||
$sql="select * from fund where id=?";
|
||||
$this->view->fund=$this->db->fetchRow($sql,array($id));
|
||||
if ($this->view->fund) {
|
||||
$sql="select distinct m.* from normalmetadata m left join mdfund mf on m.uuid=mf.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 mf.fid=?";
|
||||
$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 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.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by f.ts_created desc";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$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;
|
||||
$this->_helper->viewRenderer('fund-list');
|
||||
}
|
||||
}
|
||||
|
||||
function organizationAction()
|
||||
{
|
||||
$page = $this->_request->getParam('page');
|
||||
$name = $this->_request->getParam('name');
|
||||
$state=$this->db->query("select distinct responsible.organisation 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')");
|
||||
$this->view->organisation=$state->fetchAll();
|
||||
if (!empty($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 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 {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,15 +14,15 @@ class IndexController extends Zend_Controller_Action
|
|||
{
|
||||
$this->_helper->layout->setLayout('layout-sanji');
|
||||
//统计数据
|
||||
$sql='select (select count(*) from users) as usernum,(select count(*) from metadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum';
|
||||
$sql='select (select count(*) from users) as usernum,(select count(*) from polesmetadata) as metanum,(select count(*) from offlineapp where ts_approved is not null ) as offlinenum';
|
||||
$row=$this->db->fetchRow($sql);
|
||||
$this->view->usernum=$row['usernum'];
|
||||
$this->view->metanum=$row['metanum'];
|
||||
$this->view->offlinenum=$row['offlinenum'];
|
||||
/*$sql='select count(*) from metadata';
|
||||
/*$sql='select count(*) from polesmetadata';
|
||||
$row=$this->db->fetchRow($sql);
|
||||
$this->view->metanum=$row['count'];*/
|
||||
$sql="select sum(filesize) as sum,datatype from metadata group by datatype";
|
||||
$sql="select sum(filesize) as sum,datatype from polesmetadata group by datatype";
|
||||
$rows=$this->db->fetchAll($sql);
|
||||
foreach($rows as $row)
|
||||
{
|
||||
|
@ -35,12 +35,12 @@ class IndexController extends Zend_Controller_Action
|
|||
$sql="select * from datafeature order by id desc";
|
||||
$this->view->feature=$this->db->fetchRow($sql);
|
||||
//下载最多数据(top 5)
|
||||
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata m left join dataorder d on m.uuid=d.uuid group by m.id order by count(d.uuid) desc limit 8)";
|
||||
$sql="select uuid,title,id from polesmetadata where id in (select m.id from polesmetadata m left join dataorder d on m.uuid=d.uuid group by m.id order by count(d.uuid) desc limit 8)";
|
||||
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||
$this->view->mdtop=$this->db->fetchAll($sql);
|
||||
$sql="select uuid,title,id from normalmetadata where id in (select m.id from normalmetadata m left join dataorder d on m.uuid=d.uuid group by m.id order by id desc limit 8)";
|
||||
$sql="select uuid,title,id from polesmetadata where id in (select m.id from polesmetadata m left join dataorder d on m.uuid=d.uuid group by m.id order by id desc limit 8)";
|
||||
$this->view->offlinemdtop=$this->db->fetchAll($sql);
|
||||
$sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()";
|
||||
$sql="select m.uuid,m.title,m.id,m.description from polesmetadata m left join thumbnail t on m.id=t.id where length(t.data)>2 order by random()";
|
||||
$this->view->mdrandom=$this->db->fetchRow($sql);
|
||||
//搜索
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
|
@ -78,7 +78,7 @@ class IndexController extends Zend_Controller_Action
|
|||
|
||||
$this->view->list_news = $rows;
|
||||
|
||||
$sql="select d.*,m.ts_published as publish_year from datadoi d left join metadata m on d.uuid=m.uuid where length(d.title)>1 and d.ts_published is not null order by ts_published desc limit 4";
|
||||
$sql="select d.*,m.ts_published as publish_year from datadoi d left join polesmetadata m on d.uuid=m.uuid where length(d.title)>1 and d.ts_published is not null order by ts_published desc limit 4";
|
||||
$sth = $this->db->query($sql);
|
||||
$this->view->dois = $sth->fetchAll();
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
class NepalquakeController extends Zend_Controller_Action
|
||||
{
|
||||
function indexAction()
|
||||
{
|
||||
$this->_helper->ViewRenderer->setNoRender();
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_redirect("http://nepalquake.westgis.ac.cn/");
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,346 +0,0 @@
|
|||
<?php
|
||||
class WaterController extends DataController
|
||||
{
|
||||
private $limit=20;
|
||||
function preDispatch()
|
||||
{
|
||||
parent::preDispatch();
|
||||
$this->debug = 0;
|
||||
$acName = $this->_request->getActionName();
|
||||
if(in_array($acName,array("cold","bg","ar","bdk","eb")))
|
||||
{
|
||||
$this->view->pageIn = "collapse1";
|
||||
}
|
||||
if(in_array($acName,array("forest","dyk","plg")))
|
||||
{
|
||||
$this->view->pageIn = "collapse2";
|
||||
}
|
||||
if(in_array($acName,array("arid","hzz","yk",'zy','zynoc','lzg','lzs')))
|
||||
{
|
||||
$this->view->pageIn = "collapse3";
|
||||
}
|
||||
if(in_array($acName,array("meteo","autometeo","mobilemeteo","ec",'las','normalmeteo','regionalmeteo','doppler','hydro','airsounding')))
|
||||
{
|
||||
$this->view->pageIn = "collapse4";
|
||||
}
|
||||
if(in_array($acName,array("radiometer","airebone","lidar","widas",'asd')))
|
||||
{
|
||||
$this->view->pageIn = "collapse5";
|
||||
}
|
||||
if(in_array($acName,array("satellite")))
|
||||
{
|
||||
$this->view->pageIn = "collapse6";
|
||||
}
|
||||
if(in_array($acName,array("surveystd","document")))
|
||||
{
|
||||
$this->view->pageIn = "collapse7";
|
||||
}
|
||||
$this->view->pageID = "water-".$acName;
|
||||
}
|
||||
|
||||
function indexAction()
|
||||
{
|
||||
}
|
||||
function documentAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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'))");
|
||||
$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 ?";
|
||||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
function surveystdAction()
|
||||
{
|
||||
}
|
||||
function coldAction()
|
||||
{
|
||||
$this->getmd('上游寒区水文试验区');
|
||||
}
|
||||
function bgAction()
|
||||
{
|
||||
$this->getmd('冰沟流域加密观测区');
|
||||
}
|
||||
function arAction()
|
||||
{
|
||||
$this->getmd('阿柔加密观测区');
|
||||
}
|
||||
function bdkAction()
|
||||
{
|
||||
$this->getmd('扁都口加密观测区');
|
||||
}
|
||||
function ebAction()
|
||||
{
|
||||
$this->getmd('峨堡加密观测区');
|
||||
}
|
||||
function forestAction()
|
||||
{
|
||||
$this->getmd('森林水文试验区');
|
||||
}
|
||||
function dykAction()
|
||||
{
|
||||
$this->getmd('大野口流域加密观测区');
|
||||
}
|
||||
function plgAction()
|
||||
{
|
||||
$this->getmd('排露沟流域加密观测区');
|
||||
}
|
||||
function aridAction()
|
||||
{
|
||||
$this->getmd('中游干旱区水文试验区');
|
||||
}
|
||||
function hzzAction()
|
||||
{
|
||||
$this->getmd('花寨子荒漠加密观测区');
|
||||
}
|
||||
function ykAction()
|
||||
{
|
||||
$this->getmd('盈科绿洲加密观测区');
|
||||
}
|
||||
function zyAction()
|
||||
{
|
||||
$this->getmd('张掖市加密观测区');
|
||||
}
|
||||
function zynocAction()
|
||||
{
|
||||
$this->getmd('观象台加密观测区');
|
||||
}
|
||||
function lzgAction()
|
||||
{
|
||||
$this->getmd('临泽草地加密观测区');
|
||||
}
|
||||
function lzsAction()
|
||||
{
|
||||
$this->getmd('临泽站加密观测区');
|
||||
}
|
||||
function meteoAction()
|
||||
{
|
||||
$this->getmd('气象水文','theme');
|
||||
}
|
||||
function autometeoAction()
|
||||
{
|
||||
$this->getmd('气象观测','theme');
|
||||
}
|
||||
function mobilemeteoAction()
|
||||
{
|
||||
$this->getmd('移动气象观测','theme');
|
||||
}
|
||||
function ecAction()
|
||||
{
|
||||
$this->getmd('涡动相关','theme');
|
||||
}
|
||||
function lasAction()
|
||||
{
|
||||
$this->getmd('大孔径闪烁仪','theme');
|
||||
}
|
||||
function normalmeteoAction()
|
||||
{
|
||||
$this->getmd('常规气象观测','theme');
|
||||
}
|
||||
function regionalmeteoAction()
|
||||
{
|
||||
$this->getmd('区域气象观测','theme');
|
||||
}
|
||||
function dopplerAction()
|
||||
{
|
||||
$this->getmd('降雨','theme');
|
||||
}
|
||||
function hydroAction()
|
||||
{
|
||||
$this->getmd('水文','theme');
|
||||
}
|
||||
function airsoundingAction()
|
||||
{
|
||||
$this->getmd('大气廓线','theme');
|
||||
}
|
||||
function aireboneAction()
|
||||
{
|
||||
$this->getmd('航空遥感','theme');
|
||||
}
|
||||
function radiometerAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='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='航空遥感')");
|
||||
$row=$state->fetchAll();
|
||||
$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 ?";
|
||||
$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 lidarAction()
|
||||
{
|
||||
//$this->getmd('激光雷达','theme');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='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='航空遥感')");
|
||||
$row=$state->fetchAll();
|
||||
$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 ?";
|
||||
$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 widasAction()
|
||||
{
|
||||
//$this->getmd('WiDAS','theme');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='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='航空遥感')");
|
||||
$row=$state->fetchAll();
|
||||
$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 ?";
|
||||
$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 asdAction()
|
||||
{
|
||||
//$this->getmd('成像光谱仪OMIS-II','theme');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='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='航空遥感')");
|
||||
$row=$state->fetchAll();
|
||||
$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 ?";
|
||||
$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 satelliteAction()
|
||||
{
|
||||
$this->getmd('卫星遥感','theme');
|
||||
}
|
||||
|
||||
function tagAction()
|
||||
{
|
||||
$key = $this->_request->getParam('key');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $page=1;
|
||||
$offset=$this->limit*($page-1);
|
||||
if (!empty($key)) {
|
||||
$this->view->codename=$key;
|
||||
$sql=$this->db->quoteInto('select count(id) from keyword where keyword=?',$key);
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$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 ?";
|
||||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
} 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");
|
||||
$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='water') group by k.keyword order by k.keyword");
|
||||
$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='water') group by k.keyword order by k.keyword");
|
||||
$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='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);
|
||||
}
|
||||
}
|
||||
|
||||
function searchAction()
|
||||
{
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
$form=new SearchForm();
|
||||
$this->view->form=$form;
|
||||
//$form->submit->setLabel('快速搜索');
|
||||
$key=$this->_request->getParam('q');
|
||||
if (!empty($key)) {
|
||||
$search=new Search($key);
|
||||
$where=$search->sql_expr(array("title","description"));
|
||||
$page=@(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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);
|
||||
$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 ?";
|
||||
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->key=$key;
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
}
|
||||
|
||||
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')";
|
||||
$this->view->rows=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function timelineAction()
|
||||
{
|
||||
$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");
|
||||
$last_update=strtotime($rows[0]['ts_created']);
|
||||
if (!file_exists($fn) || (filemtime($fn)<$last_update))
|
||||
{
|
||||
$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");
|
||||
$timexml='<data>';
|
||||
foreach($rows as $row) {
|
||||
$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"';
|
||||
$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'].'">';
|
||||
$desc_length=mb_strlen($row['description'],"UTF-8");
|
||||
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
|
||||
if ($desc_length>300) $desc.=" ...";
|
||||
$timexml.=htmlspecialchars($desc);
|
||||
$timexml.="</event>\n";
|
||||
}
|
||||
$timexml.='</data>';
|
||||
$fp=fopen($fn,'w');
|
||||
fwrite($fp,$timexml);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function categoryAction()
|
||||
{
|
||||
$code = (int)$this->_request->getParam('code');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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 id in (select id from category where code=".$code.")");
|
||||
$sum=$row[0]['count'];
|
||||
|
||||
$this->view->category=$this->db->fetchAll('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');
|
||||
if ($code>0 && $code<20) {
|
||||
$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='water') 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
|
||||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function getmd($keyword,$type='place')
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='water') and id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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 ?";
|
||||
$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;
|
||||
}
|
||||
}
|
|
@ -1,405 +0,0 @@
|
|||
<?php
|
||||
class YrnmrController extends DataController
|
||||
{
|
||||
private $limit=20;
|
||||
|
||||
function preDispatch()
|
||||
{
|
||||
parent::preDispatch();
|
||||
//$this->_helper->layout->setLayout('yrnmr');
|
||||
$acName = $this->_request->getActionName();
|
||||
$this->view->pageID = "yrnmr-".$acName;
|
||||
}
|
||||
|
||||
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='yrnmr') and length(t.data)>2 order by random() limit 3";
|
||||
$this->view->meatdata=$this->db->fetchAll($sql);
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('黄河上游宁蒙河段:数据简介','about');
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据浏览
|
||||
*/
|
||||
function browseAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='yrnmr') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$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='yrnmr') ")->order('title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function thumbAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
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='yrnmr') ");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
$select=$this->db->select();
|
||||
$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='yrnmr') ")
|
||||
->order('m.title desc')->limitPage($page,$this->limit);
|
||||
$this->view->metadata = $this->db->fetchAll($select);
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit);
|
||||
}
|
||||
|
||||
function documentAction()
|
||||
{
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='yrnmr') ))");
|
||||
$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='yrnmr') )) order by reference limit ? offset ?";
|
||||
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
|
||||
$this->view->page=new Pagination($sum,$page,$this->limit,"文献");
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
function baseAction()
|
||||
{
|
||||
$this->getmd(array('基础地理','陆地表层','遥感影像','水文地质','社会经济'));
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-基础数据','about');
|
||||
}
|
||||
|
||||
function geobaseAction()
|
||||
{
|
||||
$this->getmd('基础地理');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-基础地理','about');
|
||||
}
|
||||
|
||||
function landsurfaceAction()
|
||||
{
|
||||
$this->getmd('陆地表层');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-陆地表层','about');
|
||||
}
|
||||
|
||||
function rsAction()
|
||||
{
|
||||
$this->getmd('遥感影像');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-遥感影像','about');
|
||||
}
|
||||
|
||||
function waterAction()
|
||||
{
|
||||
$this->getmd('水文地质');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-水文地质','about');
|
||||
}
|
||||
|
||||
function modelAction()
|
||||
{
|
||||
$this->getmd('模型数据');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-模型数据','about');
|
||||
}
|
||||
|
||||
function economicAction()
|
||||
{
|
||||
$this->getmd('社会经济');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-社会经济','about');
|
||||
}
|
||||
|
||||
function coreAction()
|
||||
{
|
||||
$this->getmd(array('DEM','土地利用','土壤','气象','水文观测','实验'));
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-核心数据','about');
|
||||
}
|
||||
|
||||
function demAction()
|
||||
{
|
||||
$this->getmd('DEM');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-DEM','about');
|
||||
}
|
||||
|
||||
function landuseAction()
|
||||
{
|
||||
$this->getmd('土地利用');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-土地利用','about');
|
||||
}
|
||||
|
||||
function soilAction()
|
||||
{
|
||||
$this->getmd('土壤');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-土地利用','about');
|
||||
}
|
||||
|
||||
function meteoAction()
|
||||
{
|
||||
$this->getmd('气象');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-气象','about');
|
||||
}
|
||||
|
||||
function expAction()
|
||||
{
|
||||
$this->getmd('实验');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-实验','about');
|
||||
}
|
||||
|
||||
function obsAction()
|
||||
{
|
||||
$this->getmd('观测');
|
||||
$this->_helper->viewRenderer('base');
|
||||
$archive = new Archive($this->db);
|
||||
$this->view->info = $archive->getOneArchive('YRNMR-观测','about');
|
||||
}
|
||||
|
||||
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='yrnmr') order by timebegin,title";
|
||||
$this->view->metadata=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function tagAction()
|
||||
{
|
||||
$key = $this->_request->getParam('key');
|
||||
$keytype = $this->_request->getParam('keytype');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $page=1;
|
||||
$offset=$this->limit*($page-1);
|
||||
if (!empty($key)) {
|
||||
$this->view->codename=$key;
|
||||
$sql=$this->db->quoteInto("select count(k.id) from keyword k left join normalmetadata m on k.id=m.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='yrnmr') and k.keyword=?",$key);
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$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='yrnmr') 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->page=new Pagination($sum,$page,$this->limit);
|
||||
} else {
|
||||
$sql="select k.keyword,count(*),k.keytype from keyword k left join normalmetadata m on k.id=m.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='yrnmr') ";
|
||||
if (!empty($keytype) && ($keytype=='place' || $keytype=='theme' || $keytype=='discipline'||$keytype=='temporal')) $sql.=" and k.keytype='".$keytype."'";
|
||||
$sql.=' group by k.keyword,k.keytype order by k.keytype,k.keyword,count desc';
|
||||
$state=$this->db->query($sql);
|
||||
$this->view->keytype=$keytype;
|
||||
$this->view->keywords=$state->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
function searchAction()
|
||||
{
|
||||
$this->view->addHelperPath('helper','Zend_View_Helper_');
|
||||
$form=new SearchForm();
|
||||
$this->view->form=$form;
|
||||
//$form->submit->setLabel('快速搜索');
|
||||
$key=$this->_request->getParam('q');
|
||||
if (!empty($key)) {
|
||||
$search=new Search($key);
|
||||
$where=$search->sql_expr(array("title","description"));
|
||||
$page=@(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='yrnmr') and ".$where);
|
||||
$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='yrnmr') and ".$where." 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);
|
||||
$this->view->key=$key;
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
}
|
||||
|
||||
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='yrnmr') and timebegin is not null";
|
||||
$this->view->rows=$this->db->fetchAll($sql);
|
||||
}
|
||||
|
||||
function timelineAction()
|
||||
{
|
||||
$fn="yrnmrtime.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='yrnmr') order by ts_created desc limit 1");
|
||||
$last_update=strtotime($rows[0]['ts_created']);
|
||||
if (!file_exists($fn) || (filemtime($fn)<$last_update))
|
||||
{
|
||||
$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='yrnmr') and timebegin is not null order by timebegin,title");
|
||||
$timexml='<data>';
|
||||
foreach($rows as $row) {
|
||||
$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"';
|
||||
$timexml.= ' title="'.htmlspecialchars($row['title']).'" image="/images/westdc_40w.gif" link="/yrnmr/view/uuid/'.$row['uuid'].'">';
|
||||
$desc_length=mb_strlen($row['description'],"UTF-8");
|
||||
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
|
||||
if ($desc_length>300) $desc.=" ...";
|
||||
$timexml.=htmlspecialchars($desc);
|
||||
$timexml.="</event>\n";
|
||||
}
|
||||
$timexml.='</data>';
|
||||
$fp=fopen($fn,'w');
|
||||
fwrite($fp,$timexml);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
function categoryAction()
|
||||
{
|
||||
$code = (int)$this->_request->getParam('code');
|
||||
$page=(int)$this->_request->getParam('page');
|
||||
if (empty($page)) $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='yrnmr') group by c.code,cc.name,cc.name_zh");
|
||||
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='yrnmr') and id in (select id from category where code=".$code.")");
|
||||
$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='yrnmr') 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
|
||||
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
|
||||
} else {
|
||||
//提供全部分类列表
|
||||
}
|
||||
}
|
||||
|
||||
private function getmd($keyword,$type='theme')
|
||||
{
|
||||
$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 normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='yrnmr' and m.id in (select id from keyword where keytype='".$type."' and keyword in ".$keyword.")");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='yrnmr') and id in (select id from 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->page=new Pagination($sum,$page,$this->limit);
|
||||
$this->view->offset=$offset+1;
|
||||
}
|
||||
|
||||
//获取多项条件并列关系的数据并必须满足limited条件
|
||||
//$keyword:字符串或字符串数组
|
||||
//$limited:限制字符串
|
||||
//$without:明确不包含的字符串数组
|
||||
private function getmdlimited($keyword,$limited,$without='')
|
||||
{
|
||||
$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;
|
||||
|
||||
if (!empty($without))
|
||||
{
|
||||
if (!is_array($without))
|
||||
{
|
||||
$without=array($without);
|
||||
}
|
||||
$withoutkey="(";
|
||||
foreach ($without as $wo)
|
||||
{
|
||||
$withoutkey.="'".$wo."',";
|
||||
}
|
||||
$withoutkey=substr($withoutkey,0,-1);
|
||||
$withoutkey.=")";
|
||||
}
|
||||
|
||||
$sql="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='yrnmr' and m.id in (select id from keyword where keyword='".$limited."')
|
||||
and m.id in (select id from keyword where keyword in ".$keyword.")";
|
||||
if (!empty($without)) $sql.=" and m.id not in (select id from keyword where keyword in $withoutkey)";
|
||||
$state=$this->db->query($sql);
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@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='yrnmr')
|
||||
and id in (select id from keyword where keyword='".$limited."')
|
||||
and id in (select id from keyword where keyword in ".$keyword.")";
|
||||
if (!empty($without)) $sql.=" and id not in (select id from keyword where keyword in $withoutkey)";
|
||||
$sql.=" 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;
|
||||
}
|
||||
|
||||
//获取多项必须满足的条件
|
||||
//$keyword:字符串或字符串数组
|
||||
private function getmdrestricted($keyword)
|
||||
{
|
||||
$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.="m.id in (select id from keyword where keyword='".$k."') and ";
|
||||
}
|
||||
$key=substr($key,0,-4);
|
||||
$key.=")";
|
||||
$keyword=$key;
|
||||
|
||||
$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='yrnmr' and $keyword");
|
||||
$row=$state->fetchAll();
|
||||
$sum=$row[0]['count'];
|
||||
//@todo: add order with title
|
||||
$sql="select uuid,title from normalmetadata m where m.uuid in
|
||||
(select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='yrnmr')
|
||||
and $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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue