Work on search in multiple targets.
[egate.git] / www / search.egw
1 <html>
2 {
3 # $Id: search.egw,v 1.9 1995/11/07 14:56:59 adam Exp $
4
5     if {[info commands saveState] == ""} {
6         source z39util.tcl
7     }
8     global sessionWait
9     global nextSetNo
10     global setNo
11     global hist
12
13     set oldHost $hist($setNo,host)
14
15     if {[wform menu1] == ""} {
16         set setNo [lindex $sessionParms 0]
17     } else {
18         if {![info exists hist($nextSetNo,host)]} {
19            set hist($nextSetNo,host) $oldHost
20         }
21         set setNo $nextSetNo
22         html "using host " $hist($setNo,host) " <br\n"
23         incr nextSetNo
24
25         set hist($setNo,query) [build-query $hist($setNo,host)]
26         set b [wform base]
27         if {$b == ""} {
28             set hist($setNo,database) $databases
29         } else {
30             set hist($setNo,database) $b
31         }
32         set hist($setNo,maxPresent) [wform hits]
33         if {$hist($setNo,maxPresent) == ""} {
34             set hist($setNo,maxPresent) 30
35         }
36     }
37     set host $hist($setNo,host)
38     set databases [lindex $targets($host) 1]
39
40     html "<head><title> WWW/Z39.50 Gateway Search " $host " </title>\n"
41     html "</head><body>\n"
42
43     set startPos [lindex $sessionParms 1]
44     set endPos [lindex $sessionParms 2]
45     set setMax 0
46     set setOffset 0
47     if {$startPos == ""} {
48         if {[z39search $setNo 1] != "1"} {
49             return
50         }
51         set r [z39.$setNo resultCount]
52         html "<h2> Search result $r hits</h2>\n"
53         wflush
54         set setOffset [z39.$setNo numberOfRecordsReturned]
55         display-rec 1 $setOffset display-brief z39
56         incr setOffset
57         set setMax [z39.$setNo resultCount]
58         if {$setMax > $hist($setNo,maxPresent)} {
59             set setMax $hist($setNo,maxPresent)
60         }
61     } else {
62         if {[z39search $setNo 0] != "1"} {
63             return 
64         }
65         set r [z39.$setNo resultCount]
66         html "<h2> Search result $r hits</h2>\n"
67         wflush
68         set setOffset $startPos
69         set setMax [z39.$setNo resultCount]
70         if {$setMax > $endPos} {
71             set setMax $endPos
72         }
73     }
74     if {$setMax > 0} {
75         z39present $setNo $setOffset $setMax display-brief
76     }
77 }
78
79
80 <hr>
81 {
82     if {$setMax < [z39.$setNo resultCount]} {
83         html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
84         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
85         html + [expr $setMax + $hist($setNo,maxPresent)] {"> Next </a>} "| \n"
86     }
87     if {$startPos != "" && $startPos != "1"} {
88         html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
89         html / $sessionId {/search.egw/} $setNo 
90         if {[expr $startPos - $hist($setNo,maxPresent)] > 1} {
91             html + [expr $startPos - $hist($setNo,maxPresent)]
92             html + [expr $startPos - 1]
93         }
94         html {"> Prev </a>} "| \n"
95     }
96     html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
97     html / $sessionId {/targets.egw"> New target </a>} " | \n"
98     html {<a href="http://} $env(SERVER_NAME) $env(SCRIPT_NAME)
99     html / $sessionId {/query.egw/} $host + $setNo {"> New query </a>}
100 }
101
102 {
103     html "<hr>\n"
104     html "<h3>Debug information</h3>\n"
105     html "sessionId: $sessionId <br>\n"
106     html "sessionParms: $sessionParms <br>\n"
107     foreach e {SERVER_NAME PATH_INFO SCRIPT_NAME} {
108         html $e {: } $env($e) {<br>} \n
109     }
110     html "form: " [wform] " <br>\n"
111     html "target: " $host " <br>\n"
112     html "databases: " $hist($setNo,database) " <br>\n"
113     html "selected: " [wform base] " <br>\n"
114     html "query: --" $hist($setNo,query) "-- <br>"
115     html "setNo: " $setNo " <br>\n"
116     html "nextSetNo: " $nextSetNo " <br>\n"
117 }
118
119 </body>
120 </html>