227 lines
7.4 KiB
PHTML
227 lines
7.4 KiB
PHTML
<?php
|
|
$__ = array('q', 'm', 'f', 's', 'p', 'ie', 'oe', 'syn', 'xml','east','west','south','north','begin','end');
|
|
foreach ($__ as $_)
|
|
$$_ = isset($_GET[$_]) ? $_GET[$_] : '';
|
|
// input encoding
|
|
if (!empty($ie) && !empty($q) && strcasecmp($ie, 'UTF-8'))
|
|
{
|
|
$q = XS::convert($q, $cs, $ie);
|
|
$eu .= '&ie=' . $ie;
|
|
}
|
|
|
|
// output encoding
|
|
if (!empty($oe) && strcasecmp($oe, 'UTF-8'))
|
|
{
|
|
|
|
function xs_output_encoding($buf)
|
|
{
|
|
return XS::convert($buf, $GLOBALS['oe'], 'UTF-8');
|
|
}
|
|
ob_start('xs_output_encoding');
|
|
$eu .= '&oe=' . $oe;
|
|
}
|
|
else
|
|
{
|
|
$oe = 'UTF-8';
|
|
}
|
|
// recheck request parameters
|
|
$q = get_magic_quotes_gpc() ? stripslashes($q) : $q;
|
|
$f = empty($f) ? '_all' : $f;
|
|
${'m_check'} = ($m == 'yes' ? ' checked' : '');
|
|
${'syn_check'} = ($syn == 'yes' ? ' checked' : '');
|
|
${'f_' . $f} = ' checked';
|
|
${'s_' . $s} = ' selected';
|
|
$search=$this->search;
|
|
|
|
$this->headTitle($this->config->title->site);
|
|
$this->headTitle('首页');
|
|
$this->headTitle('搜索');
|
|
$this->headTitle()->setSeparator(' - ');
|
|
$this->headLink()->appendStylesheet('/css/search.css');
|
|
$this->nav[] = array('link'=>"/search",'title'=>'全文搜索');
|
|
?>
|
|
<?= $this->render('breadcrumbs.phtml'); ?>
|
|
<div class="row">
|
|
<div class="span12">
|
|
<!-- search form -->
|
|
<form id="q-form" class="form-search form-inline" method="get">
|
|
<div id="q-input" class="input-append">
|
|
<input class="span4 search-query text" type="text" name="q" placeholder="输入任意关键词皆可搜索" value="<?php echo htmlspecialchars($q); ?>" />
|
|
<button type="submit" class="btn">Search</button>
|
|
</div>
|
|
<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="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>
|
|
按
|
|
<select name="s" size="1">
|
|
<option value="relevance">相关性</option>
|
|
|
|
</select>
|
|
排序
|
|
</li>-->
|
|
</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 -->
|
|
<?php if (count($this->hot) > 0): ?>
|
|
<div id="hot-search" class="res_div2">
|
|
<h4>热门搜索</h4>
|
|
<ul>
|
|
<?php foreach($this->hot as $word => $freq): ?>
|
|
<li><a href="/search?q=<?php echo urlencode($word); ?>"><?php echo $word; ?></a><small>(<?php echo $freq; ?>)</small></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- begin search result -->
|
|
|
|
<!-- neck bar -->
|
|
<div id="res-neck">
|
|
大约有 <strong><?php echo number_format($this->count); ?></strong> 项符合查询结果,
|
|
库内数据总量为 <strong><?php echo number_format($this->total); ?></strong> 项。
|
|
(搜索耗时:<?php printf('%.4f', $this->search_cost); ?>秒 - 页面处理时间:<?php printf('%.4f', $this->total_cost); ?>秒)
|
|
[<a href="<?php echo "$this->base_url&xml=yes&p=$p" ;?> " target="_blank">XML</a>]
|
|
</div>
|
|
|
|
<!-- error -->
|
|
<?php if (!empty($this->error)): ?>
|
|
<div id="res-error"><strong>错误:</strong><?php echo $this->error; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<!-- fixed query -->
|
|
<?php if (count($this->corrected) > 0): ?>
|
|
<div id="res-fixed" class="res_div2">
|
|
<h4>您是不是要找:</h4>
|
|
<ul>
|
|
<?php foreach ($this->corrected as $word): ?>
|
|
<li><a href="<?php echo '/search?q=' . urlencode($word); ?>"><?php echo $word; ?></a></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($this->expanded) > 0): ?>
|
|
<div id="res-fixed" class="res_div2">
|
|
<h4>您是不是要找:</h4>
|
|
<ul>
|
|
<?php foreach ($this->expanded as $word): ?>
|
|
<li><a href="<?php echo '/search?q=' . urlencode($word); ?>"><?php echo $word; ?></a></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
|
|
<!-- empty result -->
|
|
<?php if ($this->count === 0 && empty($this->error)): ?>
|
|
<div id="res-empty">
|
|
<p>找不到和 <strong><?php echo htmlspecialchars($q); ?></strong> 相符的内容或信息。建议您:</p>
|
|
<ul>
|
|
<li>请检查输入字词有无错误。</li>
|
|
<li>请换用另外的查询字词。</li>
|
|
<li>请改用较短、较为常见的字词。</li>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- result doc list -->
|
|
<div id="res-list">
|
|
<?php foreach ($this->docs as $doc): ?>
|
|
<div class="res-doc">
|
|
<h2>
|
|
<a href="/data/<?php echo $doc->uuid; ?>"><?php echo $doc->rank(); ?>. <?php echo $this->search->highlight(htmlspecialchars($doc->title)); ?></a>
|
|
<small>[<?php echo $doc->percent(); ?>%]</small>
|
|
</h2>
|
|
<p><?php echo $search->highlight(htmlspecialchars($doc->description)); ?></p>
|
|
<ul>
|
|
<li><span>关键词:</span> <?php echo $search->highlight(htmlspecialchars($doc->keyword)); ?></li>
|
|
<li><span>元数据:</span> <?php echo $search->highlight(htmlspecialchars($doc->data)); ?></li>
|
|
</ul>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<!-- pager -->
|
|
<?php if (!empty($this->pager)): ?>
|
|
<div id="res-pager" class="res_div2">
|
|
<strong>分页:</strong>
|
|
<?php echo $this->pager; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- related query -->
|
|
<?php if (count($this->related) > 0): ?>
|
|
<div id="res-related" class="res_div2">
|
|
<h4>相关搜索</h4>
|
|
<ul>
|
|
<?php foreach ($this->related as $word): ?>
|
|
<li><a href="<?php echo '/search?q=' . urlencode($word); ?>"><?php echo $word; ?></a></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- end search result -->
|
|
</div>
|
|
</div><!-- outer -->
|
|
|
|
<!-- load jquery from google -->
|
|
<link rel="stylesheet" href="/js/lib/jquery.ui/jquery-ui.lasted.css" type="text/css" media="all" />
|
|
<script type="text/javascript" src="/js/lib/jquery.ui/jquery-ui.lasted.js"></script>
|
|
|
|
<!-- ready script -->
|
|
<script language="javascript">
|
|
$(function(){
|
|
// input tips
|
|
$('#q-input .text').focus(function(){
|
|
if ($(this).val() == $(this).attr('title')) {
|
|
$(this).val('').removeClass('tips');
|
|
}
|
|
}).blur(function(){
|
|
if ($(this).val() == '' || $(this).val() == $(this).attr('title')) {
|
|
$(this).addClass('tips').val($(this).attr('title'));
|
|
}
|
|
}).blur().autocomplete({
|
|
'source':'/search/suggest',
|
|
'select':function(ev,ui) {
|
|
$('#q-input .text').val(ui.item.label);
|
|
$('#q-form').submit();
|
|
}
|
|
});
|
|
// submit check
|
|
$('#q-form').submit(function(){
|
|
var $input = $('#q-input .text');
|
|
/*if ($input.val() == $input.attr('title')) {
|
|
alert('请先输入关键词');
|
|
$input.focus();
|
|
return false;
|
|
}*/
|
|
});
|
|
//advance search
|
|
$('#advance').click(function(){
|
|
$('#q-form').attr('action','/search/advance');
|
|
$('#q-form').submit();
|
|
});
|
|
});
|
|
</script>
|