first init yrnmr project

This commit is contained in:
wlx 2012-08-30 09:35:50 +00:00
parent 77784c77ba
commit 788ea2097e
4 changed files with 385 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import.dir=../data/import
title.site=西部数据中心 title.site=西部数据中心
title.data=数据产品与服务 title.data=数据产品与服务
title.heihe=黑河计划数据整理服务 title.heihe=黑河计划数据整理服务
title.yrnmr=黄河上游宁蒙河段综合数据平台
title.review=数据评审 title.review=数据评审
title.author=数据作者 title.author=数据作者
title.knowledge=知识积累 title.knowledge=知识积累

View File

@ -0,0 +1,311 @@
<?php
class YrnmrController extends DataController
{
private $limit=20;
function preDispatch()
{
parent::preDispatch();
$this->_helper->layout->setLayout('yrnmr');
}
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 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='<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="/heihe/view/uuid/'.$row['uuid'].'">';
$desc_length=mb_strlen($row['description'],"UTF-8");
$desc=mb_substr($row['description'],0,($desc_length>300)?300:$desc_length,"UTF-8");
if ($desc_length>300) $desc.=" ...";
$timexml.=htmlspecialchars($desc);
$timexml.="</event>\n";
}
$timexml.='</data>';
$fp=fopen($fn,'w');
fwrite($fp,$timexml);
fclose($fp);
}
}
function categoryAction()
{
$code = (int)$this->_request->getParam('code');
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$offset=$this->limit*($page-1);
$this->view->category=$this->db->fetchAll("select c.code,name,name_zh,count(*) from category c left join normalmetadata m on c.id=m.id,categorycode cc where c.code=cc.code and m.uuid in (select d.uuid from datasource d left join source s on d.sourceid=s.id where s.code='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;
}
}

View File

@ -0,0 +1,34 @@
<div id="divHeader">
<div id="heiheLogo">
<a href="/yrnmr"><img src="/images/yrnmr-logo.png" alt="yrnmr Logo" /></a>
</div>
<div class="nav">
<div id="divNavi">
<ul>
<!-- CSS Tabs -->
<li><a href="/"><span>首页</span></a></li>
<!-- <li><a href="/news"><span>新闻动态</span></a></li> -->
<li><a href="/data"><span>数据产品与服务</span></a></li>
<li><a href="/review"><span>数据评审</span></a></li>
<li><a href="/author"><span>数据作者</span></a></li>
<li><a href="/knowledge"><span>知识积累</span></a></li>
<li><a href="/community"><span>合作与交流</span></a></li>
<li><a href="/about"><span>关于本站</span></a></li>
</ul>
</div>
<div id="userNavi">
<?php
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity())
{
$user = $auth->getIdentity();
echo '<a href="/account/edit">'.$user->username.'</a> ';
if ($user->usertype=="administrator") echo '<a href="/admin">后台管理</a> ';
echo '<a href="/data/order">数据篮</a> <a href="/account/logout">注销</a>';
} else {
echo '<a href="/account/login">登录</a> <a href="/account/register">注册</a>';
}
?>
</div>
</div>
</div>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen"
href="/css/default.css" />
<link rel="stylesheet" type="text/css" media="screen"
href="/css/heihe.css" />
<script src='/js/navi.js' type="text/javascript"></script>
<link rel="alternate" type="application/rss+xml" title="WestDC RSS Feed" href="/data/feed" />
<link rel="pingback" href="http://westdc.westgis.ac.cn/data/pingback" />
<?= $this->headTitle() ?>
<?= $this->headScript() ?>
<?= $this->headLink() ?>
<?= $this->headStyle() ?>
</head>
<body>
<?= $this->render('yrnmr_header.phtml') ?>
<div class="clearLine"/>
<div id="divBreadCrumb"><?= $this->breadcrumb() ?> </div>
<div id="divContent"><?= $this->layout()->content ?></div>
<div class="clearLine"/>
<?= $this->render('footer.phtml') ?>
<script type="text/javascript">setPage();</script>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.westgis.ac.cn/" : "http://piwik.westgis.ac.cn/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 5);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://piwik.westgis.ac.cn/piwik.php?idsite=5" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
</body>
</html>