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

570 lines
28 KiB
PHP
Raw Normal View History

<?php
class WaterController extends DataController
{
private $limit=20;
function preDispatch()
{
2013-11-09 15:47:23 +00:00
parent::preDispatch();
$this->debug = 0;
$acName = $this->_request->getActionName();
if(in_array($acName,array("cold","bg","ar","bdk","eb")))
{
$this->view->pageIn = "collapse1";
}
if(in_array($acName,array("forest","dyk","plg")))
{
$this->view->pageIn = "collapse2";
}
if(in_array($acName,array("arid","hzz","yk",'zy','zynoc','lzg','lzs')))
{
$this->view->pageIn = "collapse3";
}
if(in_array($acName,array("meteo","autometeo","mobilemeteo","ec",'las','normalmeteo','regionalmeteo','doppler','hydro','airsounding')))
{
$this->view->pageIn = "collapse4";
}
if(in_array($acName,array("radiometer","airebone","lidar","widas",'asd')))
{
$this->view->pageIn = "collapse5";
}
if(in_array($acName,array("satellite")))
{
$this->view->pageIn = "collapse6";
}
if(in_array($acName,array("surveystd","document")))
{
$this->view->pageIn = "collapse7";
}
$this->view->pageID = "water-".$acName;
}
function indexAction()
2013-11-09 15:47:23 +00:00
{
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER - Watershed Allied Telemetry Experimental Research','about');
}
function documentAction()
{
2013-11-09 15:47:23 +00:00
$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 language<>'zh' and id in (select refid from mdref where uuid in (select m.uuid from en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water'))");
$sum=$row[0]['count'];
$sql="select * from reference where language<>'zh' and id in (select refid from mdref where uuid in (select m.uuid from normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on s.id=d.sourceid where s.code='water')) order by reference limit ? offset ?";
$this->view->refs=$this->db->fetchAll($sql,array($this->limit,$offset));
2013-11-09 15:47:23 +00:00
$this->view->page=new Pagination($sum,$page,$this->limit,"Publications");
$this->view->offset=$offset+1;
}
function coldAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the cold region hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Cold region hydrology experiment','about');
$this->_helper->viewRenderer('base');
}
function bgAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Binggou watershed foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Binggou watershed foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function arAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd("A''rou foci experimental area",'place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive("WATER: Arou foci experimental area",'about');
$this->_helper->viewRenderer('base');
}
function bdkAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Biandukou (BDK) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Biandukou (BDK) foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function ebAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Ebao foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Ebao foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function forestAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the forest hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Forest hydrology experimental area','about');
$this->_helper->viewRenderer('base');
}
function dykAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Dayekou watershed foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Dayekou watershed foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function plgAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Pailugou watershed (PLG) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Pailugou watershed (PLG) foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function aridAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the arid region hydrology experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Arid region hydrology experimental area','about');
$this->_helper->viewRenderer('base');
}
function hzzAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Huazhaizi foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Huazhaizi foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function ykAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Yingke oasis station','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Yingke oasis station','about');
$this->_helper->viewRenderer('base');
}
function zyAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Zhangye city (ZY) foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Zhangye city (ZY) foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function zynocAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('National observatory on climatology at Zhangye (ZYNOC)','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: National observatory on climatology at Zhangye (ZYNOC)','about');
$this->_helper->viewRenderer('base');
}
function lzgAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Linze grassland foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Linze grassland foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function lzsAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('Linze station foci experimental area','place');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Linze station foci experimental area','about');
$this->_helper->viewRenderer('base');
}
function meteoAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('meteorology and hydrology','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: meteorology and hydrology','about');
$this->_helper->viewRenderer('base');
}
function autometeoAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the meteorological observation','about');
$this->_helper->viewRenderer('base');
}
function mobilemeteoAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the mobile meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the mobile meteorological observation','about');
$this->_helper->viewRenderer('base');
}
function ecAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('eddy covariance','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: eddy covariance','about');
$this->_helper->viewRenderer('base');
}
function lasAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the large aperture scintillometer','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the large aperture scintillometer','about');
$this->_helper->viewRenderer('base');
}
function normalmeteoAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the routine meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the routine meteorological observation','about');
$this->_helper->viewRenderer('base');
}
function regionalmeteoAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('the regional meteorological observation','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: the regional meteorological observation','about');
$this->_helper->viewRenderer('base');
}
function dopplerAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('dual-polarization Doppler weather radar','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: dual-polarization Doppler weather radar','about');
$this->_helper->viewRenderer('base');
}
function hydroAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('hydrology','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: hydrology','about');
$this->_helper->viewRenderer('base');
}
function airsoundingAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('atmospheric profile','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: atmospheric profile','about');
$this->_helper->viewRenderer('base');
}
function aireboneAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('airborne remote sensing','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: airborne remote sensing','about');
$this->_helper->viewRenderer('base');
}
function radiometerAction()
{
2013-11-09 15:47:23 +00:00
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword ilike '%microwave radiometer') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword ilike '%microwave radiometer') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
2013-11-09 15:47:23 +00:00
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: Microwave radiometers','about');
$this->_helper->viewRenderer('base');
}
function lidarAction()
{
2013-11-09 15:47:23 +00:00
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='lidar') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='lidar') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
2013-11-09 15:47:23 +00:00
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: LiDAR','about');
$this->_helper->viewRenderer('base');
}
function widasAction()
{
2013-11-09 15:47:23 +00:00
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='Wide-angle Infrared Dual-mode line/area Array Scanner,WiDAS') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='Wide-angle Infrared Dual-mode line/area Array Scanner,WiDAS') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
2013-11-09 15:47:23 +00:00
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: WiDAS','about');
$this->_helper->viewRenderer('base');
}
function asdAction()
{
2013-11-09 15:47:23 +00:00
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$state=$this->db->query("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='SWPHI') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keytype='theme' and keyword='SWPHI') and id in (select id from en.keyword where keytype='theme' and keyword='airborne remote sensing') order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
2013-11-09 15:47:23 +00:00
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: OMIS-II','about');
$this->_helper->viewRenderer('base');
}
function satelliteAction()
{
2013-11-09 15:47:23 +00:00
$this->getmd('satellite remote sensing','theme');
$archive = new Archive($this->db);
$this->view->info = $archive->getOneArchive('WATER: satellite remote sensing','about');
$this->_helper->viewRenderer('base');
}
2013-11-09 15:47:23 +00:00
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 en.keyword k left join en.normalmetadata m on k.id=m.id where length(k.keyword)>0 and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and k.keyword=?",$key);
$state=$this->db->query($sql);
$row=$state->fetchAll();
$sum=$row[0]['count'];
$sql="select uuid,title,id,description from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keyword='".$key."') order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
} else {
$sql="select k.keyword,count(*),k.keytype from en.keyword k left join en.normalmetadata m on k.id=m.id where length(k.keyword)>0 and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') ";
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);
2013-11-09 15:47:23 +00:00
$row=$this->db->fetchAll("select count(*) from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and ".$where);
$sum=$row[0]['count'];
2013-11-09 15:47:23 +00:00
$sql="select uuid,title,id,description from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and ".$where." order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->key=$key;
$this->view->offset=$offset+1;
}
}
function timemapAction()
{
2013-11-09 15:47:23 +00:00
$sql="select id,uuid,west,south,north,east,title,timebegin,timeend from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and timebegin is not null and timebegin::date>date('2007-01-01')";
$this->view->rows=$this->db->fetchAll($sql);
}
function timelineAction()
{
$fn="watertime.xml";
2013-11-09 15:47:23 +00:00
$rows=$this->db->fetchAll("select ts_created from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') order by ts_created desc limit 1");
$last_update=strtotime($rows[0]['ts_created']);
if (!file_exists($fn) || (filemtime($fn)<$last_update))
{
$dateformat="M j Y";
2013-11-09 15:47:23 +00:00
$rows=$this->db->fetchAll("select id,uuid,description,title,timebegin,timeend from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and timebegin is not null order by timebegin,title");
$timexml='<data>';
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"';
2013-11-09 15:47:23 +00:00
$timexml.= ' title="'.htmlspecialchars(mb_substr($row['title'],6,mb_strlen($row['title'],'UTF-8')-6,'UTF-8')).'" image="/images/westdc_40w.gif" link="/water/'.$row['uuid'].'">';
$desc_length=mb_strlen($row['description'],"UTF-8");
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
if ($desc_length>300) $desc.=" ...";
$timexml.=htmlspecialchars($desc);
$timexml.="</event>\n";
}
$timexml.='</data>';
$fp=fopen($fn,'w');
fwrite($fp,$timexml);
fclose($fp);
}
}
function categoryAction()
{
$code = (int)$this->_request->getParam('code');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$row=$this->db->fetchAll("select count(*) from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from category where code=".$code.")");
$sum=$row[0]['count'];
$this->view->category=$this->db->fetchAll('select c.code,name,name_zh,count(*) from category c,categorycode cc where c.code=cc.code group by c.code,cc.name,cc.name_zh');
if ($code>0 && $code<20) {
$sql="select uuid,title,description,id from normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select distinct id from category where code=".$code.") order by timebegin,title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
$row=$this->db->fetchRow("select name,name_zh from categorycode where code=?",$code);
$this->view->codename=(empty($row['name_zh'])?$row['name']:$row['name_zh']);
} else {
//提供全部分类列表
}
}
2013-11-09 15:47:23 +00:00
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 en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='water' and m.id in (select id from en.keyword where keytype='".$type."' and keyword in ".$keyword.")");
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where 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 en.normalmetadata m left join datasource d on m.uuid=d.uuid left join source s on d.sourceid=s.id where s.code='water' and m.id in (select id from en.keyword where keyword='".$limited."') and m.id in (select id from en.keyword where keyword in ".$keyword.")");
$row=$state->fetchAll();
$sum=$row[0]['count'];
//@todo: add order with title
$sql="select uuid,title from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='water') and id in (select id from en.keyword where keyword='".$limited."') and id in (select id from en.keyword where keyword in ".$keyword.") order by title limit ? offset ?";
$this->view->metadata=$this->db->fetchAll($sql,array($this->limit,$offset));
$this->view->page=new Pagination($sum,$page,$this->limit);
$this->view->offset=$offset+1;
}
//基于数据作者的浏览(包括认证后的数据作者以及未认证的数据作者)
function authorAction()
{
$ac = $this->_request->getParam('ac');
$id = (int)$this->_request->getParam('id');
if ($ac=='verified') {
//已经认证过的数据作者
$this->view->tabID='author-verified';
$this->view->ac='verified';
if ($id) {
//列出作者的数据
$sql="select username,realname from users where id=?";
$this->view->author=$this->db->fetchRow($sql,array($id));
$sql="select m.* from normalmetadata m left join mdauthor a on a.uuid=m.uuid where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and a.userid=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//已经认证过的数据作者
$sql="select u.username,u.realname,u.id,count(u.id) as count from mdauthor a left join users u on a.userid=u.id where a.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and a.status=1 and a.uuid in (select uuid from normalmetadata) group by u.id,u.username,u.realname";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(50);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
} else if ($ac=='unverified' || empty($ac)) {
//未认证的数据作者
$this->view->tabID='author-unverified';
$this->view->ac='unverified';
if ($id) {
//列出数据
$sql="select individual as username from responsible where id=?";
$this->view->author=$this->db->fetchRow($sql,array($id));
$sql="select distinct m.* from normalmetadata m left join role r on m.uuid=r.uuid left join responsible s on r.resid=s.id where r.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and r.role in ('pointOfContact','resourceProvider','owner') and s.id=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($id));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//列出所有作者
$sql="select distinct responsible.individual as username,responsible.id from responsible left join role on role.resid=responsible.id where role.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and role.role in ('pointOfContact','resourceProvider','owner')";
$sth = $this->db->prepare($sql);
$sth->execute();
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(50);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
}
}
function organizationAction()
{
$page = $this->_request->getParam('page');
$name = $this->_request->getParam('name');
$state=$this->db->query("select distinct responsible.organisation from en.responsible left join en.role on role.resid=responsible.id where role.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and role.role in ('pointOfContact','resourceProvider','owner')");
$this->view->organisation=$state->fetchAll();
if (!empty($name)) {
$this->view->codename=$name;
$sql="select distinct m.* from en.normalmetadata m left join en.role r on m.uuid=r.uuid left join en.responsible s on r.resid=s.id where m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') and r.role in ('pointOfContact','resourceProvider','owner') and s.organisation=?";
$sth = $this->db->prepare($sql);
$sth->execute(array($name));
$rows = $sth->fetchAll();
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(10);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
} else {
//提供全部分类列表
}
}
2010-06-23 15:13:26 +00:00
}