westdc-zf1/application/default/controllers/WaterController.php

306 lines
15 KiB
PHP
Raw Normal View History

2010-06-23 15:13:26 +00:00
<?php
class WaterController extends DataController
{
private $limit=20;
function indexAction()
{
}
2010-06-27 23:40:07 +00:00
function documentAction()
{
2010-07-02 10:07:53 +00:00
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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'))");
2010-07-02 10:07:53 +00:00
$sum=$row[0]['count'];
2011-12-06 02:44:49 +00:00
$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 ?";
2010-07-02 10:07:53 +00:00
$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;
2010-06-27 23:40:07 +00:00
}
2010-07-07 03:15:05 +00:00
function surveystdAction()
{
}
2010-06-23 15:13:26 +00:00
function coldAction()
{
$this->getmd('上游寒区水文试验区');
}
function bgAction()
{
$this->getmd('冰沟流域加密观测区');
}
function arAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('阿柔加密观测区');
2010-06-23 15:13:26 +00:00
}
function bdkAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('扁都口加密观测区');
}
function ebAction()
{
$this->getmd('峨堡加密观测区');
2010-06-23 15:13:26 +00:00
}
function forestAction()
{
$this->getmd('森林水文试验区');
}
function dykAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('大野口流域加密观测区');
2010-06-23 15:13:26 +00:00
}
function plgAction()
{
$this->getmd('排露沟流域加密观测区');
}
function aridAction()
{
$this->getmd('中游干旱区水文试验区');
}
function hzzAction()
{
2010-06-28 07:26:04 +00:00
$this->getmd('花寨子荒漠加密观测区');
2010-06-23 15:13:26 +00:00
}
function ykAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('盈科绿洲加密观测区');
2010-06-23 15:13:26 +00:00
}
function zyAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('张掖市加密观测区');
2010-06-23 15:13:26 +00:00
}
function zynocAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('观象台加密观测区');
2010-06-23 15:13:26 +00:00
}
function lzgAction()
{
$this->getmd('临泽草地加密观测区');
}
function lzsAction()
{
2010-06-24 13:37:33 +00:00
$this->getmd('临泽站加密观测区');
2010-06-23 15:13:26 +00:00
}
2010-06-24 13:37:33 +00:00
function meteoAction()
{
$this->getmd('气象水文','theme');
}
function autometeoAction()
{
$this->getmd('气象观测','theme');
}
2010-06-28 07:26:04 +00:00
function mobilemeteoAction()
{
$this->getmd('移动气象观测','theme');
}
2010-06-24 13:37:33 +00:00
function ecAction()
{
$this->getmd('涡动相关','theme');
}
function lasAction()
{
$this->getmd('大孔径闪烁仪','theme');
}
function normalmeteoAction()
{
$this->getmd('常规气象观测','theme');
}
function regionalmeteoAction()
{
$this->getmd('区域气象观测','theme');
}
function dopplerAction()
{
2010-06-27 12:06:20 +00:00
$this->getmd('降雨','theme');
}
2010-06-24 13:37:33 +00:00
function hydroAction()
{
$this->getmd('水文','theme');
}
function airsoundingAction()
{
$this->getmd('大气廓线','theme');
}
function aireboneAction()
{
$this->getmd('航空遥感','theme');
}
2010-06-27 23:40:07 +00:00
function radiometerAction()
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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'];
2011-12-06 02:44:49 +00:00
$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;
2010-06-27 23:40:07 +00:00
}
2010-06-30 09:58:12 +00:00
function lidarAction()
2010-06-27 23:40:07 +00:00
{
//$this->getmd('激光雷达','theme');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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'];
2011-12-06 02:44:49 +00:00
$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;
2010-06-27 23:40:07 +00:00
}
function widasAction()
{
2010-06-30 09:58:12 +00:00
//$this->getmd('WiDAS','theme');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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='航空遥感')");
2010-06-30 09:58:12 +00:00
$row=$state->fetchAll();
$sum=$row[0]['count'];
2011-12-06 02:44:49 +00:00
$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 ?";
2010-06-30 09:58:12 +00:00
$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;
2010-06-27 23:40:07 +00:00
}
function asdAction()
{
//$this->getmd('成像光谱仪OMIS-II','theme');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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'];
2011-12-06 02:44:49 +00:00
$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;
2010-06-27 23:40:07 +00:00
}
2010-06-24 13:37:33 +00:00
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'];
2011-12-06 02:44:49 +00:00
$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 ?";
2010-06-24 13:37:33 +00:00
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
2010-06-30 13:37:35 +00:00
} else {
2011-12-06 02:44:49 +00:00
$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");
2010-06-30 13:37:35 +00:00
$k1=$state->fetchAll();
2011-12-06 02:44:49 +00:00
$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");
2010-06-30 13:37:35 +00:00
$k2=$state->fetchAll();
2011-12-06 02:44:49 +00:00
$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");
2010-06-30 13:37:35 +00:00
$k5=$state->fetchAll();
$this->view->keywords=array('place'=>$k1,'theme'=>$k2,'discipline'=>$k3,'stratum'=>$k4,'temporal'=>$k5);
2010-06-24 13:37:33 +00:00
}
}
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);
2011-12-06 02:44:49 +00:00
$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'];
2011-12-06 02:44:49 +00:00
$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);
2010-06-27 23:40:07 +00:00
$this->view->key=$key;
$this->view->offset=$offset+1;
}
}
2010-06-29 03:41:06 +00:00
function timemapAction()
{
2011-12-06 02:44:49 +00:00
$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')";
2010-06-29 03:41:06 +00:00
$this->view->rows=$this->db->fetchAll($sql);
}
function timelineAction()
{
$fn="watertime.xml";
2011-12-06 02:44:49 +00:00
$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";
2011-12-06 02:44:49 +00:00
$rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and timebegin is not null order by timebegin,title");
$timexml='<data>';
foreach($rows as $row) {
$timexml.='<event start="'.date($dateformat,strtotime($row['timebegin'])).' GMT+0800" ';
if ($row['timeend']!='' && $row['timeend']!=$row['timebegin']) $timexml.=' end="'.date($dateformat,strtotime($row['timeend'])).'" isDuration="true"';
$timexml.= ' title="'.htmlspecialchars(mb_substr($row['title'],11,mb_strlen($row['title'],'UTF-8')-10,'UTF-8')).'" image="/images/westdc_40w.gif" link="/water/'.$row['uuid'].'">';
$desc_length=mb_strlen($row['description'],"UTF-8");
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
if ($desc_length>300) $desc.=" ...";
$timexml.=htmlspecialchars($desc);
$timexml.="</event>\n";
}
$timexml.='</data>';
$fp=fopen($fn,'w');
fwrite($fp,$timexml);
fclose($fp);
}
}
2010-06-28 14:20:25 +00:00
function categoryAction()
{
$code = (int)$this->_request->getParam('code');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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.")");
2010-06-28 14:20:25 +00:00
$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) {
2011-12-06 02:44:49 +00:00
$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 ?";
2010-06-28 14:20:25 +00:00
$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 {
//提供全部分类列表
}
}
2010-06-24 13:37:33 +00:00
private function getmd($keyword,$type='place')
2010-06-23 15:13:26 +00:00
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
2011-12-06 02:44:49 +00:00
$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."')");
2010-06-23 15:13:26 +00:00
$row=$state->fetchAll();
$sum=$row[0]['count'];
2010-06-30 09:58:12 +00:00
//@todo: add order with title
2011-12-06 02:44:49 +00:00
$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 ?";
2010-06-23 15:13:26 +00:00
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
2010-06-27 23:40:07 +00:00
$this->view->offset=$offset+1;
2010-06-24 13:37:33 +00:00
}
2010-06-23 15:13:26 +00:00
}