From 2fe5725b9a61ae17fee13ea8a49f48ac64e0f1dd Mon Sep 17 00:00:00 2001
From: wlx
Date: Fri, 25 Jun 2010 08:54:04 +0000
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=BF=AB=E9=80=9F?=
=?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=87=AA=E5=8A=A8=E5=88=86=E8=AF=8D=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=EF=BC=9B=E5=88=86=E9=A1=B5=E4=B8=AD=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E5=AD=97=EF=BC=9B=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?water=E4=B8=AD=E5=BE=84=E6=B5=81=E8=A7=82=E6=B5=8B=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../default/controllers/DataController.php | 29 ++++------
.../default/controllers/WaterController.php | 26 +++++++++
.../default/views/scripts/water/index.phtml | 30 +++++++---
.../default/views/scripts/water/navi.phtml | 1 +
.../default/views/scripts/water/runoff.phtml | 33 +++++++++++
.../default/views/scripts/water/view.phtml | 2 +-
application/models/Pagination.php | 2 +-
application/models/Search.php | 57 +++++++++++++++++++
8 files changed, 154 insertions(+), 26 deletions(-)
create mode 100644 application/default/views/scripts/water/runoff.phtml
create mode 100644 application/models/Search.php
diff --git a/application/default/controllers/DataController.php b/application/default/controllers/DataController.php
index a5c1db35..a195013b 100755
--- a/application/default/controllers/DataController.php
+++ b/application/default/controllers/DataController.php
@@ -1,6 +1,7 @@
_request->getPost();
//include_once("bcspamblock.php");
//if ($form->isValid($formData)) {
- $page=@(int)$this->_request->getParam('page');
- if (empty($page)) $page=1;
- $limit=10;
- $offset=$limit*($page-1);
- if (!empty($key)) {
- $md=new MetadataTable();
- $db=$md->getAdapter();
- $sql=$db->quoteInto('select count(*) from metadata where title ilike ? or description ilike ?','%'.$key.'%');
- $state=$db->query($sql);
- $row=$state->fetchAll();
- $sum=$row[0]['count'];
- $select=$db->select();
- $select->from('metadata','*')->where('title ilike ? or description ilike ?','%'.$key.'%')->order('title')->limit($limit,$offset);
- $this->view->metadata = $db->fetchAll($select);
- $this->view->page=new Pagination($sum,$page);
- $this->view->key=$key;
- }
+ $page=@(int)$this->_request->getParam('page');
+ if (empty($page)) $page=1;
+ $offset=$this->limit*($page-1);
+ $search=new Search($key);
+ $where=$search->sql_expr(array("title","description"));
+ $row=$this->db->fetchAll("select count(*) from metadata where ".$where);
+ $sum=$row[0]['count'];
+ $sql="select uuid,title,id,description from metadata where ".$where." 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->key=$key;
}
}
/*
diff --git a/application/default/controllers/WaterController.php b/application/default/controllers/WaterController.php
index 9c6daf2d..15d73415 100644
--- a/application/default/controllers/WaterController.php
+++ b/application/default/controllers/WaterController.php
@@ -107,6 +107,10 @@ class WaterController extends DataController
{
$this->getmd('降水','theme');
}
+ function runoffAction()
+ {
+ $this->getmd('径流','theme');
+ }
function hydroAction()
{
$this->getmd('水文','theme');
@@ -142,6 +146,28 @@ class WaterController extends DataController
}
}
+ 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 metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and ".$where);
+ $sum=$row[0]['count'];
+ $sql="select uuid,title,id,description from metadata where source='0595169a-279e-4b95-819f-129d0ba4280d' and ".$where." order by timebegin 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;
+ }
+ }
+
function timelineAction()
{
$fn="watertime.xml";
diff --git a/application/default/views/scripts/water/index.phtml b/application/default/views/scripts/water/index.phtml
index 37319cec..80b4ad61 100755
--- a/application/default/views/scripts/water/index.phtml
+++ b/application/default/views/scripts/water/index.phtml
@@ -67,19 +67,35 @@ Wang WZ, Ran YH, Xin XZ, Ren HZ. Watershed Allied Telemetry Experimental
Research. Journal of Geophysical Research, 2009, 114(D22103),
doi:10.1029/2008JD011590. 下载
-马明国, 刘强, 阎广建, 陈尔学, 肖青, 苏培玺, 胡泽勇, 李新, 牛铮,王维真, 钱金
-波, 宋怡, 丁松爽, 辛晓洲, 任华忠, 黄春林, 晋锐, 车涛, 楚荣忠.黑河流域遥感-
-地面观测同步试验:森林水文和中游干旱区水文试验.地球科学进展,2009,24(7):681-695. 下载
+
马明国,刘强,阎广建,陈尔学,肖青,苏培玺,胡泽勇,李新,牛铮,王维真,钱金波,宋怡,丁松爽,辛晓洲,任华忠,黄春林,晋锐,车涛,楚荣忠。
+黑河流域遥感-地面观测同步试验:森林水文和中游干旱区水文试验。地球科学进展,2009,24(7):681-695. 下载
-王建,车涛,张立新,晋锐,王维真,李新,梁继,郝小华,李弘毅,吴月茹.黑河流域上游寒区
-水文遥感-地面同步观测试验介绍.冰川冻土, 2009, 31(2): 189-197. 下载
+
王建,车涛,张立新,晋锐,王维真,李新,梁继,郝小华,李弘毅,吴月茹。
+黑河流域上游寒区水文遥感-地面同步观测试验介绍。冰川冻土,2009, 31(2): 189-197. 下载
-试验数据的关键词列表
-
+
+
'地点关键词','theme'=>'主题关键词','discipline'=>'学科关键词','stratum'=>'地层关键词','temporal'=>'时间关键词');
diff --git a/application/default/views/scripts/water/navi.phtml b/application/default/views/scripts/water/navi.phtml
index 803990f9..bdc81161 100644
--- a/application/default/views/scripts/water/navi.phtml
+++ b/application/default/views/scripts/water/navi.phtml
@@ -27,6 +27,7 @@
业务气象站观测
区域气象站观测
降水观测
+
径流观测
业务水文站观测
探空观测
diff --git a/application/default/views/scripts/water/runoff.phtml b/application/default/views/scripts/water/runoff.phtml
new file mode 100644
index 00000000..5514d279
--- /dev/null
+++ b/application/default/views/scripts/water/runoff.phtml
@@ -0,0 +1,33 @@
+headTitle($this->config->title->site);
+$this->headTitle($this->config->title->data);
+$this->headTitle()->setSeparator(' - ');
+$this->headLink()->appendStylesheet('/css/water.css');
+$this->breadcrumb('
首页');
+$this->breadcrumb('
'.$this->config->title->data.'');
+$this->breadcrumb('
黑河综合遥感联合试验');
+$this->breadcrumb('径流观测');
+$this->breadcrumb()->setSeparator(' > ');
+?>
+
+
+
+
+
+
+
+metadata) : ?>
+page->getNavigation(); ?>
+
+
+ metadata as $md) : ?>
+
+
+
+
+
+
diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml
index f15f9cea..d580f217 100755
--- a/application/default/views/scripts/water/view.phtml
+++ b/application/default/views/scripts/water/view.phtml
@@ -102,7 +102,7 @@ else
联系人
'资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'分发者','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'调查者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者');
+$party_zh=array('resourceProvider'=>'资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'调查者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者');
$r='';
$i=0;
foreach($this->authors as $k=>$author) :
diff --git a/application/models/Pagination.php b/application/models/Pagination.php
index 57cf0d2f..dd4d8983 100755
--- a/application/models/Pagination.php
+++ b/application/models/Pagination.php
@@ -56,7 +56,7 @@ class Pagination
{
if ($this->_itemCount<$this->_pageSize) return '';
$navigation = '';
- $navigation .= "共$this->_itemCount条 \n";
+ $navigation .= "共有元数据$this->_itemCount条 \n";
$pageCote = ceil($this->_currentPage / ($this->_navigationItemCount - 1)) - 1; //当前页处于第几栏分页
$pageCoteCount = ceil($this->_pageCount / ($this->_navigationItemCount - 1)); //总分页栏
diff --git a/application/models/Search.php b/application/models/Search.php
new file mode 100644
index 00000000..cdc7cf4b
--- /dev/null
+++ b/application/models/Search.php
@@ -0,0 +1,57 @@
+terms = array();
+ $this->text=$text;
+ }
+
+ private function safe_query($search)
+ {
+ return preg_replace('/%|_|\'|\\\\/', '\\\\$0', stripslashes($search));
+ }
+
+ function parse_search($search="", $safe = true)
+ {
+ if (empty($search)) $search=$this->text;
+ $temp = array();
+ preg_match_all('/"([^"]+)"|([^\\s]+)/', (( $safe ) ? $this->safe_query($search) : $search), $temp);
+
+ for ($i = 1; $i < count($temp); $i++)
+ {
+ foreach ( $temp[$i] as $value )
+ {
+ if ( strlen($value) >= 3 )
+ {
+ $this->terms[] = $value;
+ }
+ }
+ }
+
+ }
+
+ function sql_expr($field)
+ {
+ $sql=" 1=1 ";
+ if (!is_array($field))
+ {
+ $field=array($field);
+ }
+ if (!count($this->terms))
+ $this->parse_search();
+ foreach($this->terms as $t)
+ {
+ $sql.=" and (1<>1 ";
+ foreach($field as $f)
+ {
+ $sql.=" or ".$f." ilike '%".$t."%' ";
+ }
+ $sql.=") ";
+ }
+ return $sql;
+ }
+}
\ No newline at end of file