2012-12-13 03:59:48 +00:00
< ? php
class HiwaterController extends DataController
{
private $limit = 20 ;
function preDispatch ()
{
2013-11-09 15:47:47 +00:00
parent :: preDispatch ();
2014-09-30 06:50:20 +00:00
2013-11-09 15:47:47 +00:00
$this -> debug = 0 ;
2013-04-16 09:19:06 +00:00
$acName = $this -> _request -> getActionName ();
2013-10-28 14:54:21 +00:00
if ( in_array ( $acName , array ( " aviation " , " radiometer " , " lidar " , " ccdlidar " , " widas " , 'ccdwidas' , " nearvis " , " thermal " )))
2013-04-16 09:19:06 +00:00
{
$this -> view -> pageIn = " collapse1 " ;
}
2013-10-28 14:54:21 +00:00
else if ( in_array ( $acName , array ( " airborne " , " demdsm " , " reflectance " , " vegtypeair " , " vegparam " , " temperature " , " soilmoisture " )))
2013-04-16 09:19:06 +00:00
{
$this -> view -> pageIn = " collapse2 " ;
}
2014-09-18 05:19:23 +00:00
else if ( in_array ( $acName , array ( " hmon " , 'hmon2012' , 'hmon2013' , 'hmon2012up' , 'hmon2012middle' , 'hmon2012down' , 'hmon2013up' , 'hmon2013middle' , 'hmon2013down' , 'super' , 'normal' , 'prec' )))
2013-04-16 09:19:06 +00:00
{
$this -> view -> pageIn = " collapse3 " ;
}
2013-05-25 02:19:17 +00:00
else if ( in_array ( $acName , array ( " cgs " , " calibration " , " ground " , 'sync' )))
2013-04-16 09:19:06 +00:00
{
$this -> view -> pageIn = " collapse4 " ;
}
2013-05-25 02:19:17 +00:00
else if ( in_array ( $acName , array ( " wsn " , " waternet " , " soilnet " , " bnunet " , 'bnulai' )))
2013-04-16 09:19:06 +00:00
{
$this -> view -> pageIn = " collapse5 " ;
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
else if ( in_array ( $acName , array ( " mso " , " autometeo " , " ec " , 'las' , " cosmos " , " tdp " , " isotope " )))
2013-06-07 02:30:26 +00:00
{
$this -> view -> pageIn = " collapse6 " ;
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
else if ( in_array ( $acName , array ( " rsproduct " , " dem " , " precipitation " , 'sm' , " snow " , " vegtype " , " vegcov " , 'phenology' , 'npp' )))
{
$this -> view -> pageIn = " collapse7 " ;
2013-10-28 14:54:21 +00:00
}
2013-05-28 04:20:36 +00:00
else if ( in_array ( $acName , array ( " browse " , " thumb " , " fund " , " tag " , " timeline " , " timemap " , 'author' , 'organization' )))
2013-05-26 11:23:36 +00:00
{
$this -> view -> pageIn = " collapse10 " ;
2013-04-16 09:19:06 +00:00
}
2013-05-25 02:19:17 +00:00
else if ( in_array ( $acName , array ( " other " )))
2013-04-16 09:19:06 +00:00
{
2013-06-07 02:30:26 +00:00
$this -> view -> pageIn = " collapse9 " ;
2013-04-16 09:19:06 +00:00
}
2013-10-28 14:54:21 +00:00
$this -> view -> pageID = " hiwater- " . $acName ;
2014-09-30 06:50:20 +00:00
//$this->_helper->layout->setLayout('heihe');
2012-12-13 03:59:48 +00:00
}
function indexAction ()
{
2014-09-30 06:50:23 +00:00
$sql = " select m.uuid,m.title,m.id,m.description from en.normalmetadata m left join en.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 " ;
2012-12-13 03:59:48 +00:00
$this -> view -> meatdata = $this -> db -> fetchAll ( $sql );
$archive = new Archive ( $this -> db );
2014-09-30 06:50:23 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'Heihe Watershed Allied Telemetry Experimental Research (HiWATER)' , 'about' );
2012-12-13 03:59:48 +00:00
}
/*
* 数据浏览
*/
function browseAction ()
{
$page = ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2014-09-30 06:50:23 +00:00
$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='hiwater') " );
2012-12-13 03:59:48 +00:00
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
$select = $this -> db -> select ();
2014-09-30 06:50:23 +00:00
$select -> from ( 'en.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 );
2012-12-13 03:59:48 +00:00
$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 );
2014-09-30 06:50:23 +00:00
$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='hiwater') " );
2012-12-13 03:59:48 +00:00
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
$select = $this -> db -> select ();
2014-09-30 06:50:23 +00:00
$select -> from ( 'en.normalmetadata as m' , 'm.*' )
2012-12-13 03:59:48 +00:00
-> 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 );
2014-09-30 06:50:23 +00:00
$row = $this -> db -> fetchAll ( " select count(*) from reference where language<>'zh' and id in (select refid from mdref where uuid in (select uuid from en.normalmetadata where uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='hiwater') )) " );
2012-12-13 03:59:48 +00:00
$sum = $row [ 0 ][ 'count' ];
2014-09-30 06:50:23 +00:00
$sql = " select * from reference where language<>'zh' and id in (select refid from mdref where uuid in (select uuid from en.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 ? " ;
2012-12-13 03:59:48 +00:00
$this -> view -> refs = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2014-09-30 06:50:23 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit , " literatures " );
2012-12-13 03:59:48 +00:00
$this -> view -> offset = $offset + 1 ;
}
2013-05-24 16:24:31 +00:00
function aviationAction ()
{
2016-04-08 13:11:22 +00:00
$this -> getmdlimited ( array ( 'WiDAS' , 'WIDAS' , 'PLMR' , 'LIDAR' , 'CASI' , 'thermal-infrared hyperspectral data' ), 'airborne remote sensing' );
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function radiometerAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( 'PLMR' , 'airborne remote sensing' );
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function lidarAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( 'LIDAR' , 'airborne remote sensing' , array ( 'CCD' ));
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-10-28 14:54:21 +00:00
function ccdlidarAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdrestricted ( array ( 'CCD' , 'airborne remote sensing' , " LIDAR " ));
2013-10-28 14:54:21 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-05-24 16:24:31 +00:00
function widasAction ()
2013-10-28 14:54:21 +00:00
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( 'WIDAS' , 'airborne remote sensing' , array ( 'CCD' ));
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-10-28 14:54:21 +00:00
function ccdwidasAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdrestricted ( array ( 'CCD' , 'airborne remote sensing' , 'WIDAS' ));
2013-06-18 12:23:33 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-05-24 16:24:31 +00:00
function nearvisAction ()
2013-10-28 14:54:21 +00:00
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( 'CASI' , 'airborne remote sensing' );
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function thermalAction ()
2013-10-28 14:54:21 +00:00
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( 'thermal-infrared hyperspectral data' , 'airborne remote sensing' );
2013-05-24 16:24:31 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-05-25 02:19:17 +00:00
function airborneAction ()
2012-12-13 03:59:48 +00:00
{
2015-10-25 08:08:27 +00:00
$this -> getmdlimited ( array ( 'DEM' , 'DSM' , 'DOM' , 'albedo' , 'land use' , 'vegetation type' , 'Vegetation structure parameters' , 'soil water content' , 'land surface temperature' ), 'airborne remote sensing data products' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-10-28 14:54:21 +00:00
function demdsmAction ()
2013-05-25 02:19:17 +00:00
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( array ( 'DEM' , 'DSM' , 'DOM' ), " airborne remote sensing data products " );
2013-10-28 14:54:21 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function reflectanceAction ()
{
2015-10-25 08:08:27 +00:00
$this -> getmdlimited ( array ( 'albedo' ), " airborne remote sensing data products " );
2013-10-28 14:54:21 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function vegtypeairAction ()
{
2015-10-25 08:08:27 +00:00
$this -> getmdlimited ( array ( 'vegetation type' , 'land use' ), 'airborne remote sensing data products' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function vegparamAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( array ( " " , 'Vegetation structure parameters' ), " airborne remote sensing data products " );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
function soilmoistureAction ()
2013-05-25 02:19:17 +00:00
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( array ( '' , 'soil water content' ), " airborne remote sensing data products " );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function temperatureAction ()
{
2014-11-29 14:37:25 +00:00
$this -> getmdlimited ( array ( '' , 'land surface temperature' ), " airborne remote sensing data products " );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-06-13 13:09:10 +00:00
function hmonAction ()
2013-05-25 02:19:17 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$archive = new Archive ( $this -> db );
2015-01-16 09:49:43 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-HMon' , 'about' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function superAction ()
{
$this -> getmdlimited ( array ( '阿柔超级站' , '大满超级站' , '四道桥超级站' ), '水文气象' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-06-13 13:09:10 +00:00
function normalAction ()
2012-12-13 03:59:48 +00:00
{
2013-10-28 14:54:21 +00:00
$this -> getmdlimited ( array ( '景阳岭站' , '峨堡站' , '黄草沟站' , '阿柔阴坡站' , '阿柔阳坡站' , '黄藏寺站' , '大沙龙站' , '寺大隆站' , '排露沟林前气象站' , '水源涵养林研究院观测站' , '巴吉滩戈壁站' , '神沙窝沙漠站' , '张掖湿地站' ,
'花寒子荒漠站' , '五里墩气象站' , '四道桥混合林站' , '四道桥胡杨林站' , '四道桥裸地站' , '四道桥农田站' , '黑河上游生态-水文试验研究站' , '临泽内陆河流域研究站' , '阿拉善荒漠生态-水文实验研究站' ), '水文气象' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-06-13 13:09:10 +00:00
2013-05-25 02:19:17 +00:00
function autometeoAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'automatic weather station' ), 'flux observation matrix' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
$archive = new Archive ( $this -> db );
2015-04-11 04:02:55 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-MSO' , 'about' );
2013-05-25 02:19:17 +00:00
}
function ecAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'eddy covariance system' ), 'flux observation matrix' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
$archive = new Archive ( $this -> db );
2015-04-11 04:02:55 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-MSO' , 'about' );
2013-05-25 02:19:17 +00:00
}
function lasAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'large aperture scintillometer' ), 'flux observation matrix' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
$archive = new Archive ( $this -> db );
2015-04-11 04:02:55 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-MSO' , 'about' );
2013-10-28 14:54:21 +00:00
2013-05-25 02:19:17 +00:00
}
function precAction ()
{
$this -> getmd ( array ( '' , '河川径流观测' ));
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function cgsAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( 'calibration measurement' , 'ground measurement' , 'synchronous observation' ));
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function calibrationAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( '' , 'calibration measurement' ));
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function groundAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( '' , 'ground measurement' ));
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function syncAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( '' , 'synchronous observation' ));
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function wsnAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'WATERNET' , 'SoilNET' , 'BNUNET' , 'LAI' ), 'Eco-hydrological Wireless Sensor Network' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function waternetAction ()
2012-12-13 03:59:48 +00:00
{
2013-05-25 02:19:17 +00:00
$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 ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( 'LAI' , 'Eco-hydrological Wireless Sensor Network' );
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
2013-05-25 02:19:17 +00:00
function satelliteAction ()
2012-12-13 03:59:48 +00:00
{
2015-04-11 04:02:55 +00:00
$this -> getmd ( array ( '' , 'satellite remote sensing' ));
2013-05-25 02:19:17 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
function soilAction ()
{
2013-05-25 02:19:17 +00:00
$this -> getmd ( array ( '' , '卫星遥感' ));
$this -> _helper -> viewRenderer ( 'base' );
2012-12-13 03:59:48 +00:00
}
function meteoAction ()
{
$this -> getmd ( '气象' , 'theme' );
}
function hydroAction ()
{
$this -> getmd ( '水文观测' , 'theme' );
}
function irragationAction ()
{
$this -> getmd ( '灌溉' , 'theme' );
}
function obsAction ()
{
$this -> getmd ( '试验' , 'theme' );
}
2013-10-28 14:54:21 +00:00
2013-06-07 02:30:26 +00:00
function msoAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'automatic weather station' , 'eddy covariance system' , 'large aperture scintillometer' , 'stable isotope' , 'TDP' , 'cosmic-ray soil moisture observing system' ), 'flux observation matrix' );
2013-06-07 02:30:26 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
$archive = new Archive ( $this -> db );
2015-01-16 09:49:43 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-MSO' , 'about' );
2013-06-07 02:30:26 +00:00
}
2012-12-13 03:59:48 +00:00
2013-06-07 02:30:26 +00:00
function isotopeAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'stable isotope' ), 'flux observation matrix' );
2013-06-07 02:30:26 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-10-28 14:54:21 +00:00
2013-06-07 02:30:26 +00:00
function tdpAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'TDP' ), 'flux observation matrix' );
2013-06-07 02:30:26 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2013-10-28 14:54:21 +00:00
2013-06-07 02:30:26 +00:00
function cosmosAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( '' , 'cosmic-ray soil moisture observing system' ), 'flux observation matrix' );
2013-06-07 02:30:26 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function rsproductAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'DEM' , 'DOM' , '降水' , 'soil moisture' , 'snow' , 'vegetation type' , 'vegetation cover' , 'crop phenology' , 'NPP' ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-06-07 02:30:26 +00:00
}
2013-06-13 13:09:10 +00:00
function demAction ()
{
$this -> getmdlimited ( array ( 'DEM' , 'DOM' ), '数据产品' );
$this -> _helper -> viewRenderer ( 'base' );
}
function precipitationAction ()
{
$this -> getmdlimited ( array ( '降水' , '' ), '数据产品' );
$this -> _helper -> viewRenderer ( 'base' );
}
function smAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'soil moisture' , " " ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function snowAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'snow' , " " ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function vegtypeAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'vegetation type' , '' ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function vegcovAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'vegetation cover' , '' ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function phenologyAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'crop phenology' , '' ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2013-06-13 13:09:10 +00:00
function nppAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdlimited ( array ( 'NPP' , '' ), 'satellite remote sensing data products' );
2013-06-13 13:09:10 +00:00
$this -> _helper -> viewRenderer ( 'base' );
2013-10-28 14:54:21 +00:00
}
2014-09-18 05:19:23 +00:00
function hmon2012Action ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2012' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$archive = new Archive ( $this -> db );
2015-01-16 09:49:43 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-HMon' , 'about' );
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2013Action ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2013' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$archive = new Archive ( $this -> db );
2015-01-16 09:49:43 +00:00
$this -> view -> info = $archive -> getOneArchive ( 'HiWATER-HMon' , 'about' );
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2012upAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2012' , '上游寒区水文试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2012middleAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2012' , '中游人工绿洲试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2012downAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2012' , '下游天然绿洲试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2013upAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2013' , '上游寒区水文试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2013middleAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2013' , '中游人工绿洲试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
function hmon2013downAction ()
{
2015-04-11 04:02:55 +00:00
$this -> getmdrestricted ( array ( '2013' , '下游天然绿洲试验区' , 'Hydrometeorology observation network' ));
2014-09-18 05:19:23 +00:00
$this -> _helper -> viewRenderer ( 'base' );
}
2012-12-13 03:59:48 +00:00
function listAction ()
{
2014-09-30 06:50:23 +00:00
$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='hiwater') order by timebegin,title " ;
2012-12-13 03:59:48 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql );
}
function tagAction ()
{
$key = $this -> _request -> getParam ( 'key' );
2013-05-25 03:46:38 +00:00
$keytype = $this -> _request -> getParam ( 'keytype' );
2012-12-13 03:59:48 +00:00
$page = ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
if ( ! empty ( $key )) {
$this -> view -> codename = $key ;
2014-09-30 06:50:23 +00:00
$sql = $this -> db -> quoteInto ( " select count(k.id) from en.keyword k left join en.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 );
2012-12-13 03:59:48 +00:00
$state = $this -> db -> query ( $sql );
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
2014-09-30 06:50: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='hiwater') and id in (select id from en.keyword where keyword=' " . $key . " ') order by timebegin,title limit ? offset ? " ;
2012-12-13 03:59:48 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
} else {
2014-09-30 06:50:23 +00:00
$sql = " select k.keyword,count(*),k.keytype from en.keyword k left join en.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') " ;
2013-05-25 03:46:38 +00:00
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 ();
2012-12-13 03:59:48 +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 )) {
2013-05-25 02:19:17 +00:00
$search = new SimpleSearch ( $key );
2012-12-13 03:59:48 +00:00
$where = $search -> sql_expr ( array ( " title " , " description " ));
$page =@ ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2014-09-30 06:50: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='hiwater') and " . $where );
2012-12-13 03:59:48 +00:00
$sum = $row [ 0 ][ 'count' ];
2014-09-30 06:50: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='hiwater') and " . $where . " order by timebegin,title limit ? offset ? " ;
2012-12-13 03:59:48 +00:00
$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 ()
{
2014-09-30 06:50: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='hiwater') and timebegin is not null " ;
2012-12-13 03:59:48 +00:00
$this -> view -> rows = $this -> db -> fetchAll ( $sql );
}
function timelineAction ()
{
2013-05-25 03:46:38 +00:00
$fn = " hiwatertime.xml " ;
2014-09-30 06:50: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='hiwater') order by ts_created desc limit 1 " );
2012-12-13 03:59:48 +00:00
$last_update = strtotime ( $rows [ 0 ][ 'ts_created' ]);
if ( ! file_exists ( $fn ) || ( filemtime ( $fn ) < $last_update ))
{
$dateformat = " M j Y " ;
2014-09-30 06:50: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='hiwater') and timebegin is not null order by timebegin,title " );
2012-12-13 03:59:48 +00:00
$timexml = '<data>' ;
foreach ( $rows as $row ) {
$timexml .= '<event start="' . date ( $dateformat , strtotime ( $row [ 'timebegin' ])) . ' GMT+0800" ' ;
if ( $row [ 'timeend' ] != '' && $row [ 'timeend' ] != $row [ 'timebegin' ]) $timexml .= ' end="' . date ( $dateformat , strtotime ( $row [ 'timeend' ])) . '" isDuration="true"' ;
$timexml .= ' title="' . htmlspecialchars ( $row [ 'title' ]) . '" image="/images/westdc_40w.gif" link="/hiwater/view/uuid/' . $row [ 'uuid' ] . '">' ;
$desc_length = mb_strlen ( $row [ 'description' ], " UTF-8 " );
$desc = mb_substr ( $row [ 'description' ], 0 ,( $desc_length > 300 ) ? 300 : $desc_length , " UTF-8 " );
if ( $desc_length > 300 ) $desc .= " ... " ;
$timexml .= htmlspecialchars ( $desc );
$timexml .= " </event> \n " ;
}
$timexml .= '</data>' ;
$fp = fopen ( $fn , 'w' );
fwrite ( $fp , $timexml );
fclose ( $fp );
}
}
function categoryAction ()
{
$code = ( int ) $this -> _request -> getParam ( 'code' );
$page = ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2014-09-30 06:50:23 +00:00
$this -> view -> category = $this -> db -> fetchAll ( " select c.code,name,name_zh,count(*) from category c left join en.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 " );
2012-12-13 03:59:48 +00:00
if ( $code > 0 && $code < 20 ) {
2014-09-30 06:50: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='hiwater') and id in (select id from category where code= " . $code . " ) " );
2012-12-13 03:59:48 +00:00
$sum = $row [ 0 ][ 'count' ];
2014-09-30 06:50:23 +00:00
$sql = " select uuid,title,description,id from en.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 ? " ;
2012-12-13 03:59:48 +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 {
//提供全部分类列表
}
}
2013-05-25 03:46:38 +00:00
function viewAction ()
{
parent :: viewAction ();
2015-06-25 12:38:07 +00:00
include_once ( " ipip/IP.class.php " );
$ip = new IP ();
if ( ! $ip -> mainland_verify ())
2015-06-20 07:25:01 +00:00
$this -> _helper -> viewRenderer ( 'hiwater/view' );
else
$this -> _helper -> viewRenderer ( 'hiwater/view-tianditu' );
2013-05-25 03:46:38 +00:00
}
2012-12-13 03:59:48 +00:00
private function getmd ( $keyword , $type = 'theme' )
{
$page = ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
2013-05-24 16:24:31 +00:00
if ( ! is_array ( $keyword ))
{
$keyword = array ( $keyword );
}
$key = " ( " ;
foreach ( $keyword as $k )
{
$key .= " ' " . $k . " ', " ;
}
$key = substr ( $key , 0 , - 1 );
$key .= " ) " ;
$keyword = $key ;
2014-09-30 06:50:23 +00:00
$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='hiwater' and m.id in (select id from en.keyword where keytype=' " . $type . " ' and keyword in " . $keyword . " ) " );
2012-12-13 03:59:48 +00:00
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
//@todo: add order with title
2016-04-08 09:13:51 +00:00
$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='hiwater')
and id in ( select id from en . keyword where keytype = '".$type."' and keyword in " . $keyword . " )
2016-04-09 04:08:25 +00:00
order by regexp_replace ( title , '[0-9]+' , '' , 'g' ),( substring ( title , '([0-9]+)' )) :: int limit ? offset ? " ;
2012-12-13 03:59:48 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2013-06-07 02:30:26 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
$this -> view -> offset = $offset + 1 ;
2013-10-28 14:54:21 +00:00
}
//获取多项条件并列关系的数据并必须满足limited条件
//$keyword:字符串或字符串数组
//$limited:限制字符串
2014-09-02 05:20:24 +00:00
//$without:明确不包含的字符串数组
private function getmdlimited ( $keyword , $limited , $without = '' )
2013-06-07 02:30:26 +00:00
{
$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 ;
2014-09-02 05:20:24 +00:00
if ( ! empty ( $without ))
{
if ( ! is_array ( $without ))
{
$without = array ( $without );
}
$withoutkey = " ( " ;
foreach ( $without as $wo )
{
$withoutkey .= " ' " . $wo . " ', " ;
}
$withoutkey = substr ( $withoutkey , 0 , - 1 );
$withoutkey .= " ) " ;
}
2014-09-30 06:50:23 +00:00
$sql = " 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
2015-04-11 04:02:55 +00:00
where s . code = 'hiwater' and m . id in ( select id from en . keyword where lower ( keyword ) = lower ( '".$limited."' ))
2014-09-30 06:50:23 +00:00
and m . id in ( select id from en . keyword where keyword in " . $keyword . " ) " ;
if ( ! empty ( $without )) $sql .= " and m.id not in (select id from en.keyword where keyword in $withoutkey ) " ;
2014-09-02 05:20:24 +00:00
$state = $this -> db -> query ( $sql );
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
//@todo: add order with title
2014-09-30 06:50:23 +00:00
$sql = " select uuid,title from en.normalmetadata where
2014-09-02 05:20:24 +00:00
uuid in ( select d . uuid from datasource d left join source s on d . sourceid = s . id where s . code = 'hiwater' )
2015-04-11 04:02:55 +00:00
and id in ( select id from en . keyword where lower ( keyword ) = lower ( '".$limited."' ))
2014-09-30 06:50:23 +00:00
and id in ( select id from en . keyword where keyword in " . $keyword . " ) " ;
if ( ! empty ( $without )) $sql .= " and id not in (select id from en.keyword where keyword in $withoutkey ) " ;
2016-04-09 04:08:25 +00:00
$sql .= " order by regexp_replace(title,'[0-9]+','','g'),(substring(title, '([0-9]+)'))::int limit ? offset ? " ;
2014-09-02 05:20:24 +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 ;
}
//获取多项必须满足的条件
//$keyword:字符串或字符串数组
private function getmdrestricted ( $keyword )
{
$page = ( int ) $this -> _request -> getParam ( 'page' );
if ( empty ( $page )) $page = 1 ;
$offset = $this -> limit * ( $page - 1 );
if ( ! is_array ( $keyword ))
{
$keyword = array ( $keyword );
}
$key = " ( " ;
foreach ( $keyword as $k )
{
2014-09-30 06:50:23 +00:00
$key .= " m.id in (select id from en.keyword where keyword=' " . $k . " ') and " ;
2014-09-02 05:20:24 +00:00
}
$key = substr ( $key , 0 , - 4 );
$key .= " ) " ;
$keyword = $key ;
2014-09-30 06:50:23 +00:00
$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='hiwater' and $keyword " );
2013-06-07 02:30:26 +00:00
$row = $state -> fetchAll ();
$sum = $row [ 0 ][ 'count' ];
//@todo: add order with title
2014-09-30 06:50:23 +00:00
$sql = " select uuid,title from en.normalmetadata m where m.uuid in
2014-09-02 05:20:24 +00:00
( select d . uuid from datasource d left join source s on d . sourceid = s . id where s . code = 'hiwater' )
and $keyword
2016-04-09 04:08:25 +00:00
order by regexp_replace ( title , '[0-9]+' , '' , 'g' ),( substring ( title , '([0-9]+)' )) :: int limit ? offset ? " ;
2013-06-07 02:30:26 +00:00
$this -> view -> metadata = $this -> db -> fetchAll ( $sql , array ( $this -> limit , $offset ));
2012-12-13 03:59:48 +00:00
$this -> view -> page = new Pagination ( $sum , $page , $this -> limit );
$this -> view -> offset = $offset + 1 ;
}
2013-05-26 11:23:36 +00:00
//基于数据作者的浏览(包括认证后的数据作者以及未认证的数据作者)
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 ));
2014-09-30 06:50:23 +00:00
$sql = " select m.* from en.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=? " ;
2013-05-26 11:23:36 +00:00
$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 {
//已经认证过的数据作者
2014-09-30 06:50:23 +00:00
$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 en.normalmetadata) group by u.id,u.username,u.realname " ;
2013-05-26 11:23:36 +00:00
$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 ) {
//列出数据
2014-09-30 06:50:23 +00:00
$sql = " select individual as username from en.responsible where id=? " ;
2013-05-26 11:23:36 +00:00
$this -> view -> author = $this -> db -> fetchRow ( $sql , array ( $id ));
2014-09-30 06:50:23 +00:00
$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 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=? " ;
2013-05-26 11:23:36 +00:00
$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 {
//列出所有作者
2014-09-30 06:50:23 +00:00
$sql = " select distinct responsible.individual as username,responsible.id 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') " ;
2013-05-26 11:23:36 +00:00
$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 ;
}
}
2013-10-28 14:54:21 +00:00
}
2013-05-26 11:23:36 +00:00
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 ) {
2014-09-30 06:50:23 +00:00
$sql = " select distinct m.* from en.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=? " ;
2013-05-26 11:23:36 +00:00
$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 {
//提供全部分类列表
2015-06-20 01:58:23 +00:00
$sql = " select f.id,f.title_en,f.fund_id,f.fund_type_en,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 right join en.normalmetadata 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 " ;
2013-05-26 11:23:36 +00:00
$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' );
}
2013-10-28 14:54:21 +00:00
}
2013-05-26 11:23:36 +00:00
function organizationAction ()
{
$page = $this -> _request -> getParam ( 'page' );
$name = $this -> _request -> getParam ( 'name' );
2014-09-30 06:50:23 +00:00
$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') " );
2013-05-26 11:23:36 +00:00
$this -> view -> organisation = $state -> fetchAll ();
if ( ! empty ( $name )) {
$this -> view -> codename = $name ;
2014-09-30 06:50:23 +00:00
$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=? " ;
2013-05-26 11:23:36 +00:00
$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 {
//提供全部分类列表
}
}
2012-12-13 03:59:48 +00:00
}