1 |
<?php |
2 |
|
3 |
require("Smarty.class.php"); |
4 |
require("conn.inc"); |
5 |
|
6 |
require("class.swish.php"); |
7 |
require("class.keywords.php"); |
8 |
|
9 |
$smarty = new Smarty; |
10 |
|
11 |
$smarty->assign( array ( Title=>"Pliva d.d." ) ); |
12 |
|
13 |
$section="search"; |
14 |
|
15 |
$q=StripSlashes($q); |
16 |
|
17 |
$title="Search results for '$q'"; |
18 |
$lpic="search"; $lext=".jpg"; |
19 |
$mpic="search.gif"; |
20 |
|
21 |
|
22 |
$get_array = array( "DESC" => "swishdescription"); |
23 |
|
24 |
|
25 |
|
26 |
$main=""; |
27 |
|
28 |
$n_arr = array( 10, 20, 50 ); // number of results (options) |
29 |
|
30 |
if (! isset($n)) $n = $n_arr[0]; // default nr. of resuts |
31 |
if (! isset($f) || $f < 1) $f = 1; // first one |
32 |
|
33 |
$l = ($f + $n - 1); // calc last hit on this page |
34 |
|
35 |
### search |
36 |
$kw = new keywords($q,""); |
37 |
$q_kw = $kw->generate(); |
38 |
|
39 |
$swish = new swish("/data/swish/index/corp"); |
40 |
$swish->set_params($q_kw,$get_array,"",($f-1),$n); |
41 |
|
42 |
$res = $swish->get_result(); |
43 |
|
44 |
$pages = array(); |
45 |
|
46 |
for ($i=0; $i<floor(($swish->number_results+$n-1)/$n); $i++) { |
47 |
$pages[] = array ( |
48 |
url => "q=".urlencode($q)."&f=".($i*$n+1)."&n=$n", |
49 |
page => $i + 1, |
50 |
current => ($f == ($i*$n+1) ? 1 : 0 ), |
51 |
); |
52 |
if ($f == ($i*$n+1)) $curr_page = $i; |
53 |
|
54 |
} |
55 |
if (isset($pages[$curr_page-1])) $prev_page = $pages[$curr_page-1]; |
56 |
if (isset($pages[$curr_page+1])) $next_page = $pages[$curr_page+1]; |
57 |
|
58 |
if ($l > ($swish->number_results + 1)) $l = $swish->number_results+1; |
59 |
|
60 |
$smarty->assign( array( |
61 |
php_self => $PHP_SELF, |
62 |
res => $res, |
63 |
|
64 |
q => $q, |
65 |
q_kw => $q_kw, |
66 |
n_arr => $n_arr, |
67 |
n => $n, |
68 |
|
69 |
f => $f, |
70 |
l => $l, |
71 |
t => ($swish->number_results)+1, |
72 |
search_time => $swish->search_time, |
73 |
run_time => $swish->run_time, |
74 |
|
75 |
pages => $pages, |
76 |
prev_page => $prev_page, |
77 |
next_page => $next_page, |
78 |
|
79 |
)); |
80 |
$main=$smarty->fetch("swish.tpl"); |
81 |
|
82 |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); |
83 |
|
84 |
if ($HTTP_REFERER) { |
85 |
$back_url=$HTTP_REFERER; |
86 |
} else { |
87 |
$back_url="index.php"; |
88 |
} |
89 |
|
90 |
include("common.inc"); |
91 |
$smarty->assign( array( |
92 |
back_url=>"swish.php", |
93 |
MAIN=>$main |
94 |
) ); |
95 |
|
96 |
$smarty->display("index.tpl"); |
97 |
?> |
98 |
|