diff --git a/application/default/controllers/CommunityController.php b/application/default/controllers/CommunityController.php
deleted file mode 100755
index a0f29d0e..00000000
--- a/application/default/controllers/CommunityController.php
+++ /dev/null
@@ -1,13 +0,0 @@
-_redirect('/metadata');
- }
- function preDispatch()
- {
- $this->view->config = Zend_Registry::get('config');
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/GlacierController.php b/application/default/controllers/GlacierController.php
deleted file mode 100644
index 0d36abc4..00000000
--- a/application/default/controllers/GlacierController.php
+++ /dev/null
@@ -1,392 +0,0 @@
-_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='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $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;
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/HaiheController.php b/application/default/controllers/HaiheController.php
deleted file mode 100644
index 5c54b895..00000000
--- a/application/default/controllers/HaiheController.php
+++ /dev/null
@@ -1,85 +0,0 @@
-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 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;
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/HeiheController.php b/application/default/controllers/HeiheController.php
deleted file mode 100644
index 782b3fa6..00000000
--- a/application/default/controllers/HeiheController.php
+++ /dev/null
@@ -1,1275 +0,0 @@
-debug = 1;
- $this->view->pageID = "heihe-".$this->_request->getActionName();
- $this->view->nav[] = array('link'=>"/heihe",'title'=>'黑河计划数据管理中心');
- $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='heihe') 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='heihe') ");
- $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='heihe') ")->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='heihe') ");
- $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='heihe') ")
- ->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='heihe') ))");
- $sum=$row[0]['count'];
- $sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') )) order by reference limit ? offset ?";
- $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('冰川','沙漠','地貌','植被','草场','沙漠化','基础地理','遥感影像','水文地质','社会经济','人口','SWAT','NPP','WRF','辐射','NEP'));
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-基础数据','about');
- $this->view->nav[] = array('link'=>"/heihe/base",'title'=>'基础数据');
- $this->_helper->viewRenderer('base');
- }
-
- function geobaseAction()
- {
- $this->getmd('基础地理');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-基础地理数据','about');
- $this->view->nav[] = array('link'=>"/heihe/geobase",'title'=>'基础地理数据');
- $this->_helper->viewRenderer('base');
- }
-
- function coreAction()
- {
- $this->getmd(array('DEM','土地利用','土壤','气象','水文观测','灌溉','试验'));
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-核心数据','about');
- $this->view->nav[] = array('link'=>"/heihe/core",'title'=>'核心数据');
- $this->_helper->viewRenderer('base');
- }
-
- function demAction()
- {
- $this->getmd('DEM');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-DEM','about');
- $this->view->nav[] = array('link'=>"/heihe/dem",'title'=>'DEM');
- $this->_helper->viewRenderer('base');
- }
-
- function rsAction()
- {
- $this->getmd('遥感影像');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-遥感影像','about');
- $this->view->nav[] = array('link'=>"/heihe/rs",'title'=>'遥感影像');
- $this->_helper->viewRenderer('base');
- }
-
- function waterAction()
- {
- $this->getmd('水文地质');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-水文水资源数据','about');
- $this->view->nav[] = array('link'=>"/heihe/water",'title'=>'水文水资源数据');
- $this->_helper->viewRenderer('base');
- }
-
- function modelAction()
- {
- $this->getmd(array('WRF','NPP','SWAT','NEP','辐射'));
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-模型数据','about');
- $this->view->nav[] = array('link'=>"/heihe/model",'title'=>'模型数据');
- $this->_helper->viewRenderer('base');
- }
-
- function economicAction()
- {
- $this->getmd(array('人口','社会经济'));
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-社会经济数据','about');
- $this->view->nav[] = array('link'=>"/heihe/economic",'title'=>'社会经济数据');
- $this->_helper->viewRenderer('base');
- }
-
- function landsurfaceAction()
- {
- $this->getmd(array('冰川','沙漠','地貌','植被','草场','沙漠化'));
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-陆地表层数据','about');
- $this->view->nav[] = array('link'=>"/heihe/landsurface",'title'=>'陆地表层数据');
- $this->_helper->viewRenderer('base');
- }
-
- function landuseAction()
- {
- $this->getmd('土地利用');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-土地利用数据','about');
- $this->view->nav[] = array('link'=>"/heihe/landuse",'title'=>'土地利用数据');
- $this->_helper->viewRenderer('base');
- }
-
- function soilAction()
- {
- $this->getmd('土壤');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-土壤数据','about');
- $this->view->nav[] = array('link'=>"/heihe/soil",'title'=>'土壤数据');
- $this->_helper->viewRenderer('base');
- }
-
- function meteoAction()
- {
- $this->getmd('气象');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-气象观测数据','about');
- $this->view->nav[] = array('link'=>"/heihe/meteo",'title'=>'气象观测数据');
- $this->_helper->viewRenderer('base');
- }
-
- function hydroAction()
- {
- $this->getmd('水文观测');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-水文观测数据','about');
- $this->view->nav[] = array('link'=>"/heihe/hydro",'title'=>'水文观测数据');
- $this->_helper->viewRenderer('base');
- }
- function irragationAction()
- {
- $this->getmd('灌溉');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-灌溉数据','about');
- $this->view->nav[] = array('link'=>"/heihe/irragation",'title'=>'灌溉数据');
- $this->_helper->viewRenderer('base');
- }
-
- function obsAction()
- {
- $this->getmd('试验');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('黑河计划-观测试验数据','about');
- $this->view->nav[] = array('link'=>"/heihe/obs",'title'=>'观测试验数据');
- $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='heihe') 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='heihe') 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='heihe') 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='heihe') ";
- 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='heihe') 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='heihe') 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='heihe') and timebegin is not null";
- $this->view->rows=$this->db->fetchAll($sql);
- }
-
- function timelineAction()
- {
- $fn="heihetime.xml";
- $rows=$this->db->fetchAll("select ts_created from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') order by ts_created desc limit 1");
- $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='heihe') and timebegin is not null order by timebegin,title");
- $timexml='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $fp=fopen($fn,'w');
- fwrite($fp,$timexml);
- fclose($fp);
- }
- }
-
- function categoryAction()
- {
- $code = (int)$this->_request->getParam('code');
- $this->view->code = $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='heihe') 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='heihe') 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='heihe') 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='heihe' 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='heihe') 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='heihe' 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='heihe') and id in (select id from keyword where keyword='".$limited."') and id in (select id from keyword where 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;
- }
-
- /*
- * submitAction() //数据汇交
- *
- * param string $ac //动作
- * param int $id //数据模版ID
- * param int $group //geonetwork页面跳转参数
- *
- * return view
- */
- function submitAction(){
-
- $ac = $this->_getParam('ac');
- $id = $this->_request->getParam('id');
- $this->wdb=Zend_Db::factory($this->view->config->geonetwork);
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity())
- {
- $user = $auth->getIdentity();
- $u_id = $user->id;
- $this->view->isadmin=false;
- if ($user->usertype=='administrator') $this->view->isadmin=true;
- }
-
- //新建元数据
- if($ac == "newdata")
- {
-
- $do = $this->_getParam('do');
-
- if(empty($do))
- {
- $this->_helper->viewRenderer('submit-newdata');
-
- $keywords = $this->_request->getParam('q');
- $sql="select id,(regexp_matches(data,'(.*)'))[1] as title,(owner-".$u_id.") as isowner from metadata where istemplate='y' and schemaid='iso19115'";
- if(!empty($keywords))
- {
- $this->view->q = $keywords;
- $search=new Search($keywords);
- $where=$search->sql_expr(array("data"));
- $sql.=' and '.$where;
- }
- $sql.=" order by changedate desc";
- $sth = $this->wdb->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;
-
- return true;
- }
-
- if($do == "add")
- {
- $this->_helper->viewRenderer('submit-newdata-add');
- $this->view->pageNav = "newdata-add";
-
- $keywords = $this->_request->getParam('q');
- $sql = "SELECT md.title,md.uuid,md.description,gn.id as gid FROM normalmetadata md
- left join geonetworkmetadata gn on md.uuid=gn.uuid
- WHERE gn.id is not null";
- if(!empty($keywords))
- {
- $this->view->q = $keywords;
- $search=new Search($keywords);
- $where=$search->sql_expr(array("md.title","md.description"));
- $sql.=' and '.$where;
- }
- $sql.=" order by md.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;
-
- return true;
- }
- return true;
- }//newdata
-
- //未提交数据
- if($ac == "unsubmit" || $ac=="")
- {
- $do = $this->_getParam('do');
-
- //未提交的数据列表
- if(empty($do) || $do=="index")
- {
- $this->_helper->viewRenderer('submit-unsubmit');
-
- $sql = "SELECT (regexp_matches(gn.data,'(.*)'))[1] as title,gn.id,gn.uuid FROM geonetworkmetadata gn
- WHERE gn.uuid not in (select uuid from metadata) and gn.owner=?
- order by gn.id desc
- ";
- $sth = $this->db->prepare($sql);
- $sth->execute(array($u_id));
- $rows = $sth->fetchAll();
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
-
- return true;
- }//index
-
- //提交
- if($do=="commit")
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $data = "";
- $id = $this->_request->getParam('id');
- try{
- if(empty($id) || !is_numeric($id))
- {
- $data = array("error"=>"参数错误");
- $this->jsonexit($data);
- return true;
- }
-
- $changelog = $this->_request->getParam('changelog');
-
- if(empty($changelog))
- {
- $data = array("error"=>'请输入变更信息');
- $this->jsonexit($data);
- return true;
- }
-
- // 1. 权限认定:当前用户必须和其owner相同
- // 数据应当没有评审状态,没有作者信息
- $sql="select gn.id from geonetworkmetadata gn
- left join mdstatus s on gn.uuid=s.uuid
- left join mdauthor a on s.uuid=a.uuid
- where (s.id is not null or a.id is not null) and gn.id=?";
- $sth=$this->db->prepare($sql);
- $sth->execute(array($id));
- $row=$sth->fetch();
- if (!empty($row))
- {
- $data = array("error"=>'错误的入口');
- $this->jsonexit($data);
- return true;
- }
-
- $sql="select uuid,data as xml from metadata where id=? and owner=?";
- $sth=$this->wdb->prepare($sql);
- $sth->execute(array($id,$u_id));
- $row=$sth->fetch();
- if (empty($row))
- {
- $data = array("error"=>'无权限修改数据');
- $this->jsonexit($data);
- return true;
- }else{
- $uuid = $row['uuid'];
- }
-
- //检查元数据错误
- $iso=new ISO19115();
- @$iso->loadXML($row['xml']);
- if ($iso->validate())
- {
- $data=array("error"=>"元数据导入过程中发现错误。 ".implode(" ",$iso->error));
- $this->jsonexit($data);
- return true;
- }
-
- $messages = array();
-
- // 保存数据作者信息
- $sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
- $sth=$this->db->query($sql,array($row['uuid'],$u_id));
-
- // 2. 保存变化记录 save changelog & userid for the latest version
- $sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
- $this->db->query($sql,array($changelog,$u_id,$row['uuid']));
- file_get_contents("http://ftp2.westgis.ac.cn/proftp_upload.php?uuid=".$row['uuid']."&filelist=1");
- //自动添加数据分类为黑河
- $sql="insert into datasource (uuid,sourceid) values(?,1)";
- $sth=$this->db->prepare($sql);
- try{$sth->execute(array($uuid));}catch(Exception $e) {}
-
- // 3. 保存数据评审状态
- //导入元数据
- $iso->saveDB($this->db);
- //进入评审库
- $sql="insert into mdstatus (uuid,status,userid) values(?,?,?)";
- $this->db->query($sql,array($uuid,0,$u_id));
-
- //email to admin
- $mail=new WestdcMailer($this->view->config->smtp);
- $mail->setFrom($this->view->config->service->email,'数据服务组');
- $mailtp=new EmailText($this->db,"metadata-new-admin",array(
- 'user' => $user->username,
- 'uuid' => $iso->uuid,
- 'email'=> $user->email,
- //元数据标题
- 'title'=> $iso->resTitle,
- ));
- $mail->setBodyText($mailtp->getBody());
- $mail->setSubject($mailtp->getSubject());
- $mail->addTo($this->view->config->service->email);
- $mail->send();
-
- unset($mail);
- unset($mailtp);
- //email to author
- $mail=new WestdcMailer($this->view->config->smtp);
- $mail->setFrom($this->view->config->service->email,'数据服务组');
- $mailtp=new EmailText($this->db,"heihe-new-author",array(
- 'user' => $user->username,
- 'uuid' => $iso->uuid,
- 'email'=> $user->email,
- //元数据标题
- 'title'=> $iso->resTitle,
- ));
- $mail->setBodyText($mailtp->getBody());
- $mail->setSubject($mailtp->getSubject());
- $mail->addTo($user->email);
- $mail->addCc($this->view->config->service->email);
- @$mail->send();
-
- $data = array("commited"=>1,"error"=>'该版本已经成功提交,请等待数据中心进一步处理!');
- $this->jsonexit($data);
- return true;
- }catch(Exception $e) {
- $sql="delete from mdstatus where uuid in (select uuid from geonetworkmetadata where id=?)";
- $this->db->query($sql,array($id));
- $sql="delete from mdauthor where userid=? and uuid in (select uuid from geonetworkmetadata where id=?)";
- $this->db->query($sql,array($u_id,$id));
-
- $msg = "提交失败,请确认权限后重试";
- if($this->debug>0)
- {$msg .= $e->getMessage();}
- $data = array("error"=>$msg);
- $this->jsonexit($data);
- return true;
- }
- }//commit
-
- return true;
- }//unsubmit
-
- //FTP
- else if($ac == "ftp")
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $uuid = $this->_getParam('uuid');
-
- $this->view->uuid = $uuid;
-
- if(empty($uuid) || !preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
- {
- $data = array(
- 'error'=>"参数错误"
- );
- $this->jsonexit($data);
- return true;
- }
- //安全检查: uuid必须是当前用户且为新建数据
- $sql="select * from geonetworkmetadata where uuid=? and uuid not in (select uuid from metadata) and owner=?";
- $sth=$this->db->prepare($sql);
- $sth->execute(array($uuid,$u_id));
- $row=$sth->fetch();
- if (empty($row))
- {
- $data = array(
- 'error'=>"参数错误"
- );
- $this->jsonexit($data);
- return true;
- }
-
- //ftp 用户名
- $uname = 'westdc'.$u_id.'upload';
-
- //ftp路径
- $homedir = "/disk1/WestDC/upload/".$uuid."/";
- //ftp用户表
- $ftptable=' pureftp ';//ftp2.westgis.ac.cn
-
- //$sql = "SELECT * FROM proftpusers WHERE userid='$uname' ORDER BY pkid DESC";
- $sql = "SELECT * FROM $ftptable WHERE userid='$uname' ORDER BY pkid DESC";
- $sth = $this->db->prepare($sql);
- $sth->execute();
- $row = $sth->fetch();
-
- //create directory for upload
- //server is not localhost, so we need a trick
- //$old=umask(0);
- //@mkdir($homedir,0777);
- //umask($old);
- $page=file_get_contents('http://ftp2.westgis.ac.cn/proftp_upload.php?uuid='.$uuid);
- if (!empty($page)) die($page);//there are errors in visit ftp page
-
-
- if(!empty($row['pkid']))
- {
- if(preg_match("/.*".$uuid.".*/",$row['homedir']))
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$row['userid'],
- 'passwd'=>$row['passwd']
- );
-
- $this->jsonexit($data);
- return true;
-
- }else{
- $uid = 1002;
- $gid = 1002;
-
- $passwd = $this->genRandomString(16);
- //$sql = "UPDATE proftpusers SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?";
- //$sth = $this->db->prepare($sql);
- //$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname));
- //$sql="update proftpusers SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'";
- $sql="update ".$ftptable." SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'";
- $rs=$this->db->query($sql);
- if($rs)
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$uname,
- 'passwd'=>$passwd
- );
- $this->jsonexit($data);
- return true;
- }else{
- $data = array(
- 'error'=>"FTP信息更新失败,请重试"
- );
- $this->jsonexit($data);
- return true;
- }
- }
- }
-
- else{
- $uid = 1002;
- $gid = 1002;
- $passwd = $this->genRandomString(16);
-
- //$sql = "INSERT INTO proftpusers (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)";
- //$sth = $this->db->prepare($sql);
- //$rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir));
- //$sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',109,1002,'".$homedir."')";
- $sql="insert into ".$ftptable." (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',1002,1002,'".$homedir."')";
- $rs=$this->db->query($sql);
- if($rs)
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$uname,
- 'passwd'=>$passwd
- );
- $this->jsonexit($data);
- return true;
- }else{
- $data = array(
- 'error'=>"FTP信息更新失败,请重试"
- );
- $this->jsonexit($data);
- return true;
- }
- }//end if
-
- }//ftp
-
- }//function submitAction()
-
- /*
- * projectsAction() 数据汇交计划
- *
- *
- *
- *
- */
- function projectsAction()
- {
-
- $ac = $this->_getParam('ac');
- $invite = $this->_getParam('invite');
-
- $heihe = new Heihe($this->db);
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity())
- {
- $user = $auth->getIdentity();
- $uid = $user->id;
- $this->view->user_email = $user_email = $user->email;
- }
-
- $this->view->page = $this->_getParam('page');
- $this->view->pageLimit = 15;
- include_once("helper/view.php");
-
- if(empty($ac) || $ac == "index" || $ac == 'my')
- {
- $this->_helper->viewRenderer('project-index');
- $this->view->tabID='projects-index';
-
- //Search Link
- $this->view->searchLink = "/heihe/projects/ac/index/";
-
- $q = $this->_getParam('q');
-
- $wheresql = array();
-
- if(!empty($q))
- {
- if(!preg_match("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$q))
- {
- $this->view->error = "输入的搜索条件有误,只允许输入汉字、数字、字母";
- return true;
- }
- $wheresql[] = " (p.title LIKE '%$q%' OR
- p.code LIKE '%$q%' OR
- p.name LIKE '%$q%')";
- $this->view->searchKeyword = $q;
- }
-
- if($ac == "my")
- {
- //防止通过其它方式访问,先判断是否是登录用户,如果不是,抛出消息后强制用户退出
- $auth = Zend_Auth::getInstance();
- if(!$auth->hasIdentity())
- $this->_redirect('/account/login?href=/heihe/projects/ac/my');
- $wheresql[] = " p.email='$user_email' ";
- $this->view->tabID='projects-my';
- }
-
- if(count($wheresql)>0)
- {
- $wheresql = join(" AND ",$wheresql);
- }else{
- $wheresql = "";
- }
-
- if(!empty($wheresql))
- {
- $wheresql = " WHERE ".$wheresql;
- }
-
- $sql = "SELECT p.*,f.id as fid FROM heiheproject p left join fund f on p.code=f.fund_id $wheresql
- ORDER BY p.id asc";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- view::addPaginator($rows,$this->view,$this->_request);
-
- }//ac == index
-
- if($ac == "submitting")
- {
- $this->_helper->viewRenderer('project-index');
- $this->view->tabID='projects-submitting';
- $sql = "SELECT p.*,f.id as fid FROM heiheproject p left join fund f on p.code=f.fund_id WHERE p.status=1";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- view::addPaginator($rows,$this->view,$this->_request);
- }//ac == submitting 正在提交
-
- if($ac == "unsubmit")
- {
- $this->_helper->viewRenderer('project-index');
- $this->view->tabID='projects-unsubmit';
- $sql = "SELECT p.*,f.id as fid FROM heiheproject p left join fund f on p.code=f.fund_id WHERE p.status=0";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- view::addPaginator($rows,$this->view,$this->_request);
- }//ac == unsubmit 未提交
-
- if($ac == "submit")
- {
- $this->_helper->viewRenderer('project-index');
- $this->view->tabID='projects-submit';
- $sql = "SELECT p.*,f.id as fid FROM heiheproject p left join fund f on p.code=f.fund_id WHERE p.status>0";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- view::addPaginator($rows,$this->view,$this->_request);
- }//ac == submit 已提交
-
- if($ac == "upload")
- {
- $this->_helper->layout->setLayout('layout-iframe');
- $this->_helper->viewRenderer('project-upload');
-
- $submit = $this->_getParam('submit');
-
- $pid = $this->_getParam('pid');
-
- if(empty($pid) || !is_numeric($pid))
- {
- $this->view->error = "参数错误";
- return true;
- }
-
- $this->view->pid = $pid;
-
- if(empty($uid))
- {
- $this->view->error = "请先登录";
- return true;
- }
-
- $sql = "SELECT * FROM heiheproject WHERE id=$pid";
- $sth = $this->db->query($sql);
- $row = $sth->fetch();
-
- if($row['email']!= $user_email)
- {
- $this->view->error = "您没有权限进行此操作";
- return true;
- }
-
- if(!empty($submit) && empty($this->view->error))
- {
-
- $files=new files();
- $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'heihe');
-
- if(empty($msg['error']))
- {
- $msg['error']="";
- $filename = $msg['db_path'];
- $filesize = $msg['file_size'];
- $filedesc = $this->_request->getParam('filedesc');
- $filetype = $msg['file_type'];
- $realname = $msg['realname'];
-
- if(!empty($row['attachid']))
- {
- $sql = "SELECT * FROM attachments WHERE id={$row['attachid']}";
- $sth = $this->db->query($sql);
- $attach = $sth->fetch();
- $this->db->exec("DELETE FROM attachments WHERE id={$row['attachid']} AND filetype='heihe'");
- @unlink($this->view->config->upload.$attach['filename']);
- }
-
- $sql = " INSERT INTO attachments (filename,filetype,filedesc,userid,filesize,realname) values
- ('$filename','heihe','$filedesc','$uid','$filesize','$realname') RETURNING id";
- $sth = $this->db->prepare($sql);
- $sth->execute();
- $att = $sth->fetch(PDO::FETCH_ASSOC);
- $msg['attid'] = $attid = $att['id'];
-
- $sql = "UPDATE heiheproject SET attachid=$attid WHERE id=$pid";
- $sth = $this->db->exec($sql);
-
- if($sth)
- {
- $this->view->message = "上传成功";
- }else{
- @unlink($filename);
- $this->view->error = '附件上传失败:写入附件表出错';
- return true;
- }
- }else{
- @unlink($filename);
- $this->view->error = "附件上传失败".$msg['error'];
- return true;
- }
- }
-
- $sql = "SELECT * FROM heiheproject WHERE id=$pid";
- $sth = $this->db->query($sql);
- $row = $sth->fetch();
-
- $sql = "SELECT * FROM attachments WHERE id = {$row['attachid']}";
- $sth = $this->db->query($sql);
- $this->view->att = $sth->fetch();
-
- return true;
- }
-
- if(!empty($invite))
- {
-
- $this->_helper->viewRenderer('project-invite');
-
- $pid = $this->_getParam('pid');
-
- $level = $heihe->expertActive($pid,$invite,$user_email);
-
- if($level>100)
- {
- $this->view->error = "数据中心对您的邀请已经确认!感谢您的支持";
- return true;
- }else{
- $this->view->error = $heihe->expertActiveError($level);
- return true;
- }
-
- }//专家邀请链接
-
-
- }//projectsAction()
-
- function genRandomString($len)
- {
- $chars = array(
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
- "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
- "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
- "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
- "3", "4", "5", "6", "7", "8", "9"
- );
- $charsLen = count($chars) - 1;
-
- shuffle($chars); // 将数组打乱
-
- $output = "";
- for ($i=0; $i<$len; $i++)
- {
- $output .= $chars[mt_rand(0, $charsLen)];
- }
- return $output;
- }
-
- function chmodr($path, $filemode) {
- if (!is_dir($path))
- return chmod($path, $filemode);
-
- $dh = opendir($path);
- while (($file = readdir($dh)) !== false) {
- if($file != '.' && $file != '..') {
- $fullpath = $path.'/'.$file;
- if(is_link($fullpath))
- return FALSE;
- elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
- return FALSE;
- elseif(!$this->chmodr($fullpath, $filemode))
- return FALSE;
- }
- }
- closedir($dh);
- if(chmod($path, $filemode))
- return TRUE;
- else
- return FALSE;
- }
-
- //成为作者后的后继处理工作
- private function author_first($uuid,$author)
- {
- $sql="insert into mdversion (xml,ts_created,uuid,changelog,userid)
- select x.data,m.ts_created,?,?,? from metadata m left join xml x on m.id=x.id
- left join mdversion v on m.uuid=v.uuid
- where m.uuid=? and v.changelog is null";
- $sth=$this->db->prepare($sql);
- try
- {
- $sth->execute(array($uuid,'初始版本 version 1.0',$author,$uuid));
- } catch(Exception $e){
- // do nothing here.
- // 说明之前已经有对应数据
- }
- $this->wdb=Zend_Db::factory($this->view->config->geonetwork);
- $sql="update metadata set owner=? where uuid=?";
- $sth=$this->wdb->prepare($sql);
- $sth->execute(array($author,$uuid));
- }
- //基于数据作者的浏览(包括认证后的数据作者以及未认证的数据作者)
- 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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 left join heiheproject hp on f.fund_id=hp.code
- where hp.id is not null and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe')
- group by f.id,f.title,f.fund_id,f.fund_type,f.ts_created order by f.fund_id asc";
- $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 orgAction()
- {
- $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='heihe') 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='heihe') 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 {
- //提供全部分类列表
- }
- }
-
- //实现基于DOI信息的浏览
- function doiAction()
- {
- $ac = $this->_request->getParam('ac');
- if ($ac=='unready') {
- //列出没有DOI的数据
- $sql="select m.* from normalmetadata m where length(m.doi)<3 and m.uuid not in (select uuid from datadoi) and m.uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe') order by m.ts_created desc";
- $this->view->tabID='doi-unready';
- } else if ($ac=='prepare') {
- //列出有DOI但还未进行提交申请的数据
- $sql="select m.* from normalmetadata m where length(m.doi)>3 and m.uuid not in (select uuid from datadoi) and m.uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe') order by m.ts_created desc";
- $this->view->tabID='doi-prepare';
- } else if ($ac=='unsubmit') {
- //列出有DOI并计划提交申请的数据
- $sql="select m.*,d.doi as datadoi,date(d.ts_created) as ts_created from normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_created is not null and d.ts_submitted is null and m.uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe') order by d.ts_created desc";
- $this->view->tabID='doi-unsubmit';
- } else if ($ac=='submit') {
- //列出有DOI并计划提交申请的数据
- $sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted from normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_submitted is not null and d.ts_published is null and m.uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe') order by d.ts_submitted desc,d.ts_created desc";
- $this->view->tabID='doi-submit';
- } else if ($ac=='publish' || empty($ac)) {
- //默认:列出最新发布的DOI数据
- $sql="select m.*,d.doi as datadoi,date(d.ts_submitted) as ts_submitted,date(d.ts_published) as ts_published from normalmetadata m left join datadoi d on m.uuid=d.uuid where length(m.doi)>3 and d.ts_published is not null and m.uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe') order by d.ts_published desc,d.ts_submitted desc,d.ts_created desc";
- $this->view->tabID='doi-publish';
- }
- $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;
- }
-
- function onlinelistAction()
- {
- $page=(int)$this->_request->getParam('page');
- if (empty($page)) $page=1;
- $limit=30;
- $offset=$limit*($page-1);
- $state=$this->db->query("select count(*) from heihemetadata where datatype=0 and uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')");
- $row=$state->fetchAll();
- $sum=$row[0]['count'];
- $select=$this->db->select();
- $select->from('heihemetadata','*')->where('datatype=0')->where("uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')")->order('title')->limitPage($page,$limit);
- $this->view->metadata = $this->db->fetchAll($select);
- $this->view->page=new Pagination($sum,$page,$limit);
- }
-
- function offlinelistAction()
- {
- $page=(int)$this->_request->getParam('page');
- if (empty($page)) $page=1;
- $limit=30;
- $offset=$limit*($page-1);
- $state=$this->db->query("select count(*) from heihemetadata where datatype=1 and uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')");
- $row=$state->fetchAll();
- $sum=$row[0]['count'];
- $select=$this->db->select();
- $select->from('heihemetadata','*')->where('datatype=1')->where("uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')")->order('title')->limitPage($page,$limit);
- $this->view->metadata = $this->db->fetchAll($select);
- $this->view->page=new Pagination($sum,$page,$limit);
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/HiwaterController.php b/application/default/controllers/HiwaterController.php
deleted file mode 100644
index eaeb061c..00000000
--- a/application/default/controllers/HiwaterController.php
+++ /dev/null
@@ -1,685 +0,0 @@
-_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",'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')))
- {
- $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('激光雷达','航空遥感');
- $this->_helper->viewRenderer('base');
- }
- function ccdlidarAction()
- {
- $this->getmdlimited('CCD','航空遥感',"激光雷达");
- $this->_helper->viewRenderer('base');
- }
- function widasAction()
- {
- $this->getmdlimited('WIDAS','航空遥感');
- $this->_helper->viewRenderer('base');
- }
- function ccdwidasAction()
- {
- $this->getmdlimited('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->getmd(array('航空遥感产品','种植结构图','植被类型图','植被结构参数','数字高程模型','数字表面模型','地表温度','地表土壤水文'));
- $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->getmdlimited(array('西支','黄藏寺','黄草沟','峨堡','景阳岭','阿柔阳坡','阿柔阴坡','戈壁站','神沙窝沙漠站','花寨子荒漠站','张掖湿地站','阿柔超级站','大满超级站','四道桥超级站'),'水文气象');
- $md=$this->view->metadata;
- $this->getmd(array('','河川径流观测'));
- $this->view->metadata=array_merge($md,$this->view->metadata);
- $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->getmd(array('','自动气象站'));
- $this->_helper->viewRenderer('base');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
- }
- function ecAction()
- {
- $this->getmd(array('','涡动相关仪'));
- $this->_helper->viewRenderer('base');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
- }
- function lasAction()
- {
- $this->getmd(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->getmd(array('自动气象站','涡动相关仪','大孔径闪烁仪','稳定同位素观测系统','热扩散液流计(TDP)','宇宙射线土壤水分'));
- $this->_helper->viewRenderer('base');
- $archive = new Archive($this->db);
- $this->view->info = $archive->getOneArchive('HiWATER-通量观测矩阵','about');
- }
-
- function isotopeAction()
- {
- $this->getmd(array('','稳定同位素观测系统'));
- $this->_helper->viewRenderer('base');
- }
-
- function tdpAction()
- {
- $this->getmd(array('','热扩散液流计(TDP)'));
- $this->_helper->viewRenderer('base');
- }
-
- function cosmosAction()
- {
- $this->getmd(array('','宇宙射线土壤水分'));
- $this->_helper->viewRenderer('base');
- }
-
- function rsproductAction()
- {
- $this->getmdlimited(array('DEM','DOM','降水','土壤水分','积雪','植被类型','植被覆盖度','物候期','NPP'),'数据产品');
- $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 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='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $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:限制字符串
- 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='hiwater' 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='hiwater') 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;
- }
-
- //基于数据作者的浏览(包括认证后的数据作者以及未认证的数据作者)
- 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 {
- //提供全部分类列表
- }
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/MetainfoController.php b/application/default/controllers/MetainfoController.php
deleted file mode 100644
index c895d039..00000000
--- a/application/default/controllers/MetainfoController.php
+++ /dev/null
@@ -1,118 +0,0 @@
-_request->getParam('title');
- $filePath="http://wiki.westgis.ac.cn/api.php?format=php&action=query&prop=revisions&titles=$title&rvprop=content&redirects";
- $wikifp=fopen($filePath,'r');
- while (!feof($wikifp)) {
- $wikiLines=fgets($wikifp);
- $yuchuli=array('";}}}}}}','**','*');
- $chulihou=array('',' ·','·');
- $wikiLine=str_replace($yuchuli,$chulihou,$wikiLines);
- if(substr($wikiLine,0,2)=='a:') {
- if(strpos($wikiLine,'==')!== false){
- $wikititle=mb_strstr($wikiLine,'==',false);
- $this->wikitransform($wikititle,$content);
- }
- }else {
- $this->wikitransform($wikiLine,$content);
- }
- }
- /*$wikicontent=unserialize(file_get_contents($filePath));
- $wiki_keys=array_keys($wikicontent['query']['pages']);
- $content= $wikicontent['query']['pages'][$wiki_keys[0]];
- $this->view->title=$content['title'];
- $c1=explode('\n',$content['revisions'][0]['*']);
- foreach ($c1 as $c2) $this->wikitransform($c2,$tcontent);*/
- $this->view->content=$content;
- $this->view->config = Zend_Registry::get('config');
- }
-
- //transform mediawiki text to local text
- function wikitransform($text,&$result) {
- if(strpos($text,'=====')!== false&&substr($text,0,1)=='=') {
- $wikiFont=str_replace('=====','',$text);
- $result.="
";
- }
-}
-}
\ No newline at end of file
diff --git a/application/default/controllers/NetkitesController.php b/application/default/controllers/NetkitesController.php
deleted file mode 100755
index ece70e0e..00000000
--- a/application/default/controllers/NetkitesController.php
+++ /dev/null
@@ -1,27 +0,0 @@
-view->config = Zend_Registry::get('config');
- }
- function faqAction()
- {
- }
- function useAction()
- {
- }
- function resourceAction()
- {
- }
- function applyAction()
- {
- }
- function driverAction()
- {
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/QzrController.php b/application/default/controllers/QzrController.php
deleted file mode 100644
index 9e250be3..00000000
--- a/application/default/controllers/QzrController.php
+++ /dev/null
@@ -1,1100 +0,0 @@
-_helper->layout->setLayout('heihe');
- $this->debug = 1;
- }
-
- function indexAction()
- {
- $sql="select m.uuid,m.title,m.id,m.description from normalmetadata m left join thumbnail t on m.id=t.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and length(t.data)>2 order by random() limit 3";
- $this->view->meatdata=$this->db->fetchAll($sql);
- }
-
- function newsAction()
- {
- $this->view->theme = new Theme();
-
- $title=$this->_request->getParam('title');
-
- if($title == "national_geog")
- {
-
- }
-
- return true;
- $archive=new Archive($this->db);
- $this->view->infos = $archive->getOneArchive($title);
- }
-
- /*
- * 数据浏览
- */
- 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='heihe') ");
- $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='heihe') ")->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='heihe') ");
- $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='heihe') ")
- ->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='heihe') ))");
- $sum=$row[0]['count'];
- $sql="select * from reference where id in (select refid from mdref where uuid in (select uuid from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') )) order by reference limit ? offset ?";
- $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()
- {
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP'))");
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP')) order by timebegin,title limit ? offset ?";
- $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 geobaseAction()
- {
- $this->getmd('基础地理');
- }
-
- function coreAction()
- {
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验'))");
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验')) order by timebegin,title limit ? offset ?";
- $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 demAction()
- {
- $this->getmd('DEM');
- }
-
- function rsAction()
- {
- $this->getmd('遥感影像');
- }
-
- function waterAction()
- {
- $this->getmd('水文地质');
- }
-
- function modelAction()
- {
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射'))");
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function economicAction()
- {
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='人口' or 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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function landsurfaceAction()
- {
- $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='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化'))");
- $row=$state->fetchAll();
- $sum=$row[0]['count'];
- $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化')) order by timebegin,title limit ? offset ?";
- $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 landuseAction()
- {
- $this->getmd('土地利用','theme');
- }
-
- function soilAction()
- {
- $this->getmd('土壤','theme');
- }
-
- function meteoAction()
- {
- $this->getmd('气象','theme');
- }
-
- function hydroAction()
- {
- $this->getmd('水文观测','theme');
- }
- function irragationAction()
- {
- $this->getmd('灌溉','theme');
- }
-
- function obsAction()
- {
- $this->getmd('试验','theme');
- }
-
- function listAction()
- {
- $sql="select uuid,title from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') order by timebegin,title";
- $this->view->metadata=$this->db->fetchAll($sql);
- }
-
- 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') 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='heihe') and timebegin is not null";
- $this->view->rows=$this->db->fetchAll($sql);
- }
-
- function timelineAction()
- {
- $fn="heihetime.xml";
- $rows=$this->db->fetchAll("select ts_created from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='heihe') order by ts_created desc limit 1");
- $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='heihe') and timebegin is not null order by timebegin,title");
- $timexml='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $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='heihe') 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='heihe') 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='heihe') 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);
- $state=$this->db->query("select count(m.*) from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='heihe' and m.id in (select id from keyword where keytype='".$type."' and keyword='".$keyword."')");
- $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='heihe') 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;
- }
-
- /*
- * submitAction() //数据汇交
- *
- * param string $ac //动作
- * param int $id //数据模版ID
- * param int $group //geonetwork页面跳转参数
- *
- * return view
- */
- function submitAction(){
-
- $ac = $this->_getParam('ac');
- $id = $this->_request->getParam('id');
- $this->wdb=Zend_Db::factory($this->view->config->geonetwork);
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity())
- {
- $user = $auth->getIdentity();
- $u_id = $user->id;
- $this->view->isadmin=false;
- if ($user->usertype=='administrator') $this->view->isadmin=true;
- }
-
- if(empty($ac) || $ac == "index")
- {
- $this->_helper->viewRenderer('submit-index');
- return true;
- }
-
- //新建元数据
- if($ac == "newdata")
- {
-
- $do = $this->_getParam('do');
-
- if(empty($do))
- {
- $this->_helper->viewRenderer('submit-newdata');
-
- $keywords = $this->_request->getParam('q');
- $sql="select id,(regexp_matches(data,'(.*)'))[1] as title,(owner-".$u_id.") as isowner from metadata where istemplate='y' and schemaid='iso19115'";
- if(!empty($keywords))
- {
- $this->view->q = $keywords;
- $search=new Search($keywords);
- $where=$search->sql_expr(array("data"));
- $sql.=' and '.$where;
- }
- $sql.=" order by changedate desc";
- $sth = $this->wdb->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;
-
- return true;
- }
-
- if($do == "add")
- {
- $this->_helper->viewRenderer('submit-newdata-add');
- $this->view->pageNav = "newdata-add";
-
- $keywords = $this->_request->getParam('q');
- $sql = "SELECT md.title,md.uuid,md.description,gn.id as gid FROM normalmetadata md
- left join geonetworkmetadata gn on md.uuid=gn.uuid
- WHERE gn.id is not null";
- if(!empty($keywords))
- {
- $this->view->q = $keywords;
- $search=new Search($keywords);
- $where=$search->sql_expr(array("md.title","md.description"));
- $sql.=' and '.$where;
- }
- $sql.=" order by md.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;
-
- return true;
- }
- return true;
- }//newdata
-
- //未提交数据
- if($ac == "unsubmit")
- {
- $do = $this->_getParam('do');
-
- //未提交的数据列表
- if(empty($do) || $do=="index")
- {
- $this->_helper->viewRenderer('submit-unsubmit');
-
- $sql = "SELECT (regexp_matches(gn.data,'(.*)'))[1] as title,gn.id,gn.uuid FROM geonetworkmetadata gn
- WHERE gn.uuid not in (select uuid from metadata) and gn.owner=?
- order by gn.id desc
- ";
- $sth = $this->db->prepare($sql);
- $sth->execute(array($u_id));
- $rows = $sth->fetchAll();
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
-
- return true;
- }//index
-
- //提交
- if($do=="commit")
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $data = "";
- $id = $this->_request->getParam('id');
- try{
- if(empty($id) || !is_numeric($id))
- {
- $data = array("error"=>"参数错误");
- $this->jsonexit($data);
- return true;
- }
-
- $changelog = $this->_request->getParam('changelog');
-
- if(empty($changelog))
- {
- $data = array("error"=>'请输入变更信息');
- $this->jsonexit($data);
- return true;
- }
-
- // 1. 权限认定:当前用户必须和其owner相同
- // 数据应当没有评审状态,没有作者信息
- $sql="select gn.id from geonetworkmetadata gn
- left join mdstatus s on gn.uuid=s.uuid
- left join mdauthor a on s.uuid=a.uuid
- where (s.id is not null or a.id is not null) and gn.id=?";
- $sth=$this->db->prepare($sql);
- $sth->execute(array($id));
- $row=$sth->fetch();
- if (!empty($row))
- {
- $data = array("error"=>'错误的入口');
- $this->jsonexit($data);
- return true;
- }
-
- $sql="select uuid,data as xml from metadata where id=? and owner=?";
- $sth=$this->wdb->prepare($sql);
- $sth->execute(array($id,$u_id));
- $row=$sth->fetch();
- if (empty($row))
- {
- $data = array("error"=>'无权限修改数据');
- $this->jsonexit($data);
- return true;
- }else{
- $uuid = $row['uuid'];
- }
-
- //检查元数据错误
- $iso=new ISO19115();
- @$iso->loadXML($row['xml']);
- if ($iso->validate())
- {
- $data=array("error"=>"元数据导入过程中发现错误。 ".implode(" ",$iso->error));
- $this->jsonexit($data);
- return true;
- }
-
- $messages = array();
-
- // 保存数据作者信息
- $sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
- $sth=$this->db->query($sql,array($row['uuid'],$u_id));
-
- // 2. 保存变化记录 save changelog & userid for the latest version
- $sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
- $this->db->query($sql,array($changelog,$u_id,$row['uuid']));
-
- // 处理文件权限和数据信息
- $ftp_user = "heihe".$u_id."upload";
- $sql = "SELECT * FROM pureftp WHERE userid=? AND homedir LIKE ?";
- $sth = $this->db->prepare($sql);
- $sth->execute(array($ftp_user,'%'.$uuid.'%'));
- $row1 = $sth->fetch(PDO::FETCH_ASSOC);
-
- if(!empty($row1['passwd']))
- {
- $old=umask(0);
- //$this->chmodr($row1['homedir'],1444);
- umask($old);
- }
-
- //$path = $row1['homedir'];
- $path = '/var/www/westdc.westgis.ac.cn/data/heihe_upload/'.$uuid.'/';
-
- //delete dataset & datafile records
- $sql="delete from dataset where uuid=?";
- $sth = $this->db->prepare($sql);
- $sth->execute(array($uuid));
- //自动添加数据分类为黑河
- $sql="insert into datasource (uuid,sourceid) values(?,1)";
- $sth=$this->db->prepare($sql);
- try{$sth->execute(array($uuid));}catch(Exception $e) {}
-
- $sql = "INSERT INTO dataset (uuid,path) VALUES (?,?) RETURNING id";
- $sth = $this->db->prepare($sql);
- $rs = $sth->execute(array($uuid,$path));
-
- if(!$rs)
- {
- $messages[] = "元数据信息写入失败";
- /*
- $data = array("error"=>'元数据信息写入失败');
- $this->jsonexit($data);
- return true;
- */
- }
-
- $temp = $sth->fetch(PDO::FETCH_ASSOC);
-
- $dsid = $temp['id'];
-
- $dir = new mydir();
- $files=$dir->recursive($path);
-
- foreach ($files as $k=>$v)
- {
- //$pathinfo = pathinfo($path.$v);
- $filename = mb_substr($v,mb_strlen($path)+1);
- $filesize = filesize($v);
- $isdir=is_dir($v)?1:0;
- $depth=substr_count($filename,"/")+1;
- if (substr($filename,-1,1)=='/') $depth--;
- //$this->chmodr($path.$v,0444);
- $sql = "INSERT INTO datafile (dsid,filename,filesize,isdir,depth) VALUES (?,?,?,?,?)";
- $sth = $this->db->prepare($sql);
- $rs = $sth->execute(array($dsid,$filename,$filesize,$isdir,$depth));
- if(!$rs)
- {
- $messages[] = "数据文件".$filename.'写入失败';
- }
- }
-
-
- // 3. 保存数据评审状态
- //导入元数据
- $iso->saveDB($this->db);
- //进入评审库
- $sql="insert into mdstatus (uuid,status,userid) values(?,?,?)";
- $this->db->query($sql,array($uuid,0,$u_id));
-
- //email to admin
- $mail=new WestdcMailer($this->view->config->smtp);
- $mail->setFrom($this->view->config->service->email,'数据服务组');
- $mailtp=new EmailText($this->db,"metadata-new-admin",array(
- 'user' => $user->username,
- 'uuid' => $iso->uuid,
- 'email'=> $user->email,
- //元数据标题
- 'title'=> $iso->resTitle,
- ));
- $mail->setBodyText($mailtp->getBody());
- $mail->setSubject($mailtp->getSubject());
- $mail->addTo($this->view->config->service->email);
- $mail->send();
-
- unset($mail);
- unset($mailtp);
- //email to author
- $mail=new WestdcMailer($this->view->config->smtp);
- $mail->setFrom($this->view->config->service->email,'数据服务组');
- $mailtp=new EmailText($this->db,"heihe-new-author",array(
- 'user' => $user->username,
- 'uuid' => $iso->uuid,
- 'email'=> $user->email,
- //元数据标题
- 'title'=> $iso->resTitle,
- ));
- $mail->setBodyText($mailtp->getBody());
- $mail->setSubject($mailtp->getSubject());
- $mail->addTo($user->email);
- $mail->addCc($this->view->config->service->email);
- @$mail->send();
-
- $data = array("commited"=>1,"error"=>'该版本已经成功提交,请等待数据中心进一步处理!');
- $this->jsonexit($data);
- return true;
- }catch(Exception $e) {
- $sql="delete from mdstatus where uuid in (select uuid from geonetworkmetadata where id=?)";
- $this->db->query($sql,array($id));
- $sql="delete from mdauthor where userid=? and uuid in (select uuid from geonetworkmetadata where id=?)";
- $this->db->query($sql,array($u_id,$id));
-
- $msg = "提交失败,请确认权限后重试";
- if($this->debug>0)
- {$msg .= $e->getMessage();}
- $data = array("error"=>$msg);
- $this->jsonexit($data);
- return true;
- }
- }//commit
-
- return true;
- }//unsubmit
-
- //FTP
- if($ac == "ftp")
- {
- $this->_helper->layout->disableLayout();
- $this->_helper->viewRenderer->setNoRender();
-
- $uuid = $this->_getParam('uuid');
-
- $this->view->uuid = $uuid;
-
- if(empty($uuid) || !preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
- {
- $data = array(
- 'error'=>"参数错误"
- );
- $this->jsonexit($data);
- return true;
- }
- //安全检查: uuid必须是当前用户且为新建数据
- $sql="select * from geonetworkmetadata where uuid=? and uuid not in (select uuid from metadata) and owner=?";
- $sth=$this->db->prepare($sql);
- $sth->execute(array($uuid,$u_id));
- $row=$sth->fetch();
- if (empty($row))
- {
- $data = array(
- 'error'=>"参数错误"
- );
- $this->jsonexit($data);
- return true;
- }
-
- //ftp 用户名
- $uname = 'heihe'.$u_id.'upload';
-
- //ftp路径
- $homedir = "/var/www/westdc.westgis.ac.cn/data/heihe_upload/".$uuid."/";
-
- $sql = "SELECT * FROM pureftp WHERE userid='$uname' ORDER BY pkid DESC";
- $sth = $this->db->prepare($sql);
- $sth->execute();
- $row = $sth->fetch();
-
- $old=umask(0);
- @mkdir($homedir,0777);
- umask($old);
-
- if(!empty($row['pkid']))
- {
- if(preg_match("/.*".$uuid.".*/",$row['homedir']))
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$row['userid'],
- 'passwd'=>$row['passwd']
- );
-
- $this->jsonexit($data);
- return true;
-
- }else{
- $uid = 1001;
- $gid = 1001;
-
- $passwd = $this->genRandomString(16);
- $sql = "UPDATE pureftp SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?";
- $sth = $this->db->prepare($sql);
- $rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname));
- if($rs)
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$uname,
- 'passwd'=>$passwd
- );
- $this->jsonexit($data);
- return true;
- }else{
- $data = array(
- 'error'=>"FTP信息更新失败,请重试"
- );
- $this->jsonexit($data);
- return true;
- }
- }
- }
-
- else{
- $uid = 1001;
- $gid = 1001;
- $passwd = $this->genRandomString(16);
-
- $sql = "INSERT INTO pureftp (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)";
- $sth = $this->db->prepare($sql);
- $rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir));
- if($rs)
- {
- $data = array(
- 'statu'=>1,
- 'user'=>$uname,
- 'passwd'=>$passwd
- );
- $this->jsonexit($data);
- return true;
- }else{
- $data = array(
- 'error'=>"FTP信息更新失败,请重试"
- );
- $this->jsonexit($data);
- return true;
- }
- }//end if
-
- }//ftp
-
- }//function submitAction()
-
- /*
- * projectsAction() 数据汇交计划
- *
- *
- *
- *
- */
- function projectsAction()
- {
-
- $ac = $this->_getParam('ac');
- $invite = $this->_getParam('invite');
-
- $heihe = new Heihe($this->db);
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity())
- {
- $user = $auth->getIdentity();
- $uid = $user->id;
- $this->view->user_email = $user_email = $user->email;
- }
-
- if(empty($ac) || $ac == "index" || $ac == 'my')
- {
- $this->_helper->viewRenderer('project-index');
-
- //Search Link
- $this->view->searchLink = "/heihe/projects/ac/index/";
-
- $q = $this->_getParam('q');
-
- $wheresql = array();
-
- if(!empty($q))
- {
- if(!preg_match("/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]+$/u",$q))
- {
- $this->view->error = "输入的搜索条件有误,只允许输入汉字、数字、字母";
- return true;
- }
- $wheresql[] = " (title LIKE '%$q%' OR
- code LIKE '%$q%' OR
- name LIKE '%$q%')";
- $this->view->searchKeyword = $q;
- }
-
- if($ac == "my")
- {
- $wheresql[] = " email='$user_email' ";
- }
-
- if(count($wheresql)>0)
- {
- $wheresql = join(" AND ",$wheresql);
- }else{
- $wheresql = "";
- }
-
- if(!empty($wheresql))
- {
- $wheresql = " WHERE ".$wheresql;
- }
-
- $sql = "SELECT * FROM heiheproject $wheresql
- ORDER BY id DESC";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
-
- }//ac == index
-
- if($ac == "submitting")
- {
- $this->_helper->viewRenderer('project-index');
-
- $sql = "SELECT * FROM heiheproject WHERE status<4";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
- }//ac == submitting 正在提交
-
- if($ac == "unsubmit")
- {
- $this->_helper->viewRenderer('project-index');
-
- $sql = "SELECT * FROM heiheproject WHERE attachid IS NULL OR attachid=0";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
- }//ac == unsubmit 未提交
-
- if($ac == "submit")
- {
- $this->_helper->viewRenderer('project-index');
-
- $sql = "SELECT * FROM heiheproject WHERE status=4";
- $sth = $this->db->query($sql);
- $rows = $sth->fetchAll();
-
- foreach ($rows as $k=>$v)
- {
- $rows[$k]['status'] = $heihe->getStatus($v['status']);
- }
-
- $paginator = Zend_Paginator::factory($rows);
- $paginator->setCurrentPageNumber($this->_getParam('page'));
- $paginator->setItemCountPerPage(15);
- $paginator->setView($this->view);
- Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
- $this->view->paginator=$paginator;
- }//ac == submit 已提交
-
- if($ac == "upload")
- {
- $this->_helper->layout->setLayout('layout-iframe');
- $this->_helper->viewRenderer('project-upload');
-
- $submit = $this->_getParam('submit');
-
- $pid = $this->_getParam('pid');
-
- if(empty($pid) || !is_numeric($pid))
- {
- $this->view->error = "参数错误";
- return true;
- }
-
- $this->view->pid = $pid;
-
- if(empty($uid))
- {
- $this->view->error = "请先登录";
- return true;
- }
-
- $sql = "SELECT * FROM heiheproject WHERE id=$pid";
- $sth = $this->db->query($sql);
- $row = $sth->fetch();
-
- if($row['email']!= $user_email)
- {
- $this->view->error = "您没有权限进行此操作";
- return true;
- }
-
- if(!empty($submit) && empty($this->view->error))
- {
-
- $files=new files();
- $msg = $files -> upload($this->view->config->upload,$_FILES['Filedata'],'heihe');
-
- if(empty($msg['error']))
- {
- $msg['error']="";
- $filename = $msg['db_path'];
- $filesize = $msg['file_size'];
- $filedesc = $this->_request->getParam('filedesc');
- $filetype = $msg['file_type'];
- $realname = $msg['realname'];
-
- if(!empty($row['attachid']))
- {
- $sql = "SELECT * FROM attachments WHERE id={$row['attachid']}";
- $sth = $this->db->query($sql);
- $attach = $sth->fetch();
- $this->db->exec("DELETE FROM attachments WHERE id={$row['attachid']} AND filetype='heihe'");
- @unlink($this->view->config->upload.$attach['filename']);
- }
-
- $sql = " INSERT INTO attachments (filename,filetype,filedesc,userid,filesize,realname) values
- ('$filename','heihe','$filedesc','$uid','$filesize','$realname') RETURNING id";
- $sth = $this->db->prepare($sql);
- $sth->execute();
- $att = $sth->fetch(PDO::FETCH_ASSOC);
- $msg['attid'] = $attid = $att['id'];
-
- $sql = "UPDATE heiheproject SET attachid=$attid WHERE id=$pid";
- $sth = $this->db->exec($sql);
-
- if($sth)
- {
- $this->view->message = "上传成功";
- }else{
- @unlink($filename);
- $this->view->error = '附件上传失败:写入附件表出错';
- return true;
- }
- }else{
- @unlink($filename);
- $this->view->error = "附件上传失败".$msg['error'];
- return true;
- }
- }
-
- $sql = "SELECT * FROM heiheproject WHERE id=$pid";
- $sth = $this->db->query($sql);
- $row = $sth->fetch();
-
- $sql = "SELECT * FROM attachments WHERE id = {$row['attachid']}";
- $sth = $this->db->query($sql);
- $this->view->att = $sth->fetch();
-
- return true;
- }
-
- if(!empty($invite))
- {
-
- $this->_helper->viewRenderer('project-invite');
-
- $pid = $this->_getParam('pid');
-
- $level = $heihe->expertActive($pid,$invite,$user_email);
-
- if($level>100)
- {
- $this->view->error = "数据中心对您的邀请已经确认!感谢您的支持";
- return true;
- }else{
- $this->view->error = $heihe->expertActiveError($level);
- return true;
- }
-
- }//专家邀请链接
-
-
- }//projectsAction()
-
- function genRandomString($len)
- {
- $chars = array(
- "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
- "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
- "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
- "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
- "3", "4", "5", "6", "7", "8", "9"
- );
- $charsLen = count($chars) - 1;
-
- shuffle($chars); // 将数组打乱
-
- $output = "";
- for ($i=0; $i<$len; $i++)
- {
- $output .= $chars[mt_rand(0, $charsLen)];
- }
- return $output;
- }
-
- function chmodr($path, $filemode) {
- if (!is_dir($path))
- return chmod($path, $filemode);
-
- $dh = opendir($path);
- while (($file = readdir($dh)) !== false) {
- if($file != '.' && $file != '..') {
- $fullpath = $path.'/'.$file;
- if(is_link($fullpath))
- return FALSE;
- elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
- return FALSE;
- elseif(!$this->chmodr($fullpath, $filemode))
- return FALSE;
- }
- }
- closedir($dh);
- if(chmod($path, $filemode))
- return TRUE;
- else
- return FALSE;
- }
-
- //成为作者后的后继处理工作
- private function author_first($uuid,$author)
- {
- $sql="insert into mdversion (xml,ts_created,uuid,changelog,userid)
- select x.data,m.ts_created,?,?,? from metadata m left join xml x on m.id=x.id
- left join mdversion v on m.uuid=v.uuid
- where m.uuid=? and v.changelog is null";
- $sth=$this->db->prepare($sql);
- try
- {
- $sth->execute(array($uuid,'初始版本 version 1.0',$author,$uuid));
- } catch(Exception $e){
- // do nothing here.
- // 说明之前已经有对应数据
- }
- $this->wdb=Zend_Db::factory($this->view->config->geonetwork);
- $sql="update metadata set owner=? where uuid=?";
- $sth=$this->wdb->prepare($sql);
- $sth->execute(array($author,$uuid));
- }
-
-}
\ No newline at end of file
diff --git a/application/default/controllers/WaterController.php b/application/default/controllers/WaterController.php
deleted file mode 100644
index 9a85ef10..00000000
--- a/application/default/controllers/WaterController.php
+++ /dev/null
@@ -1,346 +0,0 @@
-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='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $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;
- }
-}
\ No newline at end of file
diff --git a/application/default/controllers/YrnmrController.php b/application/default/controllers/YrnmrController.php
deleted file mode 100644
index 1273983a..00000000
--- a/application/default/controllers/YrnmrController.php
+++ /dev/null
@@ -1,318 +0,0 @@
-_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);
- }
-
- /*
- * 数据浏览
- */
- 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()
- {
- $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') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP'))");
- $row=$state->fetchAll();
- $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='yrnmr') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化' or keyword='基础地理' or keyword='遥感影像' or keyword='水文地质' or keyword='社会经济' or keyword='人口' or keyword='SWAT' or keyword='NPP' or keyword='WRF' or keyword='辐射' or keyword='NEP')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function geobaseAction()
- {
- $this->getmd('基础地理');
- }
-
- function coreAction()
- {
- $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') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验'))");
- $row=$state->fetchAll();
- $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='yrnmr') and id in (select id from keyword where keytype='theme' and (keyword='DEM' or keyword='土地利用' or keyword='土壤' or keyword='气象' or keyword='水文观测' or keyword='灌溉' or keyword='试验')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function demAction()
- {
- $this->getmd('DEM');
- }
-
- function rsAction()
- {
- $this->getmd('遥感影像');
- }
-
- function waterAction()
- {
- $this->getmd('水文地质');
- }
-
- function modelAction()
- {
- $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') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or 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='yrnmr') and id in (select id from keyword where keytype='theme' and (keyword='WRF' or keyword='NPP' or keyword='SWAT' or keyword='NEP' or keyword='辐射')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function economicAction()
- {
- $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') and id in (select id from keyword where keytype='theme' and (keyword='人口' or 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='yrnmr') and id in (select id from keyword where keytype='theme' and (keyword='人口' or keyword='社会经济')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function landsurfaceAction()
- {
- $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') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化'))");
- $row=$state->fetchAll();
- $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='yrnmr') and id in (select id from keyword where keytype='theme' and (keyword='冰川' or keyword='沙漠' or keyword='地貌' or keyword='植被' or keyword='草场' or keyword='沙漠化')) order by timebegin,title limit ? offset ?";
- $this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
- $this->view->page=new Pagination($sum,$page,$this->limit);
- $this->view->offset=$offset+1;
- }
-
- function landuseAction()
- {
- $this->getmd('土地利用','theme');
- }
-
- function soilAction()
- {
- $this->getmd('土壤','theme');
- }
-
- function meteoAction()
- {
- $this->getmd('气象','theme');
- }
-
- function hydroAction()
- {
- $this->getmd('水文观测','theme');
- }
- function irragationAction()
- {
- $this->getmd('灌溉','theme');
- }
-
- function expAction()
- {
- $this->getmd('实验','theme');
- }
-
- function obsAction()
- {
- $this->getmd('观测','theme');
- }
-
- 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');
- $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='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 {
- $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='yrnmr') 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='yrnmr') 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='yrnmr') 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='yrnmr') 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='yrnmr') 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='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='';
- foreach($rows as $row) {
- $timexml.='';
- $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.="\n";
- }
- $timexml.='';
- $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);
- $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='".$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='".$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;
- }
-}
\ No newline at end of file
diff --git a/application/default/views/scripts/community/index.phtml b/application/default/views/scripts/community/index.phtml
deleted file mode 100755
index 634a9c8e..00000000
--- a/application/default/views/scripts/community/index.phtml
+++ /dev/null
@@ -1,48 +0,0 @@
-headTitle($this->config->title->site);
- $this->headTitle('合作与交流');
-$this->headTitle()->setSeparator(' - ');
-$this->headLink()->appendStylesheet('/css/community.css');
-$this->breadcrumb('首页');
-$this->breadcrumb('合作与交流');
-$this->breadcrumb()->setSeparator(' > ');
-?>
-
Li X, Nan ZT, Cheng GD, Ding YJ, Wu LZ, Wang LX, Wang J, Ran YH, Li HX, Pan XD, Zhu ZM. Toward an improved data stewardship and service for environmental and ecological science data in west China. International Journal of Digital Earth, 2011, 4(4): 347-359. DOI: 10.1080/17538947.2011.558123.
Li X, Li XW, Li ZY, Ma MG, Wang J, Xiao Q, Liu Q, Che T, Chen EX, Yan GJ, Hu
- ZY, Zhang LX, Chu RZ, Su PX, Liu QH, Liu SM, Wang JD, Niu Z, Chen Y, Jin R,
- Wang WZ, Ran YH, Xin XZ, Ren HZ. Watershed Allied Telemetry Experimental
- Research. Journal of Geophysical Research, 2009, 114(D22103),
- doi:10.1029/2008JD011590. 下载
-
在黑河流域已有观测网络的基础上,在3个重点试验区依据不同景观类型新建了7个自动气象站,4套涡动相关,2套大孔径闪烁仪。新建的观测系统和试验区已有的5个自动气象站, 2套涡动相关,8个业务气象站及34个气象区域站相配合,在试验区(如下图)约23700 km2 的范围内,形成了包括常规站、重点站和重点加强站三位一体的黑河中上游地区地面气象水文观测网,以满足不同层次科学研究的需要。大部分观测站获取了2008年和2009年两个完整年度的资料,部分台站观测数据有损失。
-
-
-
- metadata) : ?>
- page->getNavigation(); ?>
-
-
- metadata as $md) : ?>
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/default/views/scripts/water/mobilemeteo.phtml b/application/default/views/scripts/water/mobilemeteo.phtml
deleted file mode 100644
index eae7af2c..00000000
--- a/application/default/views/scripts/water/mobilemeteo.phtml
+++ /dev/null
@@ -1,31 +0,0 @@
-headTitle($this->config->title->site);
-$this->headTitle($this->config->title->data);
-$this->headTitle()->setSeparator(' - ');
-$this->headLink()->appendStylesheet('/css/water.css');
-$this->breadcrumb('首页');
-$this->breadcrumb(''.$this->config->title->data.'');
-$this->breadcrumb('黑河综合遥感联合试验');
-$this->breadcrumb('移动气象站观测');
-$this->breadcrumb()->setSeparator(' > ');
-?>
-
-
- = $this->partial('water/navi.phtml'); ?>
-
-
-
-
-
- metadata) : ?>
- page->getNavigation(); ?>
-
-
- metadata as $md) : ?>
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/application/default/views/scripts/water/navi.phtml b/application/default/views/scripts/water/navi.phtml
deleted file mode 100644
index d8ad2c8a..00000000
--- a/application/default/views/scripts/water/navi.phtml
+++ /dev/null
@@ -1,129 +0,0 @@
-
英文发表的成果依据以下规范注明: The data set is provided by Environmental and Ecological Science Data Center for West China,National Natural Science Foundation of China (http://westdc.westgis.ac.cn)
此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!评审
- -数据评论
-