集成高级搜索到xunsearch
This commit is contained in:
parent
eaf8c644f2
commit
0ce5031ff6
|
@ -7,6 +7,7 @@ class SearchController extends Zend_Controller_Action
|
||||||
$this->view->config = Zend_Registry::get('config');
|
$this->view->config = Zend_Registry::get('config');
|
||||||
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
||||||
$this->view->messages = $this->messenger->getMessages();
|
$this->view->messages = $this->messenger->getMessages();
|
||||||
|
$this->view->theme = new Theme();
|
||||||
$this->view->nav = array(
|
$this->view->nav = array(
|
||||||
array('link'=>'/','title'=>'<i class="icon-home"></i>'),
|
array('link'=>'/','title'=>'<i class="icon-home"></i>'),
|
||||||
array('link'=>'/data','title'=>$this->view->config->title->data),
|
array('link'=>'/data','title'=>$this->view->config->title->data),
|
||||||
|
@ -38,5 +39,15 @@ class SearchController extends Zend_Controller_Action
|
||||||
$this->_helper->viewRenderer->setNoRender();
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
header("Content-Type: application/json; charset=utf-8");
|
header("Content-Type: application/json; charset=utf-8");
|
||||||
echo $search->suggest($q);
|
echo $search->suggest($q);
|
||||||
}
|
}
|
||||||
|
function advanceAction()
|
||||||
|
{
|
||||||
|
$this->view->east=$this->getParam('east');
|
||||||
|
$this->view->west=$this->getParam('west');
|
||||||
|
$this->view->south=$this->getParam('south');
|
||||||
|
$this->view->north=$this->getParam('north');
|
||||||
|
$this->view->begin=$this->getParam('begin');
|
||||||
|
$this->view->end=$this->getParam('end');
|
||||||
|
$this->view->q=$this->getParam('q');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ $this->headTitle()->setSeparator(' - ');
|
||||||
<input type="text" value="" id="q" name="q" class="span2 search-query" placeholder="全文搜索">
|
<input type="text" value="" id="q" name="q" class="span2 search-query" placeholder="全文搜索">
|
||||||
<button type="submit" class="btn"><i class="icon-search"></i>搜索</button>
|
<button type="submit" class="btn"><i class="icon-search"></i>搜索</button>
|
||||||
</div>
|
</div>
|
||||||
<a class="btn" href="/data/advancesearch"><i class="icon-search"></i>高级搜索</a>
|
<a class="btn" href="/search/advance"><i class="icon-search"></i>高级搜索</a>
|
||||||
<a class="btn" href="/data/browse"><i class="icon-reorder"></i>数据列表浏览</a>
|
<a class="btn" href="/data/browse"><i class="icon-reorder"></i>数据列表浏览</a>
|
||||||
<a class="btn" href="/data/onlinelist"><i class="icon-th"></i>在线数据清单</a>
|
<a class="btn" href="/data/onlinelist"><i class="icon-th"></i>在线数据清单</a>
|
||||||
<a class="btn" href="/data/offlinelist"><i class="icon-th"></i>离线数据清单</a>
|
<a class="btn" href="/data/offlinelist"><i class="icon-th"></i>离线数据清单</a>
|
||||||
|
|
|
@ -0,0 +1,212 @@
|
||||||
|
<?php
|
||||||
|
$this->headTitle($this->config->title->site);
|
||||||
|
$this->headTitle($this->config->title->data);
|
||||||
|
$this->headTitle('高级搜索');
|
||||||
|
if (!empty($this->codename)) $this->headTitle($this->codename);
|
||||||
|
$this->headTitle()->setSeparator(' - ');
|
||||||
|
$this->headLink()->appendStylesheet('/css/metadata.css');
|
||||||
|
$this->breadcrumb('<a href="/">首页</a>');
|
||||||
|
$this->breadcrumb('<a href="/data">'.$this->config->title->data.'</a>');
|
||||||
|
$this->breadcrumb('高级搜索');
|
||||||
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
|
$this->theme->AppendPlus($this,'google_map_v3');
|
||||||
|
$this->theme->AppendPlus($this,'google_map_keydragzone');
|
||||||
|
$this->theme->AppendPlus($this,'jquery_ui');
|
||||||
|
$this->theme->AppendPlus($this,'colorbox');
|
||||||
|
?>
|
||||||
|
<div>
|
||||||
|
<?= $this->partial('data/tools.phtml'); ?>
|
||||||
|
</div>
|
||||||
|
<?php if (!empty($this->metadata)) :
|
||||||
|
echo $this->page->getNavigation();?>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<?php
|
||||||
|
foreach($this->metadata as $md) : ?>
|
||||||
|
<div class="mditem">
|
||||||
|
<div class="thumb"><img src="/service/thumb/id/<?php echo $md['id'];?>" /></div>
|
||||||
|
<h2><a href="/data/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a>
|
||||||
|
</h2>
|
||||||
|
<span><?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?></span>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php echo $this->page->getNavigation();?>
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="span8" id="map_canvas" style="height:500px;"></div>
|
||||||
|
<div class="span4">
|
||||||
|
<form id="search" enctype="application/x-www-form-urlencoded" action="/search" method="get">
|
||||||
|
<fieldset><legend>时间范围</legend>
|
||||||
|
<label>
|
||||||
|
开始时间
|
||||||
|
<input name="begin" type="text" id="begin" value="<?php echo $this->begin; ?>"/>
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
结束时间
|
||||||
|
<input name="end" type="text" id="end" value="<?php echo $this->end; ?>" />
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset><legend>空间范围(按住shift键,在地图上拉框)</legend>
|
||||||
|
<label>东
|
||||||
|
<input name="east" id="east" type="text" value="<?php echo $this->east; ?>"/></label>
|
||||||
|
<label>南
|
||||||
|
<input name="south" id="south" type="text" value="<?php echo $this->south; ?>" /></label>
|
||||||
|
<label>西
|
||||||
|
<input name="west" id="west" type="text" value="<?php echo $this->west; ?>" /></label>
|
||||||
|
<label>北
|
||||||
|
<input name="north" id="north" type="text" value="<?php echo $this->north; ?>" /></label>
|
||||||
|
</fieldset>
|
||||||
|
<label>关键词
|
||||||
|
<input name="q" id="q" type="text" value="<?php echo $this->q; ?>"/></label>
|
||||||
|
<button id="search" class="btn btn-large btn-block btn-primary" type="submit" value="" onclick="dosubmit()" ><i class="icon-search"></i>搜索</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
//Google map (不启用预先加载)
|
||||||
|
google.maps.event.addDomListener(window, 'load', initialize);
|
||||||
|
//jquery ui datepicker
|
||||||
|
$("#begin").datepicker({dateFormat:"yy-mm-dd"});
|
||||||
|
$("#end").datepicker({dateFormat:"yy-mm-dd"});
|
||||||
|
});
|
||||||
|
// Google Map Part
|
||||||
|
var map = null;
|
||||||
|
var mapElementID = "map_canvas";
|
||||||
|
var bounds = null;
|
||||||
|
var rectangle = null;
|
||||||
|
var input = {east:'#east',west:'#west',north:'#north',south:'#south'};
|
||||||
|
|
||||||
|
function initialize() {
|
||||||
|
//加载地图
|
||||||
|
var myLatlng = new google.maps.LatLng(35.656456,105.819946);
|
||||||
|
var myOptions = {
|
||||||
|
zoom: 3,
|
||||||
|
center: myLatlng,
|
||||||
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||||
|
}
|
||||||
|
map = new google.maps.Map(document.getElementById(mapElementID), myOptions);
|
||||||
|
|
||||||
|
//Keydragzone
|
||||||
|
map.enableKeyDragZoom({
|
||||||
|
key: "shift",
|
||||||
|
boxStyle: {
|
||||||
|
border: "1px dashed black",
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
opacity: 1.0
|
||||||
|
},
|
||||||
|
veilStyle: {
|
||||||
|
backgroundColor: "white",
|
||||||
|
opacity: 0.35,
|
||||||
|
cursor: "crosshair"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var dz = map.getDragZoomObject();
|
||||||
|
google.maps.event.addListener(dz, 'dragstart', function (latlng) {
|
||||||
|
RemoveRectangle();
|
||||||
|
//console.dir(latlng);
|
||||||
|
});
|
||||||
|
google.maps.event.addListener(dz, 'dragend', function (latlng) {
|
||||||
|
console.log(latlng);
|
||||||
|
MapValueChange(latlng.fa.d,latlng.$.d,latlng.fa.b,latlng.$.b);
|
||||||
|
setRectangle(latlng.fa.d,latlng.fa.b,latlng.$.b,latlng.$.d);
|
||||||
|
//console.dir(latlng);
|
||||||
|
});
|
||||||
|
|
||||||
|
InputValueChange();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function setRectangle(east,west,south,north){
|
||||||
|
|
||||||
|
bounds = new google.maps.LatLngBounds(
|
||||||
|
new google.maps.LatLng(south,west),
|
||||||
|
new google.maps.LatLng(north,east)
|
||||||
|
);
|
||||||
|
|
||||||
|
rectangle = new google.maps.Rectangle({
|
||||||
|
bounds: bounds,
|
||||||
|
editable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
rectangle.setMap(map);
|
||||||
|
|
||||||
|
google.maps.event.addListener(rectangle, 'bounds_changed', function () {
|
||||||
|
var latlng = rectangle.getBounds();
|
||||||
|
MapValueChange(latlng.fa.d,latlng.Z.d,latlng.fa.b,latlng.Z.b);
|
||||||
|
//console.dir(latlng);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function RemoveRectangle(){
|
||||||
|
if(rectangle != null)
|
||||||
|
{
|
||||||
|
rectangle.setMap(null);
|
||||||
|
rectangle = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function MapValueChange(east,north,west,south){
|
||||||
|
$(input.east).val(east);
|
||||||
|
$(input.north).val(north);
|
||||||
|
$(input.west).val(west);
|
||||||
|
$(input.south).val(south);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InputValueChange(){
|
||||||
|
if(MapInputValueCheck() == true)
|
||||||
|
{
|
||||||
|
if(rectangle == null)
|
||||||
|
{
|
||||||
|
setRectangle($(input.east).val(),$(input.west).val(),$(input.south).val(),$(input.north).val());
|
||||||
|
}else{
|
||||||
|
var reSetBounds = new google.maps.LatLngBounds(
|
||||||
|
new google.maps.LatLng($(input.south).val(),$(input.west).val()),
|
||||||
|
new google.maps.LatLng($(input.north).val(),$(input.east).val())
|
||||||
|
);
|
||||||
|
rectangle.setBounds(reSetBounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function MapInputValueCheck()
|
||||||
|
{
|
||||||
|
if($(input.east).val() != "" && $(input.west).val() != "" && $(input.north).val() != "" && $(input.south).val() != "")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(input.east).bind('blur',InputValueChange);
|
||||||
|
$(input.west).bind('blur',InputValueChange);
|
||||||
|
$(input.north).bind('blur',InputValueChange);
|
||||||
|
$(input.south).bind('blur',InputValueChange);
|
||||||
|
|
||||||
|
// Google map Part --End
|
||||||
|
|
||||||
|
|
||||||
|
function Alert(content){
|
||||||
|
$.colorbox({innerWidth:'40%',html:'<div style="line-height:30px;font-size:16px;">'+ content +'</div>'});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dosubmit() {
|
||||||
|
theForm.action="/search";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<div id="help">
|
||||||
|
<fieldset><legend>搜索说明</legend><ul><li>关键词:您可以使用一个关键词,比如“沙漠”,也可以使用多个关键词,中间用空格分开。</li>
|
||||||
|
<li>空间范围:这是以度为单位的十进制数字。比如,东经125度30分,可以输入为125.5。您也可以通过下面的在线地图工具直接在图上拉框选择一个范围,空间坐标会自动转换到文本框中。</li>
|
||||||
|
<li>时间范围:指数据的时间范围,从开始时间到结束时间。开始时间与结束时间可以为空,若仅填写开始时间,则含义为选择大于开始时间的数据。若仅填写结束时间,则含义为选择小于结束时间的数据。时间格式为YYYY-MM-DD。</li>
|
||||||
|
<li>还不清楚?您可以到<a href="http://forum.westgis.ac.cn/viewforum.php?f=30">论坛</a>提问。</li>
|
||||||
|
</ul></fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php endif; ?>
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
$__ = array('q', 'm', 'f', 's', 'p', 'ie', 'oe', 'syn', 'xml');
|
$__ = array('q', 'm', 'f', 's', 'p', 'ie', 'oe', 'syn', 'xml','east','west','south','north','begin','end');
|
||||||
foreach ($__ as $_)
|
foreach ($__ as $_)
|
||||||
$$_ = isset($_GET[$_]) ? $_GET[$_] : '';
|
$$_ = isset($_GET[$_]) ? $_GET[$_] : '';
|
||||||
// input encoding
|
// input encoding
|
||||||
|
@ -46,12 +46,19 @@ $this->nav[] = array('link'=>"/search",'title'=>'全文搜索');
|
||||||
<!-- search form -->
|
<!-- search form -->
|
||||||
<form id="q-form" class="form-search form-inline" method="get">
|
<form id="q-form" class="form-search form-inline" method="get">
|
||||||
<div id="q-input" class="input-append">
|
<div id="q-input" class="input-append">
|
||||||
<input class="span4 search-query text" type="text" name="q" title="输入任意关键词皆可搜索" value="<?php echo htmlspecialchars($q); ?>" />
|
<input class="span4 search-query text" type="text" name="q" placeholder="输入任意关键词皆可搜索" value="<?php echo htmlspecialchars($q); ?>" />
|
||||||
<button type="submit" class="btn">Search</button>
|
<button type="submit" class="btn">Search</button>
|
||||||
</div>
|
</div>
|
||||||
<input type="radio" name="f" value="title" <?php if (!empty($f_title)) echo $f_title; ?> />标题
|
<input type="radio" name="f" value="title" <?php if (!empty($f_title)) echo $f_title; ?> />标题
|
||||||
<input type="radio" name="f" value="_all" <?php if (!empty($f__all)) echo $f__all; ?> />全文
|
<input type="radio" name="f" value="_all" <?php if (!empty($f__all)) echo $f__all; ?> />全文
|
||||||
<input type="checkbox" name="m" value="yes" <?php echo $m_check; ?> />模糊搜索
|
<input type="checkbox" name="m" value="yes" <?php echo $m_check; ?> />模糊搜索
|
||||||
|
<input type="hidden" name="east" value="<?php echo $east; ?>" />
|
||||||
|
<input type="hidden" name="west" value="<?php echo $west; ?>" />
|
||||||
|
<input type="hidden" name="south" value="<?php echo $south; ?>" />
|
||||||
|
<input type="hidden" name="north" value="<?php echo $north; ?>" />
|
||||||
|
<input type="hidden" name="begin" value="<?php echo $begin; ?>" />
|
||||||
|
<input type="hidden" name="end" value="<?php echo $end; ?>" />
|
||||||
|
<button type="button" class="btn" id="advance">高级搜索</button>
|
||||||
<!-- <li><input type="checkbox" name="syn" value="yes" <?php echo $syn_check; ?> />同义词</li>
|
<!-- <li><input type="checkbox" name="syn" value="yes" <?php echo $syn_check; ?> />同义词</li>
|
||||||
<li>
|
<li>
|
||||||
按
|
按
|
||||||
|
@ -62,6 +69,17 @@ $this->nav[] = array('link'=>"/search",'title'=>'全文搜索');
|
||||||
排序
|
排序
|
||||||
</li>-->
|
</li>-->
|
||||||
</form>
|
</form>
|
||||||
|
<?php
|
||||||
|
if ($begin || $end || $east)
|
||||||
|
{
|
||||||
|
echo '<div class="well well-small">';
|
||||||
|
if ($begin || $end) echo '<span class="text-success">时间范围</span>';
|
||||||
|
if ($begin) echo '开始:'.$begin;
|
||||||
|
if ($end) echo '结束:'.$end;
|
||||||
|
if ($east) echo '<span class="text-success">空间范围</span> 东:'.$east.' 西:'.$west.' 南:'.$south.' 北:'.$north;
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- hot search -->
|
<!-- hot search -->
|
||||||
<?php if (count($this->hot) > 0): ?>
|
<?php if (count($this->hot) > 0): ?>
|
||||||
|
@ -194,11 +212,16 @@ $(function(){
|
||||||
// submit check
|
// submit check
|
||||||
$('#q-form').submit(function(){
|
$('#q-form').submit(function(){
|
||||||
var $input = $('#q-input .text');
|
var $input = $('#q-input .text');
|
||||||
if ($input.val() == $input.attr('title')) {
|
/*if ($input.val() == $input.attr('title')) {
|
||||||
alert('请先输入关键词');
|
alert('请先输入关键词');
|
||||||
$input.focus();
|
$input.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
});
|
||||||
|
//advance search
|
||||||
|
$('#advance').click(function(){
|
||||||
|
$('#q-form').attr('action','/search/advance');
|
||||||
|
$('#q-form').submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue