226 lines
7.2 KiB
PHTML
226 lines
7.2 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('Home');
|
||
$this->headTitle('Search');
|
||
$this->headTitle()->setSeparator(' - ');
|
||
$this->headLink()->appendStylesheet('/css/search.css');
|
||
$this->nav[] = array('link'=>"/search",'title'=>'Full Text Search');
|
||
?>
|
||
<?= $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="Input any words to search" 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; ?> />Title
|
||
<input type="radio" name="f" value="_all" <?php if (!empty($f__all)) echo $f__all; ?> />Fulltext
|
||
<input type="checkbox" name="m" value="yes" <?php echo $m_check; ?> />fuzzy
|
||
<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">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">Temporal Range</span>';
|
||
if ($begin) echo 'Start: '.$begin;
|
||
if ($end) echo 'End: '.$end;
|
||
if ($east) echo '<span class="text-success">Spatial Range</span> E:'.$east.' W:'.$west.' S:'.$south.' N:'.$north;
|
||
echo '</div>';
|
||
}
|
||
?>
|
||
|
||
<!-- hot search -->
|
||
<?php if (count($this->hot) > 0): ?>
|
||
<div id="hot-search" class="res_div2">
|
||
<h4>Hot Search</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">
|
||
Hitted <strong><?php echo number_format($this->count); ?></strong> items,
|
||
Total <strong><?php echo number_format($this->total); ?></strong> items.
|
||
(Search time: <?php printf('%.4f', $this->search_cost); ?> Seconds - Page generated time: <?php printf('%.4f', $this->total_cost); ?>Seconds)
|
||
[<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>Error: </strong><?php echo $this->error; ?></div>
|
||
<?php endif; ?>
|
||
|
||
<!-- fixed query -->
|
||
<?php if (count($this->corrected) > 0): ?>
|
||
<div id="res-fixed" class="res_div2">
|
||
<h4>Are you interested in :</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>Are you interested in : </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>Could not find results related with <strong><?php echo htmlspecialchars($q); ?></strong>. Recommendation: </p>
|
||
<ul>
|
||
<li>Are there some errors in your query string?</li>
|
||
<li>Change your query string.</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>Keywords: </span> <?php echo $search->highlight(htmlspecialchars($doc->keyword)); ?></li>
|
||
<li><span>Metadata: </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>Page: </strong>
|
||
<?php echo $this->pager; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<!-- related query -->
|
||
<?php if (count($this->related) > 0): ?>
|
||
<div id="res-related" class="res_div2">
|
||
<h4>Related Search</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>
|