search.tpl.in 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $oe; ?>" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  6. <meta name="googlebot" content="index,noarchive,nofollow,noodp" />
  7. <meta name="robots" content="index,nofollow,noarchive,noodp" />
  8. <title><?php if (!empty($q)) echo "搜索:" . strip_tags($q) . " - "; ?>@project_name@ 搜索 - Powered by @package_name@ </title>
  9. <meta http-equiv="keywords" content="Fulltext Search Engine @project_name@ @package_name@" />
  10. <meta http-equiv="description" content="Fulltext Search for @project_name@, Powered by @package_name@/@package_version@ " />
  11. <style type="text/css">
  12. /* global */
  13. body { font-size: 14px; font-family: tahoma; color: #444; line-height: 140%; }
  14. a { color: #04c; text-decoration: none; }
  15. a:hover { text-decoration: underline; }
  16. .outer { width: 880px; margin: 0 auto; }
  17. #header h1 { font-size: 24px; margin: 0 0 10px 0; }
  18. #header a, #header a:hover { text-decoration: none; color: #444; }
  19. #footer { font-size: 12px; margin-top: 20px; border-top: 1px solid #46a; padding-top: 10px; color: #666; }
  20. #footer a { color: #666; text-decoration: underline; }
  21. /* form */
  22. form#q-form { margin: 0; }
  23. #q-input { overflow: hidden; zoom: 1; clear: both; }
  24. #q-input .text {
  25. float: left; width: 333px;
  26. padding: 0 3px; line-height: 26px;
  27. -moz-border-bottom-colors: none;
  28. -moz-border-image: none;
  29. -moz-border-left-colors: none;
  30. -moz-border-right-colors: none;
  31. -moz-border-top-colors: none;
  32. border-color: #9A9A9A #CDCDCD #CDCDCD #9A9A9A;
  33. border-style: solid; border-width: 1px;
  34. font: 16px arial; height: 22px;
  35. padding: 4px 7px; vertical-align: top;
  36. background: url("http://su.bdimg.com/static/superpage/img/spis_167a8734.png") no-repeat scroll 0 0 transparent;
  37. }
  38. #q-input .button {
  39. float: left; font-size: 14px; margin-left: 10px;
  40. background: url("http://su.bdimg.com/static/superpage/img/spis_167a8734.png") repeat scroll 0 -35px #DDDDDD;
  41. border: 0 none; cursor: pointer; height: 32px; padding: 0; width: 95px;
  42. }
  43. #q-input .tips { color: #aaa; font-size: 12px; }
  44. #q-options { overflow: hidden; zoom: 1; margin: 10px 0; font-size: 12px; clear: both; }
  45. #q-options h4 { font-size: 14px; float: left; margin: 0; }
  46. #q-options ul { float: left; margin: 0; padding: 0; }
  47. #q-options li { float: left; margin: 0 0 0 10px; padding: 0; list-style: none; }
  48. /* result */
  49. .res_div2 { overflow: hidden; zoom: 1; clear: both; margin-top: 10px; }
  50. .res_div2 h4 { font-size: 16px; font-weight: bold; float: left; margin: 0; padding: 0; }
  51. .res_div2 ul { float: left; margin: 0; padding: 0; }
  52. .res_div2 li { float: left; margin: 0 0 0 0; padding: 0; list-style: none; }
  53. #hot-search h4 { margin: 10px 0; float: none; }
  54. #hot-search li { margin-right: 10px; }
  55. #hot-search li small { font-size: 80%; color: #aaa; }
  56. #res-neck { margin-top: 10px; border-bottom: 1px solid #46a; background: #def; font-size: 12px; padding: 5px; }
  57. #res-error { margin: 20px 0; color: red; }
  58. #res-error strong { font-weight: bold; font-size: 120%; }
  59. #res-fixed h4 { font-size: 14px; font-weight: normal; font-style: italic; }
  60. #res-fixed li { margin: 0 5px; }
  61. #res-fixed li a { color: #a00; }
  62. #res-empty { margin-top: 10px; }
  63. #res-pager a { margin: 0 5px; }
  64. #res-pager strong { margin: 0 5px; }
  65. #res-related { padding: 10px; background: #eee; }
  66. #res-related h4 { font-size: 14px; }
  67. #res-related ul { margin-left: 20px; width: 600px; }
  68. #res-related li { width: 120px; padding: 0 5px; }
  69. #res-related li a { text-decoration: underline; font-size: 12px; }
  70. .res-doc { margin-top: 15px; }
  71. .res-doc em { font-style: normal; color: red; }
  72. .res-doc h2 { font-size: 16px; margin: 0; font-weight: normal; }
  73. .res-doc h2 small { font-size: 12px; color: #aaa; }
  74. .res-doc p { font-size: 12px; color: #666; margin: 4px 0; }
  75. .res-doc ul { overflow: hidden; zoom: 1; margin: 0; padding: 0; }
  76. .res-doc li { list-style: none; padding: 0; margin: 0 20px 0 0; float: left; font-size: 12px; color: #666; }
  77. .res-doc li span { border-bottom: 1px dotted #aaa; font-family: arial; color: #444; }
  78. .ui-autocomplete li.ui-menu-item { font-size: 12px; }
  79. </style>
  80. </head>
  81. <!-- search.tpl @project_name@ 搜索模板 -->
  82. <body>
  83. <div class="outer">
  84. <!-- page header -->
  85. <div id="header"><h1><a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>">@project_name@ 搜索</a></h1></div>
  86. <!-- search form -->
  87. <form id="q-form" method="get">
  88. <div id="q-input">
  89. <input class="text" type="text" name="q" size="40" title="输入任意关键词皆可搜索" value="<?php echo htmlspecialchars($q); ?>" />
  90. <input class="button" type="submit" value=" 搜索! " />
  91. </div>
  92. <div id="q-options">
  93. <h4>选项</h4>
  94. <ul>
  95. @set_filter@
  96. <li><input type="radio" name="f" value="_all" <?php echo $f__all; ?> />全文</li>
  97. <li><input type="checkbox" name="m" value="yes" <?php echo $m_check; ?> />模糊搜索</li>
  98. <li><input type="checkbox" name="syn" value="yes" <?php echo $syn_check; ?> />同义词</li>
  99. <li>
  100. <select name="s" size="1">
  101. <option value="relevance">相关性</option>
  102. @set_sort@
  103. </select>
  104. 排序
  105. </li>
  106. </ul>
  107. </div>
  108. </form>
  109. <!-- hot search -->
  110. <?php if (count($hot) > 0): ?>
  111. <div id="hot-search" class="res_div2">
  112. <h4>热门搜索</h4>
  113. <ul>
  114. <?php foreach($hot as $word => $freq): ?>
  115. <li><a href="<?php echo $_SERVER['SCRIPT_NAME'] . '?q=' . urlencode($word); ?>"><?php echo $word; ?></a><small>(<?php echo $freq; ?>)</small></li>
  116. <?php endforeach; ?>
  117. </ul>
  118. </div>
  119. <?php endif; ?>
  120. <!-- begin search result -->
  121. <?php if (!empty($q)): ?>
  122. <!-- neck bar -->
  123. <div id="res-neck">
  124. 大约有 <strong><?php echo number_format($count); ?></strong> 项符合查询结果,
  125. 库内数据总量为 <strong><?php echo number_format($total); ?></strong> 项。
  126. (搜索耗时:<?php printf('%.4f', $search_cost); ?>秒)
  127. [<a href="<?php echo "$bu&o=$o&n=$n&xml=yes" ;?> " target="_blank">XML</a>]
  128. </div>
  129. <!-- error -->
  130. <?php if (!empty($error)): ?>
  131. <div id="res-error"><strong>错误:</strong><?php echo $error; ?></div>
  132. <?php endif; ?>
  133. <!-- fixed query -->
  134. <?php if (count($corrected) > 0): ?>
  135. <div id="res-fixed" class="res_div2">
  136. <h4>您是不是要找:</h4>
  137. <ul>
  138. <?php foreach ($corrected as $word): ?>
  139. <li><a href="<?php echo $_SERVER['SCRIPT_NAME'] . '?q=' . urlencode($word); ?>"><?php echo $word; ?></a></li>
  140. <?php endforeach; ?>
  141. </ul>
  142. </div>
  143. <?php endif; ?>
  144. <!-- empty result -->
  145. <?php if ($count === 0 && empty($error)): ?>
  146. <div id="res-empty">
  147. <p>找不到和 <strong><?php echo htmlspecialchars($q); ?></strong> 相符的内容或信息。建议您:</p>
  148. <ul>
  149. <li>请检查输入字词有无错误。</li>
  150. <li>请换用另外的查询字词。</li>
  151. <li>请改用较短、较为常见的字词。</li>
  152. </ul>
  153. </div>
  154. <?php endif; ?>
  155. <!-- result doc list -->
  156. <div id="res-list">
  157. <?php foreach ($docs as $doc): ?>
  158. <div class="res-doc">
  159. <h2>
  160. <a href="javascript:void(alert('@field_id@: <?php echo $doc->@field_id@; ?>'));"><?php echo $doc->rank(); ?>. <?php echo $search->highlight(htmlspecialchars($doc->@field_title@)); ?></a>
  161. <small>[<?php echo $doc->percent(); ?>%]</small>
  162. </h2>
  163. <p><?php echo $search->highlight(htmlspecialchars($doc->@field_body@)); ?></p>
  164. <ul>
  165. @field_info@
  166. </ul>
  167. </div>
  168. <?php endforeach; ?>
  169. </div>
  170. <!-- pager -->
  171. <?php if (!empty($pager)): ?>
  172. <div id="res-pager" class="res_div2">
  173. <strong>分页:</strong>
  174. <?php echo $pager; ?>
  175. </div>
  176. <?php endif; ?>
  177. <!-- related query -->
  178. <?php if (count($related) > 0): ?>
  179. <div id="res-related" class="res_div2">
  180. <h4>相关搜索</h4>
  181. <ul>
  182. <?php foreach ($related as $word): ?>
  183. <li><a href="<?php echo $_SERVER['SCRIPT_NAME'] . '?q=' . urlencode($word); ?>"><?php echo $word; ?></a></li>
  184. <?php endforeach; ?>
  185. </ul>
  186. </div>
  187. <?php endif; ?>
  188. <!-- end search result -->
  189. <?php endif; ?>
  190. <!-- footer -->
  191. <div id="footer">
  192. (C)opyright 2011 - @project_name@ search - 页面处理总时间:<?php printf('%.4f', $total_cost); ?>秒 <br />
  193. Powered by <a href="http://www.xunsearch.com" target="_blank"><?php echo PACKAGE_NAME . '/' . PACKAGE_VERSION; ?></a>
  194. </div>
  195. </div><!-- outer -->
  196. <!-- load jquery from google -->
  197. <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css" type="text/css" media="all" />
  198. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  199. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
  200. <!-- ready script -->
  201. <script language="javascript">
  202. $(function(){
  203. // input tips
  204. $('#q-input .text').focus(function(){
  205. if ($(this).val() == $(this).attr('title')) {
  206. $(this).val('').removeClass('tips');
  207. }
  208. }).blur(function(){
  209. if ($(this).val() == '' || $(this).val() == $(this).attr('title')) {
  210. $(this).addClass('tips').val($(this).attr('title'));
  211. }
  212. }).blur().autocomplete({
  213. 'source':'suggest.php',
  214. 'select':function(ev,ui) {
  215. $('#q-input .text').val(ui.item.label);
  216. $('#q-form').submit();
  217. }
  218. });
  219. // submit check
  220. $('#q-form').submit(function(){
  221. var $input = $('#q-input .text');
  222. if ($input.val() == $input.attr('title')) {
  223. alert('请先输入关键词');
  224. $input.focus();
  225. return false;
  226. }
  227. });
  228. });
  229. </script>
  230. </body>
  231. </html>